@raymondfox/ts-toolbox 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/http/HttpClient.d.ts +75 -0
- package/dist/http/HttpClient.d.ts.map +1 -0
- package/dist/http/HttpClient.js +237 -0
- package/dist/http/HttpClient.js.map +1 -0
- package/dist/http/index.d.ts +4 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +9 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/types.d.ts +78 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +23 -0
- package/dist/http/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/Logger.d.ts +62 -0
- package/dist/logger/Logger.d.ts.map +1 -0
- package/dist/logger/Logger.js +120 -0
- package/dist/logger/Logger.js.map +1 -0
- package/dist/logger/formatters/JsonFormatter.d.ts +14 -0
- package/dist/logger/formatters/JsonFormatter.d.ts.map +1 -0
- package/dist/logger/formatters/JsonFormatter.js +27 -0
- package/dist/logger/formatters/JsonFormatter.js.map +1 -0
- package/dist/logger/formatters/LoggerFormatter.d.ts +21 -0
- package/dist/logger/formatters/LoggerFormatter.d.ts.map +1 -0
- package/dist/logger/formatters/LoggerFormatter.js +3 -0
- package/dist/logger/formatters/LoggerFormatter.js.map +1 -0
- package/dist/logger/formatters/PrettyFormatter.d.ts +26 -0
- package/dist/logger/formatters/PrettyFormatter.d.ts.map +1 -0
- package/dist/logger/formatters/PrettyFormatter.js +72 -0
- package/dist/logger/formatters/PrettyFormatter.js.map +1 -0
- package/dist/logger/formatters/index.d.ts +5 -0
- package/dist/logger/formatters/index.d.ts.map +1 -0
- package/dist/logger/formatters/index.js +8 -0
- package/dist/logger/formatters/index.js.map +1 -0
- package/dist/logger/index.d.ts +19 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +40 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/transports/BufferedTransport.d.ts +71 -0
- package/dist/logger/transports/BufferedTransport.d.ts.map +1 -0
- package/dist/logger/transports/BufferedTransport.js +111 -0
- package/dist/logger/transports/BufferedTransport.js.map +1 -0
- package/dist/logger/transports/ConsoleTransport.d.ts +26 -0
- package/dist/logger/transports/ConsoleTransport.d.ts.map +1 -0
- package/dist/logger/transports/ConsoleTransport.js +39 -0
- package/dist/logger/transports/ConsoleTransport.js.map +1 -0
- package/dist/logger/transports/DiscordTransport.d.ts +48 -0
- package/dist/logger/transports/DiscordTransport.d.ts.map +1 -0
- package/dist/logger/transports/DiscordTransport.js +96 -0
- package/dist/logger/transports/DiscordTransport.js.map +1 -0
- package/dist/logger/transports/FileTransport.d.ts +104 -0
- package/dist/logger/transports/FileTransport.d.ts.map +1 -0
- package/dist/logger/transports/FileTransport.js +251 -0
- package/dist/logger/transports/FileTransport.js.map +1 -0
- package/dist/logger/transports/HttpTransport.d.ts +47 -0
- package/dist/logger/transports/HttpTransport.d.ts.map +1 -0
- package/dist/logger/transports/HttpTransport.js +57 -0
- package/dist/logger/transports/HttpTransport.js.map +1 -0
- package/dist/logger/transports/LoggerTransport.d.ts +52 -0
- package/dist/logger/transports/LoggerTransport.d.ts.map +1 -0
- package/dist/logger/transports/LoggerTransport.js +33 -0
- package/dist/logger/transports/LoggerTransport.js.map +1 -0
- package/dist/logger/transports/index.d.ts +13 -0
- package/dist/logger/transports/index.d.ts.map +1 -0
- package/dist/logger/transports/index.js +16 -0
- package/dist/logger/transports/index.js.map +1 -0
- package/dist/logger/types/LogLevel.d.ts +17 -0
- package/dist/logger/types/LogLevel.d.ts.map +1 -0
- package/dist/logger/types/LogLevel.js +23 -0
- package/dist/logger/types/LogLevel.js.map +1 -0
- package/dist/logger/types/LogMessage.d.ts +19 -0
- package/dist/logger/types/LogMessage.d.ts.map +1 -0
- package/dist/logger/types/LogMessage.js +3 -0
- package/dist/logger/types/LogMessage.js.map +1 -0
- package/dist/logger/types/LoggerOptions.d.ts +17 -0
- package/dist/logger/types/LoggerOptions.d.ts.map +1 -0
- package/dist/logger/types/LoggerOptions.js +3 -0
- package/dist/logger/types/LoggerOptions.js.map +1 -0
- package/dist/logger/types/index.d.ts +4 -0
- package/dist/logger/types/index.d.ts.map +1 -0
- package/dist/logger/types/index.js +18 -0
- package/dist/logger/types/index.js.map +1 -0
- package/dist/retry/index.d.ts +3 -0
- package/dist/retry/index.d.ts.map +1 -0
- package/dist/retry/index.js +6 -0
- package/dist/retry/index.js.map +1 -0
- package/dist/retry/retry.d.ts +38 -0
- package/dist/retry/retry.d.ts.map +1 -0
- package/dist/retry/retry.js +117 -0
- package/dist/retry/retry.js.map +1 -0
- package/dist/retry/types.d.ts +65 -0
- package/dist/retry/types.d.ts.map +1 -0
- package/dist/retry/types.js +3 -0
- package/dist/retry/types.js.map +1 -0
- package/dist/socket/browserSocket/BrowserSocketClient.d.ts +82 -0
- package/dist/socket/browserSocket/BrowserSocketClient.d.ts.map +1 -0
- package/dist/socket/browserSocket/BrowserSocketClient.js +345 -0
- package/dist/socket/browserSocket/BrowserSocketClient.js.map +1 -0
- package/dist/socket/browserSocket/index.d.ts +2 -0
- package/dist/socket/browserSocket/index.d.ts.map +1 -0
- package/dist/socket/browserSocket/index.js +6 -0
- package/dist/socket/browserSocket/index.js.map +1 -0
- package/dist/socket/index.d.ts +6 -0
- package/dist/socket/index.d.ts.map +1 -0
- package/dist/socket/index.js +15 -0
- package/dist/socket/index.js.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketClient.d.ts +70 -0
- package/dist/socket/nodeSocket/NodeSocketClient.d.ts.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketClient.js +357 -0
- package/dist/socket/nodeSocket/NodeSocketClient.js.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketServer.d.ts +101 -0
- package/dist/socket/nodeSocket/NodeSocketServer.d.ts.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketServer.js +472 -0
- package/dist/socket/nodeSocket/NodeSocketServer.js.map +1 -0
- package/dist/socket/nodeSocket/index.d.ts +4 -0
- package/dist/socket/nodeSocket/index.d.ts.map +1 -0
- package/dist/socket/nodeSocket/index.js +8 -0
- package/dist/socket/nodeSocket/index.js.map +1 -0
- package/dist/socket/shared/ConnectionState.d.ts +5 -0
- package/dist/socket/shared/ConnectionState.d.ts.map +1 -0
- package/dist/socket/shared/ConnectionState.js +3 -0
- package/dist/socket/shared/ConnectionState.js.map +1 -0
- package/dist/socket/shared/Socket.d.ts +34 -0
- package/dist/socket/shared/Socket.d.ts.map +1 -0
- package/dist/socket/shared/Socket.js +83 -0
- package/dist/socket/shared/Socket.js.map +1 -0
- package/dist/socket/shared/SocketEvent.d.ts +8 -0
- package/dist/socket/shared/SocketEvent.d.ts.map +1 -0
- package/dist/socket/shared/SocketEvent.js +3 -0
- package/dist/socket/shared/SocketEvent.js.map +1 -0
- package/dist/socket/shared/SocketMessage.d.ts +25 -0
- package/dist/socket/shared/SocketMessage.d.ts.map +1 -0
- package/dist/socket/shared/SocketMessage.js +3 -0
- package/dist/socket/shared/SocketMessage.js.map +1 -0
- package/dist/socket/shared/SocketMiddleware.d.ts +15 -0
- package/dist/socket/shared/SocketMiddleware.d.ts.map +1 -0
- package/dist/socket/shared/SocketMiddleware.js +27 -0
- package/dist/socket/shared/SocketMiddleware.js.map +1 -0
- package/dist/socket/shared/SocketOptions.d.ts +47 -0
- package/dist/socket/shared/SocketOptions.d.ts.map +1 -0
- package/dist/socket/shared/SocketOptions.js +3 -0
- package/dist/socket/shared/SocketOptions.js.map +1 -0
- package/dist/socket/shared/SocketSerializer.d.ts +16 -0
- package/dist/socket/shared/SocketSerializer.d.ts.map +1 -0
- package/dist/socket/shared/SocketSerializer.js +16 -0
- package/dist/socket/shared/SocketSerializer.js.map +1 -0
- package/dist/socket/shared/SocketValidation.d.ts +10 -0
- package/dist/socket/shared/SocketValidation.d.ts.map +1 -0
- package/dist/socket/shared/SocketValidation.js +3 -0
- package/dist/socket/shared/SocketValidation.js.map +1 -0
- package/dist/socket/shared/TypedSocket.d.ts +48 -0
- package/dist/socket/shared/TypedSocket.d.ts.map +1 -0
- package/dist/socket/shared/TypedSocket.js +3 -0
- package/dist/socket/shared/TypedSocket.js.map +1 -0
- package/dist/socket/shared/index.d.ts +12 -0
- package/dist/socket/shared/index.d.ts.map +1 -0
- package/dist/socket/shared/index.js +10 -0
- package/dist/socket/shared/index.js.map +1 -0
- package/dist/timeout/index.d.ts +4 -0
- package/dist/timeout/index.d.ts.map +1 -0
- package/dist/timeout/index.js +9 -0
- package/dist/timeout/index.js.map +1 -0
- package/dist/timeout/timeout.d.ts +39 -0
- package/dist/timeout/timeout.d.ts.map +1 -0
- package/dist/timeout/timeout.js +68 -0
- package/dist/timeout/timeout.js.map +1 -0
- package/dist/timeout/types.d.ts +30 -0
- package/dist/timeout/types.d.ts.map +1 -0
- package/dist/timeout/types.js +17 -0
- package/dist/timeout/types.js.map +1 -0
- package/package.json +79 -0
- package/readme.md +928 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
const LogLevel_1 = require("./types/LogLevel");
|
|
5
|
+
/**
|
|
6
|
+
* A transport-based logger with support for:
|
|
7
|
+
* - Multiple stacked transports (Console, HTTP, Discord, File, …)
|
|
8
|
+
* - Per-transport level filtering
|
|
9
|
+
* - Pluggable formatters
|
|
10
|
+
* - Scoped logging
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const logger = new Logger({ level: LogLevel.DEBUG });
|
|
15
|
+
*
|
|
16
|
+
* logger.use(new ConsoleTransport());
|
|
17
|
+
* logger.use(new HttpTransport({ url: 'https://logs.example.com/api/logs', level: LogLevel.INFO }));
|
|
18
|
+
* logger.use(new DiscordTransport({ webhook: '...', level: LogLevel.ERROR }));
|
|
19
|
+
*
|
|
20
|
+
* logger.info('Server started', { port: 3000 });
|
|
21
|
+
*
|
|
22
|
+
* const dbLogger = logger.scope('Database');
|
|
23
|
+
* dbLogger.error('Connection failed', { retry: 3 });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
class Logger {
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
this.transports = [];
|
|
29
|
+
this.minimumLevel = options.level ?? LogLevel_1.LogLevel.TRACE;
|
|
30
|
+
this.currentScope = options.scope;
|
|
31
|
+
}
|
|
32
|
+
// ─── Transport registration ───────────────────────────────────────────────
|
|
33
|
+
/**
|
|
34
|
+
* Register a transport. Transports are called in registration order.
|
|
35
|
+
* Returns `this` so calls can be chained.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* logger
|
|
40
|
+
* .use(new ConsoleTransport())
|
|
41
|
+
* .use(new FileTransport({ filePath: './app.log' }));
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
use(transport) {
|
|
45
|
+
this.transports.push(transport);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
// ─── Scoping ──────────────────────────────────────────────────────────────
|
|
49
|
+
/**
|
|
50
|
+
* Returns a new Logger instance with the given scope attached to every entry.
|
|
51
|
+
* The parent logger's transports are shared (not copied).
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const dbLogger = logger.scope('Database');
|
|
56
|
+
* dbLogger.info('Connected'); // → [Database] Connected
|
|
57
|
+
* dbLogger.error('Query failed'); // → [Database] Query failed
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
scope(name) {
|
|
61
|
+
const child = new Logger({
|
|
62
|
+
level: this.minimumLevel,
|
|
63
|
+
scope: this.currentScope ? `${this.currentScope}:${name}` : name,
|
|
64
|
+
});
|
|
65
|
+
// Share transport instances with the child (no duplication)
|
|
66
|
+
for (const t of this.transports) {
|
|
67
|
+
child.use(t);
|
|
68
|
+
}
|
|
69
|
+
return child;
|
|
70
|
+
}
|
|
71
|
+
// ─── Log methods ──────────────────────────────────────────────────────────
|
|
72
|
+
trace(message, context) {
|
|
73
|
+
this._dispatch(LogLevel_1.LogLevel.TRACE, message, context);
|
|
74
|
+
}
|
|
75
|
+
debug(message, context) {
|
|
76
|
+
this._dispatch(LogLevel_1.LogLevel.DEBUG, message, context);
|
|
77
|
+
}
|
|
78
|
+
info(message, context) {
|
|
79
|
+
this._dispatch(LogLevel_1.LogLevel.INFO, message, context);
|
|
80
|
+
}
|
|
81
|
+
success(message, context) {
|
|
82
|
+
this._dispatch(LogLevel_1.LogLevel.SUCCESS, message, context);
|
|
83
|
+
}
|
|
84
|
+
warn(message, context) {
|
|
85
|
+
this._dispatch(LogLevel_1.LogLevel.WARN, message, context);
|
|
86
|
+
}
|
|
87
|
+
error(message, context) {
|
|
88
|
+
this._dispatch(LogLevel_1.LogLevel.ERROR, message, context);
|
|
89
|
+
}
|
|
90
|
+
fatal(message, context) {
|
|
91
|
+
this._dispatch(LogLevel_1.LogLevel.FATAL, message, context);
|
|
92
|
+
}
|
|
93
|
+
// ─── Internal ─────────────────────────────────────────────────────────────
|
|
94
|
+
_dispatch(level, message, context) {
|
|
95
|
+
// Logger-level gate — avoids building the entry at all if not needed
|
|
96
|
+
if (level < this.minimumLevel)
|
|
97
|
+
return;
|
|
98
|
+
const entry = {
|
|
99
|
+
level,
|
|
100
|
+
levelName: (0, LogLevel_1.logLevelName)(level),
|
|
101
|
+
message,
|
|
102
|
+
timestamp: new Date().toISOString(),
|
|
103
|
+
scope: this.currentScope,
|
|
104
|
+
context,
|
|
105
|
+
};
|
|
106
|
+
for (const transport of this.transports) {
|
|
107
|
+
if (!transport.accepts(entry))
|
|
108
|
+
continue;
|
|
109
|
+
const result = transport.send(entry);
|
|
110
|
+
// Fire-and-forget for async transports; surface unexpected errors to stderr
|
|
111
|
+
if (result instanceof Promise) {
|
|
112
|
+
result.catch((err) => {
|
|
113
|
+
console.error('[Logger] Transport error:', err);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.Logger = Logger;
|
|
120
|
+
//# sourceMappingURL=Logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAK1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAKI,YAAY,OAAO,GAAkB,EAAE;QAJtB,eAAU,GAAsB,EAAE,CAAC;QAKhD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,KAAK,IAAI,mBAAQ,CAAC,KAAK,CAAC;QACpD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;IACtC,CAAC;IAED,6EAA6E;IAE7E;;;;;;;;;;OAUG;IACH,GAAG,CAAC,SAA0B;QAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,6EAA6E;IAE7E;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAY;QACd,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC;YACrB,KAAK,EAAE,IAAI,CAAC,YAAY;YACxB,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;SACnE,CAAC,CAAC;QAEH,4DAA4D;QAC5D,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC9B,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,6EAA6E;IAE7E,KAAK,CAAC,OAAe,EAAE,OAAiC;QACpD,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ACV,CAAC;QAEF,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACtC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAS;YAExC,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAErC,4EAA4E;YAC5E,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;gBAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;oBACjB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LogMessage } from '../types/LogMessage';
|
|
2
|
+
import type { LoggerFormatter } from './LoggerFormatter';
|
|
3
|
+
/**
|
|
4
|
+
* Outputs a compact JSON string — ideal for log aggregation systems (e.g. Loki, Datadog).
|
|
5
|
+
*
|
|
6
|
+
* Example output:
|
|
7
|
+
* ```
|
|
8
|
+
* {"level":"ERROR","message":"DB failed","timestamp":"2026-10-01T14:10:00.000Z","scope":"DB","context":{...}}
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare class JsonFormatter implements LoggerFormatter<string> {
|
|
12
|
+
format(entry: LogMessage): string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=JsonFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonFormatter.d.ts","sourceRoot":"","sources":["../../../src/logger/formatters/JsonFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,eAAe,CAAC,MAAM,CAAC;IACzD,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAWhC;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonFormatter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Outputs a compact JSON string — ideal for log aggregation systems (e.g. Loki, Datadog).
|
|
6
|
+
*
|
|
7
|
+
* Example output:
|
|
8
|
+
* ```
|
|
9
|
+
* {"level":"ERROR","message":"DB failed","timestamp":"2026-10-01T14:10:00.000Z","scope":"DB","context":{...}}
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
class JsonFormatter {
|
|
13
|
+
format(entry) {
|
|
14
|
+
const obj = {
|
|
15
|
+
level: entry.levelName.toLowerCase(),
|
|
16
|
+
message: entry.message,
|
|
17
|
+
timestamp: entry.timestamp,
|
|
18
|
+
};
|
|
19
|
+
if (entry.scope)
|
|
20
|
+
obj['scope'] = entry.scope;
|
|
21
|
+
if (entry.context)
|
|
22
|
+
obj['context'] = entry.context;
|
|
23
|
+
return JSON.stringify(obj);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.JsonFormatter = JsonFormatter;
|
|
27
|
+
//# sourceMappingURL=JsonFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonFormatter.js","sourceRoot":"","sources":["../../../src/logger/formatters/JsonFormatter.ts"],"names":[],"mappings":";;;AAGA;;;;;;;GAOG;AACH;IACI,MAAM,CAAC,KAAiB;QACpB,MAAM,GAAG,GAA4B;YACjC,KAAK,EAAM,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE;YACxC,OAAO,EAAI,KAAK,CAAC,OAAO;YACxB,SAAS,EAAE,KAAK,CAAC,SAAS;SAC7B,CAAC;QAEF,IAAI,KAAK,CAAC,KAAK;YAAI,GAAG,CAAC,OAAO,CAAC,GAAK,KAAK,CAAC,KAAK,CAAC;QAChD,IAAI,KAAK,CAAC,OAAO;YAAE,GAAG,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;QAElD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LogMessage } from '../types/LogMessage';
|
|
2
|
+
/**
|
|
3
|
+
* A formatter transforms a {@link LogMessage} into a string (or any value)
|
|
4
|
+
* that a transport will ultimately emit.
|
|
5
|
+
*
|
|
6
|
+
* Implement this interface to create a custom formatter:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* class MyFormatter implements LoggerFormatter<string> {
|
|
10
|
+
* format(entry: LogMessage): string {
|
|
11
|
+
* return `[${entry.levelName}] ${entry.message}`;
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @template T The output type of the formatter (defaults to `string`).
|
|
17
|
+
*/
|
|
18
|
+
export interface LoggerFormatter<T = string> {
|
|
19
|
+
format(entry: LogMessage): T;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=LoggerFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerFormatter.d.ts","sourceRoot":"","sources":["../../../src/logger/formatters/LoggerFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,MAAM;IACvC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerFormatter.js","sourceRoot":"","sources":["../../../src/logger/formatters/LoggerFormatter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LogMessage } from '../types/LogMessage';
|
|
2
|
+
import type { LoggerFormatter } from './LoggerFormatter';
|
|
3
|
+
export interface PrettyFormatterOptions {
|
|
4
|
+
/** Include ANSI colors. @default true */
|
|
5
|
+
colors?: boolean;
|
|
6
|
+
/** Include context object after the message. @default true */
|
|
7
|
+
showContext?: boolean;
|
|
8
|
+
/** Include timestamp. @default true */
|
|
9
|
+
showTimestamp?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Human-friendly, colorized formatter for terminal output.
|
|
13
|
+
*
|
|
14
|
+
* Example output:
|
|
15
|
+
* ```
|
|
16
|
+
* 14:10:00.000 ✖ ERROR [Database] Falha ao conectar { retry: 3 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class PrettyFormatter implements LoggerFormatter<string> {
|
|
20
|
+
private readonly colors;
|
|
21
|
+
private readonly showContext;
|
|
22
|
+
private readonly showTimestamp;
|
|
23
|
+
constructor(options?: PrettyFormatterOptions);
|
|
24
|
+
format(entry: LogMessage): string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=PrettyFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrettyFormatter.d.ts","sourceRoot":"","sources":["../../../src/logger/formatters/PrettyFormatter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA2BzD,MAAM,WAAW,sBAAsB;IACnC,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uCAAuC;IACvC,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,qBAAa,eAAgB,YAAW,eAAe,CAAC,MAAM,CAAC;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IAExC,YAAY,OAAO,GAAE,sBAA2B,EAI/C;IAED,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAkChC;CACJ"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrettyFormatter = void 0;
|
|
4
|
+
const LogLevel_1 = require("../types/LogLevel");
|
|
5
|
+
// ANSI escape codes
|
|
6
|
+
const RESET = '\x1b[0m';
|
|
7
|
+
const BOLD = '\x1b[1m';
|
|
8
|
+
const DIM = '\x1b[2m';
|
|
9
|
+
const LEVEL_STYLES = {
|
|
10
|
+
[LogLevel_1.LogLevel.TRACE]: '\x1b[90m', // dark grey
|
|
11
|
+
[LogLevel_1.LogLevel.DEBUG]: '\x1b[36m', // cyan
|
|
12
|
+
[LogLevel_1.LogLevel.INFO]: '\x1b[34m', // blue
|
|
13
|
+
[LogLevel_1.LogLevel.SUCCESS]: '\x1b[32m', // green
|
|
14
|
+
[LogLevel_1.LogLevel.WARN]: '\x1b[33m', // yellow
|
|
15
|
+
[LogLevel_1.LogLevel.ERROR]: '\x1b[31m', // red
|
|
16
|
+
[LogLevel_1.LogLevel.FATAL]: '\x1b[35m', // magenta
|
|
17
|
+
};
|
|
18
|
+
const LEVEL_ICONS = {
|
|
19
|
+
[LogLevel_1.LogLevel.TRACE]: '·',
|
|
20
|
+
[LogLevel_1.LogLevel.DEBUG]: '⚙',
|
|
21
|
+
[LogLevel_1.LogLevel.INFO]: 'ℹ',
|
|
22
|
+
[LogLevel_1.LogLevel.SUCCESS]: '✔',
|
|
23
|
+
[LogLevel_1.LogLevel.WARN]: '⚠',
|
|
24
|
+
[LogLevel_1.LogLevel.ERROR]: '✖',
|
|
25
|
+
[LogLevel_1.LogLevel.FATAL]: '☠',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Human-friendly, colorized formatter for terminal output.
|
|
29
|
+
*
|
|
30
|
+
* Example output:
|
|
31
|
+
* ```
|
|
32
|
+
* 14:10:00.000 ✖ ERROR [Database] Falha ao conectar { retry: 3 }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
class PrettyFormatter {
|
|
36
|
+
constructor(options = {}) {
|
|
37
|
+
this.colors = options.colors ?? true;
|
|
38
|
+
this.showContext = options.showContext ?? true;
|
|
39
|
+
this.showTimestamp = options.showTimestamp ?? true;
|
|
40
|
+
}
|
|
41
|
+
format(entry) {
|
|
42
|
+
const color = this.colors ? (LEVEL_STYLES[entry.level] ?? '') : '';
|
|
43
|
+
const icon = LEVEL_ICONS[entry.level] ?? '?';
|
|
44
|
+
const parts = [];
|
|
45
|
+
// Timestamp
|
|
46
|
+
if (this.showTimestamp) {
|
|
47
|
+
const ts = new Date(entry.timestamp).toISOString().slice(11, 23); // HH:mm:ss.mmm
|
|
48
|
+
parts.push(this.colors ? `${DIM}${ts}${RESET}` : ts);
|
|
49
|
+
}
|
|
50
|
+
// Icon + level
|
|
51
|
+
const levelTag = `${icon} ${entry.levelName.padEnd(7)}`;
|
|
52
|
+
parts.push(this.colors ? `${color}${BOLD}${levelTag}${RESET}` : levelTag);
|
|
53
|
+
// Scope
|
|
54
|
+
if (entry.scope) {
|
|
55
|
+
const scopeTag = `[${entry.scope}]`;
|
|
56
|
+
parts.push(this.colors ? `${DIM}${scopeTag}${RESET}` : scopeTag);
|
|
57
|
+
}
|
|
58
|
+
// Message
|
|
59
|
+
parts.push(this.colors ? `${color}${entry.message}${RESET}` : entry.message);
|
|
60
|
+
// Context
|
|
61
|
+
if (this.showContext && entry.context && Object.keys(entry.context).length > 0) {
|
|
62
|
+
const ctx = JSON.stringify(entry.context, null, 2)
|
|
63
|
+
.split('\n')
|
|
64
|
+
.map((l, i) => (i === 0 ? l : ` ${l}`))
|
|
65
|
+
.join('\n');
|
|
66
|
+
parts.push(this.colors ? `${DIM}${ctx}${RESET}` : ctx);
|
|
67
|
+
}
|
|
68
|
+
return parts.join(' ');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.PrettyFormatter = PrettyFormatter;
|
|
72
|
+
//# sourceMappingURL=PrettyFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrettyFormatter.js","sourceRoot":"","sources":["../../../src/logger/formatters/PrettyFormatter.ts"],"names":[],"mappings":";;;AAAA,gDAA6C;AAI7C,oBAAoB;AACpB,MAAM,KAAK,GAAI,SAAS,CAAC;AACzB,MAAM,IAAI,GAAK,SAAS,CAAC;AACzB,MAAM,GAAG,GAAM,SAAS,CAAC;AAEzB,MAAM,YAAY,GAA6B;IAC3C,CAAC,mBAAQ,CAAC,KAAK,CAAC,EAAI,UAAU,EAAS,YAAY;IACnD,CAAC,mBAAQ,CAAC,KAAK,CAAC,EAAI,UAAU,EAAS,OAAO;IAC9C,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAK,UAAU,EAAS,OAAO;IAC9C,CAAC,mBAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,EAAS,QAAQ;IAC/C,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAK,UAAU,EAAS,SAAS;IAChD,CAAC,mBAAQ,CAAC,KAAK,CAAC,EAAI,UAAU,EAAS,MAAM;IAC7C,CAAC,mBAAQ,CAAC,KAAK,CAAC,EAAI,UAAU,EAAS,UAAU;CACpD,CAAC;AAEF,MAAM,WAAW,GAA6B;IAC1C,CAAC,mBAAQ,CAAC,KAAK,CAAC,EAAI,GAAG;IACvB,CAAC,mBAAQ,CAAC,KAAK,CAAC,EAAI,GAAG;IACvB,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAK,GAAG;IACvB,CAAC,mBAAQ,CAAC,OAAO,CAAC,EAAE,GAAG;IACvB,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAK,GAAG;IACvB,CA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-0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logger/formatters/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrettyFormatter = exports.JsonFormatter = void 0;
|
|
4
|
+
var JsonFormatter_1 = require("./JsonFormatter");
|
|
5
|
+
Object.defineProperty(exports, "JsonFormatter", { enumerable: true, get: function () { return JsonFormatter_1.JsonFormatter; } });
|
|
6
|
+
var PrettyFormatter_1 = require("./PrettyFormatter");
|
|
7
|
+
Object.defineProperty(exports, "PrettyFormatter", { enumerable: true, get: function () { return PrettyFormatter_1.PrettyFormatter; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logger/formatters/index.ts"],"names":[],"mappings":";;;AACA,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Logger } from './Logger';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export type { LoggerFormatter } from './formatters/LoggerFormatter';
|
|
4
|
+
export { JsonFormatter } from './formatters/JsonFormatter';
|
|
5
|
+
export { PrettyFormatter } from './formatters/PrettyFormatter';
|
|
6
|
+
export type { PrettyFormatterOptions } from './formatters/PrettyFormatter';
|
|
7
|
+
export { LoggerTransport } from './transports/LoggerTransport';
|
|
8
|
+
export type { TransportOptions } from './transports/LoggerTransport';
|
|
9
|
+
export { ConsoleTransport } from './transports/ConsoleTransport';
|
|
10
|
+
export type { ConsoleTransportOptions } from './transports/ConsoleTransport';
|
|
11
|
+
export { FileTransport } from './transports/FileTransport';
|
|
12
|
+
export type { FileTransportOptions } from './transports/FileTransport';
|
|
13
|
+
export { HttpTransport } from './transports/HttpTransport';
|
|
14
|
+
export type { HttpTransportOptions } from './transports/HttpTransport';
|
|
15
|
+
export { DiscordTransport } from './transports/DiscordTransport';
|
|
16
|
+
export type { DiscordTransportOptions } from './transports/DiscordTransport';
|
|
17
|
+
export { BufferedTransport } from './transports/BufferedTransport';
|
|
18
|
+
export type { BufferedTransportOptions } from './transports/BufferedTransport';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,cAAc,SAAS,CAAC;AAGxB,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAG3E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,YAAY,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.BufferedTransport = exports.DiscordTransport = exports.HttpTransport = exports.FileTransport = exports.ConsoleTransport = exports.LoggerTransport = exports.PrettyFormatter = exports.JsonFormatter = exports.Logger = void 0;
|
|
18
|
+
// Core
|
|
19
|
+
var Logger_1 = require("./Logger");
|
|
20
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return Logger_1.Logger; } });
|
|
21
|
+
// Types
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
var JsonFormatter_1 = require("./formatters/JsonFormatter");
|
|
24
|
+
Object.defineProperty(exports, "JsonFormatter", { enumerable: true, get: function () { return JsonFormatter_1.JsonFormatter; } });
|
|
25
|
+
var PrettyFormatter_1 = require("./formatters/PrettyFormatter");
|
|
26
|
+
Object.defineProperty(exports, "PrettyFormatter", { enumerable: true, get: function () { return PrettyFormatter_1.PrettyFormatter; } });
|
|
27
|
+
// Transports
|
|
28
|
+
var LoggerTransport_1 = require("./transports/LoggerTransport");
|
|
29
|
+
Object.defineProperty(exports, "LoggerTransport", { enumerable: true, get: function () { return LoggerTransport_1.LoggerTransport; } });
|
|
30
|
+
var ConsoleTransport_1 = require("./transports/ConsoleTransport");
|
|
31
|
+
Object.defineProperty(exports, "ConsoleTransport", { enumerable: true, get: function () { return ConsoleTransport_1.ConsoleTransport; } });
|
|
32
|
+
var FileTransport_1 = require("./transports/FileTransport");
|
|
33
|
+
Object.defineProperty(exports, "FileTransport", { enumerable: true, get: function () { return FileTransport_1.FileTransport; } });
|
|
34
|
+
var HttpTransport_1 = require("./transports/HttpTransport");
|
|
35
|
+
Object.defineProperty(exports, "HttpTransport", { enumerable: true, get: function () { return HttpTransport_1.HttpTransport; } });
|
|
36
|
+
var DiscordTransport_1 = require("./transports/DiscordTransport");
|
|
37
|
+
Object.defineProperty(exports, "DiscordTransport", { enumerable: true, get: function () { return DiscordTransport_1.DiscordTransport; } });
|
|
38
|
+
var BufferedTransport_1 = require("./transports/BufferedTransport");
|
|
39
|
+
Object.defineProperty(exports, "BufferedTransport", { enumerable: true, get: function () { return BufferedTransport_1.BufferedTransport; } });
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAO;AACP,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,QAAQ;AACR,0CAAwB;AAIxB,4DAA2D;AAAlD,8GAAA,aAAa,OAAA;AACtB,gEAA+D;AAAtD,kHAAA,eAAe,OAAA;AAGxB,aAAa;AACb,gEAA+D;AAAtD,kHAAA,eAAe,OAAA;AAExB,kEAAiE;AAAxD,oHAAA,gBAAgB,OAAA;AAEzB,4DAA2D;AAAlD,8GAAA,aAAa,OAAA;AAEtB,4DAA2D;AAAlD,8GAAA,aAAa,OAAA;AAEtB,kEAAiE;AAAxD,oHAAA,gBAAgB,OAAA;AAEzB,oEAAmE;AAA1D,sHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { LogMessage } from '../types/LogMessage';
|
|
2
|
+
import type { LoggerFormatter } from '../formatters/LoggerFormatter';
|
|
3
|
+
import { LoggerTransport, type TransportOptions } from './LoggerTransport';
|
|
4
|
+
export interface BufferedTransportOptions<TFormatter extends LoggerFormatter = LoggerFormatter<string>> extends TransportOptions<TFormatter> {
|
|
5
|
+
/**
|
|
6
|
+
* The target transport where buffered messages will be forwarded.
|
|
7
|
+
*/
|
|
8
|
+
transport: LoggerTransport;
|
|
9
|
+
/**
|
|
10
|
+
* Maximum number of log entries to buffer in memory before flushing immediately.
|
|
11
|
+
* @default 50
|
|
12
|
+
*/
|
|
13
|
+
bufferSize?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Flush interval in milliseconds.
|
|
16
|
+
* @default 1000
|
|
17
|
+
*/
|
|
18
|
+
flushIntervalMs?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum buffer capacity. If this threshold is reached, oldest entries are dropped
|
|
21
|
+
* to protect against memory exhaustion.
|
|
22
|
+
* @default 5000
|
|
23
|
+
*/
|
|
24
|
+
maxQueueSize?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* An asynchronous, buffered transport decorator that queues log entries in memory
|
|
28
|
+
* and flushes them in batches or at fixed time intervals to an underlying transport.
|
|
29
|
+
*
|
|
30
|
+
* Automatically flushes upon process exit to prevent lost messages.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const fileTransport = new FileTransport({ filePath: './app.log' });
|
|
35
|
+
* const bufferedTransport = new BufferedTransport({
|
|
36
|
+
* transport: fileTransport,
|
|
37
|
+
* bufferSize: 100,
|
|
38
|
+
* flushIntervalMs: 2000,
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* logger.use(bufferedTransport);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare class BufferedTransport extends LoggerTransport<LoggerFormatter<string>> {
|
|
45
|
+
private readonly targetTransport;
|
|
46
|
+
private readonly bufferSize;
|
|
47
|
+
private readonly flushIntervalMs;
|
|
48
|
+
private readonly maxQueueSize;
|
|
49
|
+
private queue;
|
|
50
|
+
private flushTimer?;
|
|
51
|
+
private isFlushing;
|
|
52
|
+
private isClosed;
|
|
53
|
+
constructor(options: BufferedTransportOptions);
|
|
54
|
+
accepts(entry: LogMessage): boolean;
|
|
55
|
+
send(entry: LogMessage): void;
|
|
56
|
+
/**
|
|
57
|
+
* Immediately flushes all buffered messages to the target transport.
|
|
58
|
+
*/
|
|
59
|
+
flush(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Closes the transport, flushes pending logs, and clears timers.
|
|
62
|
+
*/
|
|
63
|
+
close(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the current number of queued entries.
|
|
66
|
+
*/
|
|
67
|
+
get queueLength(): number;
|
|
68
|
+
private startTimer;
|
|
69
|
+
private registerExitHook;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=BufferedTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferedTransport.d.ts","sourceRoot":"","sources":["../../../src/logger/transports/BufferedTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,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", { value: true });
|
|
3
|
+
exports.BufferedTransport = void 0;
|
|
4
|
+
const LoggerTransport_1 = require("./LoggerTransport");
|
|
5
|
+
/**
|
|
6
|
+
* An asynchronous, buffered transport decorator that queues log entries in memory
|
|
7
|
+
* and flushes them in batches or at fixed time intervals to an underlying transport.
|
|
8
|
+
*
|
|
9
|
+
* Automatically flushes upon process exit to prevent lost messages.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const fileTransport = new FileTransport({ filePath: './app.log' });
|
|
14
|
+
* const bufferedTransport = new BufferedTransport({
|
|
15
|
+
* transport: fileTransport,
|
|
16
|
+
* bufferSize: 100,
|
|
17
|
+
* flushIntervalMs: 2000,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* logger.use(bufferedTransport);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class BufferedTransport extends LoggerTransport_1.LoggerTransport {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
super(options);
|
|
26
|
+
this.queue = [];
|
|
27
|
+
this.isFlushing = false;
|
|
28
|
+
this.isClosed = false;
|
|
29
|
+
this.targetTransport = options.transport;
|
|
30
|
+
this.bufferSize = options.bufferSize ?? 50;
|
|
31
|
+
this.flushIntervalMs = options.flushIntervalMs ?? 1000;
|
|
32
|
+
this.maxQueueSize = options.maxQueueSize ?? 5000;
|
|
33
|
+
this.startTimer();
|
|
34
|
+
this.registerExitHook();
|
|
35
|
+
}
|
|
36
|
+
accepts(entry) {
|
|
37
|
+
// Must pass both this transport's level filter and target's filter
|
|
38
|
+
return super.accepts(entry) && this.targetTransport.accepts(entry);
|
|
39
|
+
}
|
|
40
|
+
send(entry) {
|
|
41
|
+
if (this.isClosed)
|
|
42
|
+
return;
|
|
43
|
+
if (this.queue.length >= this.maxQueueSize) {
|
|
44
|
+
// Drop oldest message to preserve bounded memory footprint
|
|
45
|
+
this.queue.shift();
|
|
46
|
+
}
|
|
47
|
+
this.queue.push(entry);
|
|
48
|
+
if (this.queue.length >= this.bufferSize) {
|
|
49
|
+
void this.flush();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Immediately flushes all buffered messages to the target transport.
|
|
54
|
+
*/
|
|
55
|
+
async flush() {
|
|
56
|
+
if (this.isFlushing || this.queue.length === 0)
|
|
57
|
+
return;
|
|
58
|
+
this.isFlushing = true;
|
|
59
|
+
const batch = this.queue;
|
|
60
|
+
this.queue = [];
|
|
61
|
+
try {
|
|
62
|
+
for (const entry of batch) {
|
|
63
|
+
const res = this.targetTransport.send(entry);
|
|
64
|
+
if (res instanceof Promise) {
|
|
65
|
+
await res;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
console.error('[BufferedTransport] Error flushing batch:', err);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
this.isFlushing = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Closes the transport, flushes pending logs, and clears timers.
|
|
78
|
+
*/
|
|
79
|
+
async close() {
|
|
80
|
+
this.isClosed = true;
|
|
81
|
+
if (this.flushTimer) {
|
|
82
|
+
clearInterval(this.flushTimer);
|
|
83
|
+
this.flushTimer = undefined;
|
|
84
|
+
}
|
|
85
|
+
await this.flush();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the current number of queued entries.
|
|
89
|
+
*/
|
|
90
|
+
get queueLength() {
|
|
91
|
+
return this.queue.length;
|
|
92
|
+
}
|
|
93
|
+
startTimer() {
|
|
94
|
+
this.flushTimer = setInterval(() => {
|
|
95
|
+
void this.flush();
|
|
96
|
+
}, this.flushIntervalMs);
|
|
97
|
+
// Don't keep the event loop alive solely because of the flush timer
|
|
98
|
+
if (typeof this.flushTimer.unref === 'function') {
|
|
99
|
+
this.flushTimer.unref();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
registerExitHook() {
|
|
103
|
+
if (typeof process !== 'undefined' && typeof process.once === 'function') {
|
|
104
|
+
process.once('beforeExit', () => {
|
|
105
|
+
void this.flush();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.BufferedTransport = BufferedTransport;
|
|
111
|
+
//# sourceMappingURL=BufferedTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferedTransport.js","sourceRoot":"","sources":["../../../src/logger/transports/BufferedTransport.ts"],"names":[],"mappings":";;;AAEA,uDAA2E;AA8B3E;;;;;;;;;;;;;;;;;GAiBG;AACH,uBAA+B,SAAQ,iCAAwC;IAW3E,YAAY,OAAiC;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QANX,UAAK,GAAiB,EAAE,CAAC;QAEzB,eAAU,GAAG,KAAK,CAAC;QACnB,aAAQ,GAAG,KAAK,CAAC;QAIrB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;QAC3C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAK,CAAC;QACxD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAK,CAAC;QAElD,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC5B,CAAC;IAEQ,OAAO,CAAC,KAAiB;QAC9B,mEAAmE;QACnE,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,CAAC,KAAiB;QAClB,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAE1B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACzC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CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;IAEO,UAAU;QACd,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;YAC/B,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAEzB,oEAAoE;QACpE,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YAC9C,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC;IAEO,gBAAgB;QACpB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACvE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;gBAC5B,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LogMessage } from '../types/LogMessage';
|
|
2
|
+
import type { LoggerFormatter } from '../formatters/LoggerFormatter';
|
|
3
|
+
import { LoggerTransport, type TransportOptions } from './LoggerTransport';
|
|
4
|
+
export interface ConsoleTransportOptions extends TransportOptions<LoggerFormatter<string>> {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Writes log entries to `process.stdout` / `process.stderr`.
|
|
8
|
+
*
|
|
9
|
+
* - TRACE / DEBUG / INFO / SUCCESS / WARN → `console.log`
|
|
10
|
+
* - ERROR / FATAL → `console.error`
|
|
11
|
+
*
|
|
12
|
+
* Uses {@link PrettyFormatter} by default.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* logger.use(new ConsoleTransport());
|
|
17
|
+
* logger.use(new ConsoleTransport({ level: LogLevel.WARN }));
|
|
18
|
+
* logger.use(new ConsoleTransport({ formatter: new JsonFormatter() }));
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConsoleTransport extends LoggerTransport<LoggerFormatter<string>> {
|
|
22
|
+
private readonly defaultFormatter;
|
|
23
|
+
constructor(options?: ConsoleTransportOptions);
|
|
24
|
+
send(entry: LogMessage): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ConsoleTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleTransport.d.ts","sourceRoot":"","sources":["../../../src/logger/transports/ConsoleTransport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;CAAG;AAE7F;;;;;;;;;;;;;;GAcG;AACH,qBAAa,gBAAiB,SAAQ,eAAe,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1E,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0B;IAE3D,YAAY,OAAO,GAAE,uBAA4B,EAGhD;IAED,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAS5B;CACJ"}
|