@rawnodes/logger 2.8.0 → 2.10.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.
@@ -0,0 +1,280 @@
1
+ interface MaskSecretsOptions {
2
+ patterns?: string[];
3
+ mask?: string;
4
+ deep?: boolean;
5
+ }
6
+ declare function maskSecrets(obj: unknown, options?: MaskSecretsOptions): unknown;
7
+ declare function createMasker(options?: MaskSecretsOptions): (obj: unknown) => unknown;
8
+ type MaskReplacer = (this: unknown, key: string, value: unknown) => unknown;
9
+ /**
10
+ * Returns a `JSON.stringify` replacer that masks secret-named keys and URL
11
+ * credentials in-place during serialization. Unlike `maskSecrets`/`createMasker`
12
+ * it allocates no intermediate object — the recursion is driven by `JSON.stringify`.
13
+ *
14
+ * Use it as `JSON.stringify(value, maskReplacer())` or
15
+ * `JSON.stringify(value, maskReplacer(), 2)`.
16
+ */
17
+ declare function maskReplacer(options?: MaskSecretsOptions): MaskReplacer;
18
+
19
+ declare const LOG_LEVELS: {
20
+ readonly off: -1;
21
+ readonly error: 0;
22
+ readonly warn: 1;
23
+ readonly info: 2;
24
+ readonly http: 3;
25
+ readonly verbose: 4;
26
+ readonly debug: 5;
27
+ readonly silly: 6;
28
+ };
29
+ type LogLevel = keyof typeof LOG_LEVELS;
30
+ declare function isValidLogLevel(level: string): level is LogLevel;
31
+ declare function assertLogLevel(level: string): asserts level is LogLevel;
32
+ type LogFormat = 'json' | 'plain' | 'logfmt' | 'simple';
33
+ interface LevelRule {
34
+ match: Record<string, unknown> & {
35
+ context?: string;
36
+ };
37
+ level: LogLevel;
38
+ }
39
+ /**
40
+ * Controls whether a transport respects runtime level overrides registered via
41
+ * `setLevelOverride(...)` (or the top-level `level.rules` in the logger config).
42
+ *
43
+ * When `true` (the default for observability transports — console/file/cloudwatch/relay):
44
+ * a matching override bypasses the transport's own `level`/`rules` so that
45
+ * targeted troubleshooting actually surfaces logs in the viewing channels.
46
+ *
47
+ * When `false` (the default for alert-style transports — discord/telegram/zohoCliq):
48
+ * the transport filters strictly by its own `level`/`rules` and ignores runtime
49
+ * overrides, which prevents ad-hoc debug overrides from flooding user-facing
50
+ * notification channels.
51
+ *
52
+ * Every transport config accepts this flag; the only time it needs to be set
53
+ * explicitly is when overriding the default for the transport kind.
54
+ */
55
+ type RespectRuntimeOverrides = boolean;
56
+ interface ConsoleConfig {
57
+ format: LogFormat;
58
+ level?: LogLevel;
59
+ rules?: LevelRule[];
60
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
61
+ }
62
+ interface FileConfig {
63
+ format: LogFormat;
64
+ level?: LogLevel;
65
+ rules?: LevelRule[];
66
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
67
+ dirname: string;
68
+ filename: string;
69
+ datePattern?: string;
70
+ interval?: string;
71
+ zippedArchive?: boolean;
72
+ maxSize?: string;
73
+ maxFiles?: string;
74
+ }
75
+ interface HttpTransportBaseConfig {
76
+ level?: LogLevel;
77
+ rules?: LevelRule[];
78
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
79
+ batchSize?: number;
80
+ flushInterval?: number;
81
+ maxRetries?: number;
82
+ retryDelay?: number;
83
+ /**
84
+ * Maximum number of messages the in-memory queue will hold before dropping.
85
+ * Provides a hard upper bound on memory usage when a transport is degraded
86
+ * or offline — without this, a failing transport + steady log volume grows
87
+ * the queue until OOM. Default: unbounded.
88
+ *
89
+ * Recommended for production: `10_000` — enough to absorb transient blips,
90
+ * small enough to avoid runaway memory.
91
+ */
92
+ maxQueueSize?: number;
93
+ /**
94
+ * Policy applied when the queue is full.
95
+ * - `'drop-oldest'` (default): prefers keeping recent events — during an
96
+ * outage old logs are usually stale.
97
+ * - `'drop-newest'`: prefers preserving historical context — useful if you
98
+ * care more about the events leading up to the outage than the noise
99
+ * happening during it.
100
+ */
101
+ dropPolicy?: 'drop-oldest' | 'drop-newest';
102
+ /**
103
+ * Called when messages are dropped due to queue overflow. Receives only the
104
+ * messages that were discarded. If not provided, drops are silent.
105
+ *
106
+ * Callback MUST NOT throw; if it does, the exception is swallowed.
107
+ */
108
+ onDrop?: (droppedMessages: unknown[]) => void;
109
+ /**
110
+ * Called when a batch fails after all retries and messages are dropped.
111
+ * If not provided, the error is logged to stderr.
112
+ *
113
+ * The callback MUST NOT throw; if it does, the failure is swallowed and a
114
+ * stderr fallback is used. This is intentional — a logger must never
115
+ * propagate its own transport errors back into the host application.
116
+ */
117
+ onError?: (error: Error, droppedMessages: unknown[]) => void;
118
+ /**
119
+ * Timeout in milliseconds for a single outbound HTTP request. Default:
120
+ * `10_000`. Applies to Discord/Telegram `fetch`. CloudWatch uses the AWS
121
+ * SDK's own timeout configuration.
122
+ */
123
+ requestTimeout?: number;
124
+ }
125
+ interface DiscordConfig extends HttpTransportBaseConfig {
126
+ webhookUrl: string;
127
+ format?: 'embed' | 'markdown';
128
+ username?: string;
129
+ avatarUrl?: string;
130
+ embedColors?: Partial<Record<LogLevel, number>>;
131
+ includeTimestamp?: boolean;
132
+ includeMeta?: boolean;
133
+ maxEmbedFields?: number;
134
+ }
135
+ interface TelegramConfig extends HttpTransportBaseConfig {
136
+ botToken: string;
137
+ chatId: string | number;
138
+ parseMode?: 'Markdown' | 'MarkdownV2' | 'HTML';
139
+ disableNotification?: boolean;
140
+ threadId?: number;
141
+ replyToMessageId?: number;
142
+ }
143
+ interface ZohoCliqBotConfig {
144
+ /** Bot display name (shown in the channel). */
145
+ name: string;
146
+ /** Optional bot avatar URL. */
147
+ image?: string;
148
+ }
149
+ interface ZohoCliqConfig extends HttpTransportBaseConfig {
150
+ /**
151
+ * Incoming webhook URL. If provided, `companyId`/`channel`/`region` are
152
+ * ignored and this URL is used as-is (with `zapikey` appended as query).
153
+ */
154
+ webhookUrl?: string;
155
+ /** Zoho Cliq company/org ID. Required unless `webhookUrl` is set. */
156
+ companyId?: string;
157
+ /** Target channel name (the `channelsbyname` API segment). Required unless `webhookUrl` is set. */
158
+ channel?: string;
159
+ /** Zoho region/TLD: 'eu' | 'com' | 'in' | etc. Default: 'eu'. */
160
+ region?: string;
161
+ /** Zoho API key (zapikey). Required. */
162
+ apiKey: string;
163
+ /** If true (default), message is posted as a broadcast so all members are notified. */
164
+ broadcast?: boolean;
165
+ /** Post as a custom bot instead of the default user. */
166
+ bot?: ZohoCliqBotConfig;
167
+ /** Include ISO timestamp in each formatted message. Default: true. */
168
+ includeTimestamp?: boolean;
169
+ /** Include meta as a fenced code block. Default: true. */
170
+ includeMeta?: boolean;
171
+ }
172
+ type LogStreamPattern = 'hostname' | 'hostname-date' | 'hostname-uuid' | 'date' | 'uuid';
173
+ interface LogStreamPatternConfig {
174
+ pattern: LogStreamPattern;
175
+ }
176
+ interface LogStreamTemplateConfig {
177
+ /** Custom template with variables: {hostname}, {date}, {datetime}, {uuid}, {pid}, {env} */
178
+ template: string;
179
+ }
180
+ type LogStreamName = string | LogStreamPatternConfig | LogStreamTemplateConfig;
181
+ interface RelayConfig {
182
+ /** URL of the relay API (e.g., https://relay.example.com) */
183
+ apiUrl: string;
184
+ /** Authentication token for the relay server */
185
+ token: string;
186
+ /** Polling interval in ms (default: 30000) */
187
+ pollInterval?: number;
188
+ /** Ring buffer capacity - max logs held during reconnect (default: 1000) */
189
+ bufferSize?: number;
190
+ /** WebSocket reconnect base delay in ms (default: 1000) */
191
+ reconnectDelay?: number;
192
+ /** Max reconnect delay in ms (default: 30000) */
193
+ maxReconnectDelay?: number;
194
+ /** See RespectRuntimeOverrides. Default: true (relay is an observability transport). */
195
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
196
+ /**
197
+ * Extra hostnames the server is allowed to direct WS streams to. By default
198
+ * the relay only connects to a `wsUrl` whose origin matches `apiUrl` — this
199
+ * prevents a compromised config endpoint from redirecting your logs to an
200
+ * attacker-controlled host. Use this only when your relay backend lives on
201
+ * a different host than its WebSocket gateway, and list those hosts here
202
+ * explicitly.
203
+ */
204
+ allowedWsHosts?: string[];
205
+ /**
206
+ * Auto-mask secrets in lines forwarded over WebSocket. The relay runs in a
207
+ * worker thread and does NOT inherit the parent logger's `maskSecrets`
208
+ * setting automatically — pass it here too if you want forwarded logs
209
+ * masked. Off by default.
210
+ */
211
+ maskSecrets?: boolean | MaskSecretsOptions;
212
+ }
213
+ interface CloudWatchConfig extends HttpTransportBaseConfig {
214
+ logGroupName: string;
215
+ /** Log stream name - string, pattern config, or template config. Defaults to hostname pattern */
216
+ logStreamName?: LogStreamName;
217
+ region: string;
218
+ accessKeyId: string;
219
+ secretAccessKey: string;
220
+ createLogGroup?: boolean;
221
+ createLogStream?: boolean;
222
+ }
223
+ interface LevelConfigObject {
224
+ default: LogLevel;
225
+ rules?: LevelRule[];
226
+ }
227
+ type LevelConfig = LogLevel | LevelConfigObject;
228
+ interface CallerConfig {
229
+ /** Stack depth to capture (default: 1). Higher values trace further up the call stack */
230
+ depth?: number;
231
+ /** Include full file path (default: false). If false, shows relative or basename only */
232
+ fullPath?: boolean;
233
+ }
234
+ interface CallerInfo {
235
+ file: string;
236
+ line: number;
237
+ column?: number;
238
+ function?: string;
239
+ }
240
+ interface AutoShutdownConfig {
241
+ /** Timeout in ms before forcing exit (default: 5000) */
242
+ timeout?: number;
243
+ /** Custom signals to handle (default: ['SIGTERM', 'SIGINT']) */
244
+ signals?: NodeJS.Signals[];
245
+ }
246
+ interface LoggerConfig {
247
+ level: LevelConfig;
248
+ console: ConsoleConfig;
249
+ file?: FileConfig;
250
+ discord?: DiscordConfig | DiscordConfig[];
251
+ telegram?: TelegramConfig | TelegramConfig[];
252
+ cloudwatch?: CloudWatchConfig | CloudWatchConfig[];
253
+ zohoCliq?: ZohoCliqConfig | ZohoCliqConfig[];
254
+ /** Relay transport config — streams logs to a remote server via WebSocket (runs in worker thread) */
255
+ relay?: RelayConfig;
256
+ /** Enable caller info (file:line) in logs. Pass true for defaults or CallerConfig for options */
257
+ caller?: boolean | CallerConfig;
258
+ /** Hostname to include in all log entries. Defaults to os.hostname() if not specified */
259
+ hostname?: string;
260
+ /** Auto-register graceful shutdown handlers. Pass true for defaults or config object */
261
+ autoShutdown?: boolean | AutoShutdownConfig;
262
+ /**
263
+ * Auto-mask secrets (password/token/auth/etc. by default) in all formatted
264
+ * output and HTTP transport payloads. Pass `true` to enable with defaults or
265
+ * a `MaskSecretsOptions` object to customize patterns/mask string.
266
+ */
267
+ maskSecrets?: boolean | MaskSecretsOptions;
268
+ }
269
+ type LoggerContext = Record<string, unknown>;
270
+ type LevelOverrideMatch<TContext extends LoggerContext> = Partial<TContext> & {
271
+ context?: string;
272
+ };
273
+ interface LevelOverride<TContext extends LoggerContext> {
274
+ match: LevelOverrideMatch<TContext>;
275
+ level: LogLevel;
276
+ readonly?: boolean;
277
+ }
278
+ type Meta = object | (() => object);
279
+
280
+ export { type AutoShutdownConfig as A, type CloudWatchConfig as C, type DiscordConfig as D, type FileConfig as F, type HttpTransportBaseConfig as H, type LoggerContext as L, type Meta as M, type RelayConfig as R, type TelegramConfig as T, type ZohoCliqConfig as Z, type LoggerConfig as a, type LevelOverrideMatch as b, type LogLevel as c, type LevelOverride as d, type MaskReplacer as e, type CallerConfig as f, type CallerInfo as g, type LogFormat as h, type LevelRule as i, type ConsoleConfig as j, type LevelConfigObject as k, type LevelConfig as l, type LogStreamPattern as m, type LogStreamPatternConfig as n, type LogStreamTemplateConfig as o, type LogStreamName as p, LOG_LEVELS as q, isValidLogLevel as r, assertLogLevel as s, type ZohoCliqBotConfig as t, maskSecrets as u, createMasker as v, maskReplacer as w, type MaskSecretsOptions as x };
@@ -0,0 +1,280 @@
1
+ interface MaskSecretsOptions {
2
+ patterns?: string[];
3
+ mask?: string;
4
+ deep?: boolean;
5
+ }
6
+ declare function maskSecrets(obj: unknown, options?: MaskSecretsOptions): unknown;
7
+ declare function createMasker(options?: MaskSecretsOptions): (obj: unknown) => unknown;
8
+ type MaskReplacer = (this: unknown, key: string, value: unknown) => unknown;
9
+ /**
10
+ * Returns a `JSON.stringify` replacer that masks secret-named keys and URL
11
+ * credentials in-place during serialization. Unlike `maskSecrets`/`createMasker`
12
+ * it allocates no intermediate object — the recursion is driven by `JSON.stringify`.
13
+ *
14
+ * Use it as `JSON.stringify(value, maskReplacer())` or
15
+ * `JSON.stringify(value, maskReplacer(), 2)`.
16
+ */
17
+ declare function maskReplacer(options?: MaskSecretsOptions): MaskReplacer;
18
+
19
+ declare const LOG_LEVELS: {
20
+ readonly off: -1;
21
+ readonly error: 0;
22
+ readonly warn: 1;
23
+ readonly info: 2;
24
+ readonly http: 3;
25
+ readonly verbose: 4;
26
+ readonly debug: 5;
27
+ readonly silly: 6;
28
+ };
29
+ type LogLevel = keyof typeof LOG_LEVELS;
30
+ declare function isValidLogLevel(level: string): level is LogLevel;
31
+ declare function assertLogLevel(level: string): asserts level is LogLevel;
32
+ type LogFormat = 'json' | 'plain' | 'logfmt' | 'simple';
33
+ interface LevelRule {
34
+ match: Record<string, unknown> & {
35
+ context?: string;
36
+ };
37
+ level: LogLevel;
38
+ }
39
+ /**
40
+ * Controls whether a transport respects runtime level overrides registered via
41
+ * `setLevelOverride(...)` (or the top-level `level.rules` in the logger config).
42
+ *
43
+ * When `true` (the default for observability transports — console/file/cloudwatch/relay):
44
+ * a matching override bypasses the transport's own `level`/`rules` so that
45
+ * targeted troubleshooting actually surfaces logs in the viewing channels.
46
+ *
47
+ * When `false` (the default for alert-style transports — discord/telegram/zohoCliq):
48
+ * the transport filters strictly by its own `level`/`rules` and ignores runtime
49
+ * overrides, which prevents ad-hoc debug overrides from flooding user-facing
50
+ * notification channels.
51
+ *
52
+ * Every transport config accepts this flag; the only time it needs to be set
53
+ * explicitly is when overriding the default for the transport kind.
54
+ */
55
+ type RespectRuntimeOverrides = boolean;
56
+ interface ConsoleConfig {
57
+ format: LogFormat;
58
+ level?: LogLevel;
59
+ rules?: LevelRule[];
60
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
61
+ }
62
+ interface FileConfig {
63
+ format: LogFormat;
64
+ level?: LogLevel;
65
+ rules?: LevelRule[];
66
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
67
+ dirname: string;
68
+ filename: string;
69
+ datePattern?: string;
70
+ interval?: string;
71
+ zippedArchive?: boolean;
72
+ maxSize?: string;
73
+ maxFiles?: string;
74
+ }
75
+ interface HttpTransportBaseConfig {
76
+ level?: LogLevel;
77
+ rules?: LevelRule[];
78
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
79
+ batchSize?: number;
80
+ flushInterval?: number;
81
+ maxRetries?: number;
82
+ retryDelay?: number;
83
+ /**
84
+ * Maximum number of messages the in-memory queue will hold before dropping.
85
+ * Provides a hard upper bound on memory usage when a transport is degraded
86
+ * or offline — without this, a failing transport + steady log volume grows
87
+ * the queue until OOM. Default: unbounded.
88
+ *
89
+ * Recommended for production: `10_000` — enough to absorb transient blips,
90
+ * small enough to avoid runaway memory.
91
+ */
92
+ maxQueueSize?: number;
93
+ /**
94
+ * Policy applied when the queue is full.
95
+ * - `'drop-oldest'` (default): prefers keeping recent events — during an
96
+ * outage old logs are usually stale.
97
+ * - `'drop-newest'`: prefers preserving historical context — useful if you
98
+ * care more about the events leading up to the outage than the noise
99
+ * happening during it.
100
+ */
101
+ dropPolicy?: 'drop-oldest' | 'drop-newest';
102
+ /**
103
+ * Called when messages are dropped due to queue overflow. Receives only the
104
+ * messages that were discarded. If not provided, drops are silent.
105
+ *
106
+ * Callback MUST NOT throw; if it does, the exception is swallowed.
107
+ */
108
+ onDrop?: (droppedMessages: unknown[]) => void;
109
+ /**
110
+ * Called when a batch fails after all retries and messages are dropped.
111
+ * If not provided, the error is logged to stderr.
112
+ *
113
+ * The callback MUST NOT throw; if it does, the failure is swallowed and a
114
+ * stderr fallback is used. This is intentional — a logger must never
115
+ * propagate its own transport errors back into the host application.
116
+ */
117
+ onError?: (error: Error, droppedMessages: unknown[]) => void;
118
+ /**
119
+ * Timeout in milliseconds for a single outbound HTTP request. Default:
120
+ * `10_000`. Applies to Discord/Telegram `fetch`. CloudWatch uses the AWS
121
+ * SDK's own timeout configuration.
122
+ */
123
+ requestTimeout?: number;
124
+ }
125
+ interface DiscordConfig extends HttpTransportBaseConfig {
126
+ webhookUrl: string;
127
+ format?: 'embed' | 'markdown';
128
+ username?: string;
129
+ avatarUrl?: string;
130
+ embedColors?: Partial<Record<LogLevel, number>>;
131
+ includeTimestamp?: boolean;
132
+ includeMeta?: boolean;
133
+ maxEmbedFields?: number;
134
+ }
135
+ interface TelegramConfig extends HttpTransportBaseConfig {
136
+ botToken: string;
137
+ chatId: string | number;
138
+ parseMode?: 'Markdown' | 'MarkdownV2' | 'HTML';
139
+ disableNotification?: boolean;
140
+ threadId?: number;
141
+ replyToMessageId?: number;
142
+ }
143
+ interface ZohoCliqBotConfig {
144
+ /** Bot display name (shown in the channel). */
145
+ name: string;
146
+ /** Optional bot avatar URL. */
147
+ image?: string;
148
+ }
149
+ interface ZohoCliqConfig extends HttpTransportBaseConfig {
150
+ /**
151
+ * Incoming webhook URL. If provided, `companyId`/`channel`/`region` are
152
+ * ignored and this URL is used as-is (with `zapikey` appended as query).
153
+ */
154
+ webhookUrl?: string;
155
+ /** Zoho Cliq company/org ID. Required unless `webhookUrl` is set. */
156
+ companyId?: string;
157
+ /** Target channel name (the `channelsbyname` API segment). Required unless `webhookUrl` is set. */
158
+ channel?: string;
159
+ /** Zoho region/TLD: 'eu' | 'com' | 'in' | etc. Default: 'eu'. */
160
+ region?: string;
161
+ /** Zoho API key (zapikey). Required. */
162
+ apiKey: string;
163
+ /** If true (default), message is posted as a broadcast so all members are notified. */
164
+ broadcast?: boolean;
165
+ /** Post as a custom bot instead of the default user. */
166
+ bot?: ZohoCliqBotConfig;
167
+ /** Include ISO timestamp in each formatted message. Default: true. */
168
+ includeTimestamp?: boolean;
169
+ /** Include meta as a fenced code block. Default: true. */
170
+ includeMeta?: boolean;
171
+ }
172
+ type LogStreamPattern = 'hostname' | 'hostname-date' | 'hostname-uuid' | 'date' | 'uuid';
173
+ interface LogStreamPatternConfig {
174
+ pattern: LogStreamPattern;
175
+ }
176
+ interface LogStreamTemplateConfig {
177
+ /** Custom template with variables: {hostname}, {date}, {datetime}, {uuid}, {pid}, {env} */
178
+ template: string;
179
+ }
180
+ type LogStreamName = string | LogStreamPatternConfig | LogStreamTemplateConfig;
181
+ interface RelayConfig {
182
+ /** URL of the relay API (e.g., https://relay.example.com) */
183
+ apiUrl: string;
184
+ /** Authentication token for the relay server */
185
+ token: string;
186
+ /** Polling interval in ms (default: 30000) */
187
+ pollInterval?: number;
188
+ /** Ring buffer capacity - max logs held during reconnect (default: 1000) */
189
+ bufferSize?: number;
190
+ /** WebSocket reconnect base delay in ms (default: 1000) */
191
+ reconnectDelay?: number;
192
+ /** Max reconnect delay in ms (default: 30000) */
193
+ maxReconnectDelay?: number;
194
+ /** See RespectRuntimeOverrides. Default: true (relay is an observability transport). */
195
+ respectRuntimeOverrides?: RespectRuntimeOverrides;
196
+ /**
197
+ * Extra hostnames the server is allowed to direct WS streams to. By default
198
+ * the relay only connects to a `wsUrl` whose origin matches `apiUrl` — this
199
+ * prevents a compromised config endpoint from redirecting your logs to an
200
+ * attacker-controlled host. Use this only when your relay backend lives on
201
+ * a different host than its WebSocket gateway, and list those hosts here
202
+ * explicitly.
203
+ */
204
+ allowedWsHosts?: string[];
205
+ /**
206
+ * Auto-mask secrets in lines forwarded over WebSocket. The relay runs in a
207
+ * worker thread and does NOT inherit the parent logger's `maskSecrets`
208
+ * setting automatically — pass it here too if you want forwarded logs
209
+ * masked. Off by default.
210
+ */
211
+ maskSecrets?: boolean | MaskSecretsOptions;
212
+ }
213
+ interface CloudWatchConfig extends HttpTransportBaseConfig {
214
+ logGroupName: string;
215
+ /** Log stream name - string, pattern config, or template config. Defaults to hostname pattern */
216
+ logStreamName?: LogStreamName;
217
+ region: string;
218
+ accessKeyId: string;
219
+ secretAccessKey: string;
220
+ createLogGroup?: boolean;
221
+ createLogStream?: boolean;
222
+ }
223
+ interface LevelConfigObject {
224
+ default: LogLevel;
225
+ rules?: LevelRule[];
226
+ }
227
+ type LevelConfig = LogLevel | LevelConfigObject;
228
+ interface CallerConfig {
229
+ /** Stack depth to capture (default: 1). Higher values trace further up the call stack */
230
+ depth?: number;
231
+ /** Include full file path (default: false). If false, shows relative or basename only */
232
+ fullPath?: boolean;
233
+ }
234
+ interface CallerInfo {
235
+ file: string;
236
+ line: number;
237
+ column?: number;
238
+ function?: string;
239
+ }
240
+ interface AutoShutdownConfig {
241
+ /** Timeout in ms before forcing exit (default: 5000) */
242
+ timeout?: number;
243
+ /** Custom signals to handle (default: ['SIGTERM', 'SIGINT']) */
244
+ signals?: NodeJS.Signals[];
245
+ }
246
+ interface LoggerConfig {
247
+ level: LevelConfig;
248
+ console: ConsoleConfig;
249
+ file?: FileConfig;
250
+ discord?: DiscordConfig | DiscordConfig[];
251
+ telegram?: TelegramConfig | TelegramConfig[];
252
+ cloudwatch?: CloudWatchConfig | CloudWatchConfig[];
253
+ zohoCliq?: ZohoCliqConfig | ZohoCliqConfig[];
254
+ /** Relay transport config — streams logs to a remote server via WebSocket (runs in worker thread) */
255
+ relay?: RelayConfig;
256
+ /** Enable caller info (file:line) in logs. Pass true for defaults or CallerConfig for options */
257
+ caller?: boolean | CallerConfig;
258
+ /** Hostname to include in all log entries. Defaults to os.hostname() if not specified */
259
+ hostname?: string;
260
+ /** Auto-register graceful shutdown handlers. Pass true for defaults or config object */
261
+ autoShutdown?: boolean | AutoShutdownConfig;
262
+ /**
263
+ * Auto-mask secrets (password/token/auth/etc. by default) in all formatted
264
+ * output and HTTP transport payloads. Pass `true` to enable with defaults or
265
+ * a `MaskSecretsOptions` object to customize patterns/mask string.
266
+ */
267
+ maskSecrets?: boolean | MaskSecretsOptions;
268
+ }
269
+ type LoggerContext = Record<string, unknown>;
270
+ type LevelOverrideMatch<TContext extends LoggerContext> = Partial<TContext> & {
271
+ context?: string;
272
+ };
273
+ interface LevelOverride<TContext extends LoggerContext> {
274
+ match: LevelOverrideMatch<TContext>;
275
+ level: LogLevel;
276
+ readonly?: boolean;
277
+ }
278
+ type Meta = object | (() => object);
279
+
280
+ export { type AutoShutdownConfig as A, type CloudWatchConfig as C, type DiscordConfig as D, type FileConfig as F, type HttpTransportBaseConfig as H, type LoggerContext as L, type Meta as M, type RelayConfig as R, type TelegramConfig as T, type ZohoCliqConfig as Z, type LoggerConfig as a, type LevelOverrideMatch as b, type LogLevel as c, type LevelOverride as d, type MaskReplacer as e, type CallerConfig as f, type CallerInfo as g, type LogFormat as h, type LevelRule as i, type ConsoleConfig as j, type LevelConfigObject as k, type LevelConfig as l, type LogStreamPattern as m, type LogStreamPatternConfig as n, type LogStreamTemplateConfig as o, type LogStreamName as p, LOG_LEVELS as q, isValidLogLevel as r, assertLogLevel as s, type ZohoCliqBotConfig as t, maskSecrets as u, createMasker as v, maskReplacer as w, type MaskSecretsOptions as x };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rawnodes/logger",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "High-performance Pino-based logger with AsyncLocalStorage context, O(1) level rules, and timing utilities",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -15,6 +15,16 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.js"
17
17
  }
18
+ },
19
+ "./relay": {
20
+ "import": {
21
+ "types": "./dist/transports/relay.d.mts",
22
+ "default": "./dist/transports/relay.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./dist/transports/relay.d.ts",
26
+ "default": "./dist/transports/relay.js"
27
+ }
18
28
  }
19
29
  },
20
30
  "files": [
@@ -29,7 +39,7 @@
29
39
  "test:watch": "vitest",
30
40
  "test:coverage": "vitest run --coverage",
31
41
  "bench": "vitest bench",
32
- "bench:measure": "tsx bench/measure.ts",
42
+ "bench:measure": "node --expose-gc --import tsx bench/measure.ts",
33
43
  "lint": "eslint src --ext .ts",
34
44
  "prepublishOnly": "pnpm build"
35
45
  },
@@ -60,24 +70,30 @@
60
70
  "zod": "^4.2.1"
61
71
  },
62
72
  "peerDependencies": {
63
- "axios": ">=1.0.0"
73
+ "axios": ">=1.0.0",
74
+ "ws": ">=8.0.0"
64
75
  },
65
76
  "peerDependenciesMeta": {
66
77
  "axios": {
67
78
  "optional": true
79
+ },
80
+ "ws": {
81
+ "optional": true
68
82
  }
69
83
  },
70
84
  "devDependencies": {
71
- "axios": "^1.9.0",
72
85
  "@semantic-release/changelog": "^6.0.3",
73
86
  "@semantic-release/git": "^10.0.1",
74
87
  "@semantic-release/npm": "^13.1.3",
75
88
  "@types/node": "^22.0.0",
89
+ "@types/ws": "^8.18.1",
90
+ "axios": "^1.9.0",
76
91
  "pino-pretty": "^13.1.3",
77
92
  "semantic-release": "^25.0.2",
78
93
  "tsup": "^8.0.0",
79
94
  "tsx": "^4.21.0",
80
95
  "typescript": "^5.7.0",
81
- "vitest": "^2.0.0"
96
+ "vitest": "^2.0.0",
97
+ "winston": "^3.19.0"
82
98
  }
83
99
  }