@visulima/pail 4.0.0-alpha.11 → 4.0.0-alpha.12

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE.md +152 -894
  3. package/dist/error.d.ts +95 -96
  4. package/dist/index.browser.d.ts +557 -47
  5. package/dist/index.browser.js +1 -1
  6. package/dist/index.server.d.ts +722 -61
  7. package/dist/index.server.js +5 -4
  8. package/dist/middleware/elysia.d.ts +65 -63
  9. package/dist/middleware/express.d.ts +73 -71
  10. package/dist/middleware/fastify.d.ts +69 -67
  11. package/dist/middleware/hono.d.ts +74 -72
  12. package/dist/middleware/next/handler.d.ts +101 -34
  13. package/dist/middleware/sveltekit.d.ts +100 -98
  14. package/dist/object-tree.d.ts +67 -70
  15. package/dist/packem_shared/{PrettyReporter-BtTr13Ha.js → PrettyReporter-CIbrmjUV.js} +1 -1
  16. package/dist/packem_shared/{PrettyReporter-BCvyNzXO.js → PrettyReporter-CNJEO9g7.js} +11 -8
  17. package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
  18. package/dist/packem_shared/{abstract-pretty-reporter-CXAKYCb8.js → abstract-pretty-reporter-CkqCt5hg.js} +4 -2
  19. package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
  20. package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
  21. package/dist/packem_shared/types.d-BeLumqgD.d.ts +246 -0
  22. package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
  23. package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
  24. package/dist/packem_shared/wide-event.d-B-t8ZnhI.d.ts +704 -0
  25. package/dist/processor/caller/caller-processor.d.ts +49 -47
  26. package/dist/processor/environment-processor.d.ts +113 -113
  27. package/dist/processor/environment-processor.js +3 -10
  28. package/dist/processor/message-formatter-processor.d.ts +51 -49
  29. package/dist/processor/message-formatter-processor.js +2 -2
  30. package/dist/processor/opentelemetry-processor.d.ts +69 -66
  31. package/dist/processor/redact-processor.d.ts +60 -41
  32. package/dist/processor/sampling-processor.d.ts +102 -101
  33. package/dist/reporter/file/json-file-reporter.d.ts +91 -42
  34. package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
  35. package/dist/reporter/http/http-reporter.d.ts +40 -36
  36. package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
  37. package/dist/reporter/json/index.browser.d.ts +99 -3
  38. package/dist/reporter/json/index.d.ts +51 -3
  39. package/dist/reporter/pretty/index.browser.d.ts +106 -2
  40. package/dist/reporter/pretty/index.browser.js +1 -1
  41. package/dist/reporter/pretty/index.d.ts +219 -2
  42. package/dist/reporter/pretty/index.js +1 -1
  43. package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
  44. package/dist/reporter/simple/simple-reporter.server.js +3 -2
  45. package/dist/wide-event.d.ts +5 -300
  46. package/package.json +6 -7
  47. package/dist/constants.d.ts +0 -37
  48. package/dist/middleware/next/middleware.d.ts +0 -59
  49. package/dist/middleware/next/storage.d.ts +0 -14
  50. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  51. package/dist/middleware/shared/headers.d.ts +0 -14
  52. package/dist/middleware/shared/routes.d.ts +0 -30
  53. package/dist/middleware/shared/storage.d.ts +0 -29
  54. package/dist/pail.browser.d.ts +0 -412
  55. package/dist/pail.server.d.ts +0 -158
  56. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  57. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  58. package/dist/reporter/http/utils/compression.d.ts +0 -7
  59. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  60. package/dist/reporter/http/utils/retry.d.ts +0 -27
  61. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  62. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  63. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  64. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  65. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  66. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  67. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  68. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  69. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  70. package/dist/reporter/utils/format-label.d.ts +0 -3
  71. package/dist/types.d.ts +0 -241
  72. package/dist/utils/arrayify.d.ts +0 -2
  73. package/dist/utils/get-longest-badge.d.ts +0 -4
  74. package/dist/utils/get-longest-label.d.ts +0 -4
  75. package/dist/utils/merge-types.d.ts +0 -4
  76. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  77. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  78. package/dist/utils/write-stream.d.ts +0 -2
@@ -1,412 +0,0 @@
1
- import type { stringify } from "safe-stable-stringify";
2
- import type { LiteralUnion } from "type-fest";
3
- import type { ConstructorOptions, DefaultLogTypes, ExtendedRfc5424LogLevels, LoggerFunction, LoggerTypesConfig, Meta, Processor, Reporter } from "./types.d.ts";
4
- /**
5
- * Pail Browser Implementation.
6
- *
7
- * A comprehensive logging library for browser environments with support for
8
- * multiple log levels, custom types, processors, reporters, and advanced features
9
- * like throttling, scoping, timers, and counters.
10
- * @template T - Custom logger types (string union)
11
- * @template L - Log level types (string union)
12
- * @example
13
- * ```typescript
14
- * const logger = new PailBrowserImpl({
15
- * logLevel: "debug",
16
- * types: {
17
- * http: { color: "blue", label: "HTTP", logLevel: "info" }
18
- * },
19
- * reporters: [new JsonReporter()]
20
- * });
21
- *
22
- * logger.info("Application started");
23
- * logger.http("GET /api/users 200");
24
- * logger.error("Something went wrong", error);
25
- * ```
26
- */
27
- export declare class PailBrowserImpl<T extends string = string, L extends string = string> {
28
- #private;
29
- protected timersMap: Map<string, number>;
30
- protected countMap: Map<string, number>;
31
- protected seqTimers: Set<string>;
32
- protected readonly lastLog: {
33
- count?: number;
34
- object?: Meta<L>;
35
- time?: Date;
36
- timeout?: ReturnType<typeof setTimeout>;
37
- };
38
- protected readonly logLevels: Record<string, number>;
39
- protected disabled: boolean;
40
- protected paused: boolean;
41
- protected messageQueue: {
42
- messageObject: any[];
43
- raw: boolean;
44
- type: LiteralUnion<DefaultLogTypes, T>;
45
- }[];
46
- protected scopeName: string[];
47
- protected readonly types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
48
- protected readonly longestLabel: string;
49
- protected readonly processors: Set<Processor<L>>;
50
- protected readonly generalLogLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;
51
- protected reporters: Set<Reporter<L>>;
52
- protected readonly throttle: number;
53
- protected readonly throttleMin: number;
54
- protected readonly stringify: typeof stringify;
55
- protected groups: string[];
56
- protected readonly startTimerMessage: string;
57
- protected readonly endTimerMessage: string;
58
- protected rawReporter: Reporter<L>;
59
- protected force: Record<string, LoggerFunction>;
60
- /**
61
- * Creates a new Pail browser logger instance.
62
- *
63
- * Initializes the logger with the provided configuration options,
64
- * setting up reporters, processors, log levels, and other internal state.
65
- * @param options Configuration options for the logger
66
- */
67
- constructor(options: ConstructorOptions<T, L>);
68
- /**
69
- * Wraps the global console methods to redirect them through the logger.
70
- *
71
- * This method replaces console methods (log, info, warn, error, etc.) with
72
- * calls to the corresponding logger methods. The original console methods
73
- * are backed up and can be restored using restoreConsole().
74
- * @example
75
- * ```typescript
76
- * const logger = createPail();
77
- * logger.wrapConsole();
78
- *
79
- * console.log("This will go through the logger");
80
- * console.error("This too!");
81
- *
82
- * logger.restoreConsole(); // Restore original console methods
83
- * ```
84
- */
85
- wrapConsole(): void;
86
- /**
87
- * Restores the original global console methods.
88
- *
89
- * This method restores the console methods that were backed up by wrapConsole().
90
- * After calling this, console methods will work as they did before wrapping.
91
- * @example
92
- * ```typescript
93
- * const logger = createPail();
94
- * logger.wrapConsole();
95
- *
96
- * // Console methods are now wrapped
97
- * logger.restoreConsole();
98
- * // Console methods are restored to original behavior
99
- * ```
100
- */
101
- restoreConsole(): void;
102
- /**
103
- * Wraps uncaught exception and unhandled rejection handlers.
104
- *
105
- * This method sets up global error handlers that will log uncaught exceptions
106
- * and unhandled promise rejections through the logger. This is useful for
107
- * capturing and logging application crashes.
108
- * @example
109
- * ```typescript
110
- * const logger = createPail();
111
- * logger.wrapException();
112
- *
113
- * // Now uncaught errors will be logged
114
- * throw new Error("This will be logged");
115
- * ```
116
- */
117
- wrapException(): void;
118
- /**
119
- * Disables all logging output.
120
- *
121
- * When disabled, all log calls will be silently ignored and no output
122
- * will be produced by any reporters. This can be useful for temporarily
123
- * suppressing log output in production or during testing.
124
- * @example
125
- * ```typescript
126
- * const logger = createPail();
127
- * logger.disable();
128
- * logger.info("This won't be logged"); // Silent
129
- * logger.enable();
130
- * logger.info("This will be logged"); // Output produced
131
- * ```
132
- */
133
- disable(): void;
134
- /**
135
- * Enables logging output.
136
- *
137
- * Re-enables logging after it has been disabled. All subsequent log calls
138
- * will produce output according to the configured reporters.
139
- * @example
140
- * ```typescript
141
- * const logger = createPail();
142
- * logger.disable();
143
- * logger.info("This won't be logged");
144
- * logger.enable(); // Re-enable logging
145
- * logger.info("This will be logged");
146
- * ```
147
- */
148
- enable(): void;
149
- /**
150
- * Checks if logging is currently enabled.
151
- *
152
- * Returns true if logging is enabled and false if it has been disabled.
153
- * @returns True if logging is enabled, false if disabled
154
- * @example
155
- * ```typescript
156
- * const logger = createPail();
157
- * console.log(logger.isEnabled()); // true
158
- * logger.disable();
159
- * console.log(logger.isEnabled()); // false
160
- * ```
161
- */
162
- isEnabled(): boolean;
163
- /**
164
- * Pauses logging and starts queuing messages.
165
- *
166
- * When paused, all log calls will be queued instead of being output immediately.
167
- * The queued messages will be processed when resume() is called. This is useful
168
- * for temporarily buffering log output during critical operations.
169
- * @example
170
- * ```typescript
171
- * const logger = createPail();
172
- * logger.pause();
173
- * logger.info("This will be queued"); // Queued, not output yet
174
- * logger.warn("This too"); // Also queued
175
- * logger.resume(); // Now both messages are output
176
- * ```
177
- */
178
- pause(): void;
179
- /**
180
- * Resumes logging and flushes all queued messages.
181
- *
182
- * Processes all messages that were queued during the pause period and
183
- * resumes normal logging behavior. Messages are output in the order
184
- * they were originally called.
185
- * @example
186
- * ```typescript
187
- * const logger = createPail();
188
- * logger.pause();
189
- * logger.info("Message 1"); // Queued
190
- * logger.info("Message 2"); // Queued
191
- * logger.resume(); // Both messages are now output in order
192
- * logger.info("Message 3"); // Output immediately
193
- * ```
194
- */
195
- resume(): void;
196
- /**
197
- * Creates a scoped logger instance.
198
- *
199
- * Returns a new logger instance that inherits all configuration but adds
200
- * the specified scope names to all log messages. This is useful for
201
- * categorizing logs by component, module, or feature.
202
- * @template N - The new custom logger type names
203
- * @param name Scope names to apply to all log messages
204
- * @returns A new scoped logger instance
205
- * @throws {Error} If no scope name is provided
206
- * @example
207
- * ```typescript
208
- * const logger = createPail();
209
- * const scopedLogger = logger.scope("auth", "login");
210
- * scopedLogger.info("User logged in"); // Will include scope: ["auth", "login"]
211
- * ```
212
- */
213
- scope<N extends string = T>(...name: string[]): PailBrowserType<N, L>;
214
- /**
215
- * Removes the current scope from the logger.
216
- *
217
- * Clears all scope names that were set by previous scope() calls.
218
- * After calling this, log messages will no longer include scope information.
219
- * @example
220
- * ```typescript
221
- * const logger = createPail();
222
- * const scopedLogger = logger.scope("auth");
223
- * scopedLogger.info("Scoped message"); // Has scope
224
- * scopedLogger.unscope();
225
- * scopedLogger.info("Unscoped message"); // No scope
226
- * ```
227
- */
228
- unscope(): void;
229
- /**
230
- * Creates a child logger that inherits settings from the parent.
231
- *
232
- * Returns a new logger instance that inherits all configuration from the parent
233
- * (reporters, processors, types, log levels, throttle settings, etc.) while allowing
234
- * you to override only what you need. Child loggers are independent instances with
235
- * their own state (timers, counters, etc.).
236
- * @template N - The new custom logger type names
237
- * @template LC - The new log level types
238
- * @param options Configuration options to override or extend parent settings
239
- * @returns A new child logger instance
240
- * @example
241
- * ```typescript
242
- * const parent = createPail({
243
- * logLevel: "info",
244
- * types: { http: { label: "HTTP", logLevel: "info" } },
245
- * reporters: [new PrettyReporter()],
246
- * });
247
- *
248
- * // Child inherits parent settings but overrides log level
249
- * const child = parent.child({ logLevel: "debug" });
250
- * child.info("This will be logged"); // Uses debug level from child
251
- * child.http("GET /api 200"); // Inherits http type from parent
252
- *
253
- * // Child can add new types
254
- * const childWithNewType = parent.child({
255
- * types: { db: { label: "DB", logLevel: "info" } },
256
- * });
257
- * childWithNewType.db("Query executed"); // New type available
258
- * ```
259
- */
260
- child<N extends string = T, LC extends string = L>(options?: Partial<ConstructorOptions<N, LC>>): PailBrowserType<N, LC>;
261
- /**
262
- * Starts a timer with the specified label.
263
- *
264
- * Records the current timestamp and associates it with the given label.
265
- * Multiple timers can be active simultaneously with different labels.
266
- * @param label The timer label (defaults to "default")
267
- * @example
268
- * ```typescript
269
- * const logger = createPail();
270
- * logger.time("operation");
271
- * // ... some operation ...
272
- * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
273
- * ```
274
- */
275
- time(label?: string): void;
276
- /**
277
- * Logs the current elapsed time for a timer without stopping it.
278
- *
279
- * Calculates and logs the time elapsed since the timer was started,
280
- * but keeps the timer running. If no label is provided, uses the
281
- * most recently started timer.
282
- * @param label The timer label (uses last timer if not specified)
283
- * @param data Additional data to include in the log message
284
- * @example
285
- * ```typescript
286
- * const logger = createPail();
287
- * logger.time("task");
288
- * // ... some work ...
289
- * logger.timeLog("task"); // Logs current elapsed time
290
- * // ... more work ...
291
- * logger.timeEnd("task"); // Logs final time and stops timer
292
- * ```
293
- */
294
- timeLog(label?: string, ...data: unknown[]): void;
295
- /**
296
- * Stops a timer and logs the final elapsed time.
297
- *
298
- * Calculates the total time elapsed since the timer was started,
299
- * logs the result, and removes the timer. If no label is provided,
300
- * uses the most recently started timer.
301
- * @param label The timer label (uses last timer if not specified)
302
- * @example
303
- * ```typescript
304
- * const logger = createPail();
305
- * logger.time("operation");
306
- * // ... perform operation ...
307
- * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
308
- * ```
309
- */
310
- timeEnd(label?: string): void;
311
- /**
312
- * Starts a log group with the specified label.
313
- *
314
- * Groups related log messages together. In browser environments,
315
- * this uses the native console.group() functionality. In other
316
- * environments, it tracks group nesting internally.
317
- * @param label The group label (defaults to "console.group")
318
- * @example
319
- * ```typescript
320
- * const logger = createPail();
321
- * logger.group("Database Operations");
322
- * logger.info("Connecting to database");
323
- * logger.info("Running migration");
324
- * logger.groupEnd(); // End the group
325
- * ```
326
- */
327
- group(label?: string): void;
328
- /**
329
- * Ends the current log group.
330
- *
331
- * Closes the most recently opened log group. In browser environments,
332
- * this uses the native console.groupEnd() functionality.
333
- * @example
334
- * ```typescript
335
- * const logger = createPail();
336
- * logger.group("Processing");
337
- * logger.info("Step 1");
338
- * logger.info("Step 2");
339
- * logger.groupEnd(); // Closes the "Processing" group
340
- * ```
341
- */
342
- groupEnd(): void;
343
- /**
344
- * Increments and logs a counter with the specified label.
345
- *
346
- * Maintains an internal counter for each label and logs the current count
347
- * each time it's called. Useful for tracking how many times certain
348
- * code paths are executed.
349
- * @param label The counter label (defaults to "default")
350
- * @example
351
- * ```typescript
352
- * const logger = createPail();
353
- * logger.count("requests"); // Logs: "requests: 1"
354
- * logger.count("requests"); // Logs: "requests: 2"
355
- * logger.count("errors"); // Logs: "errors: 1"
356
- * ```
357
- */
358
- count(label?: string): void;
359
- /**
360
- * Resets a counter to zero.
361
- *
362
- * Removes the counter with the specified label, effectively resetting
363
- * it to zero. If the counter doesn't exist, logs a warning.
364
- * @param label The counter label to reset (defaults to "default")
365
- * @example
366
- * ```typescript
367
- * const logger = createPail();
368
- * logger.count("requests"); // Logs: "requests: 1"
369
- * logger.countReset("requests"); // Resets counter
370
- * logger.count("requests"); // Logs: "requests: 1" (starts over)
371
- * ```
372
- */
373
- countReset(label?: string): void;
374
- /**
375
- * Clears the console output.
376
- *
377
- * Calls the native console.clear() method to clear all output from
378
- * the console. This is a convenience method that wraps the native
379
- * console.clear() functionality.
380
- * @example
381
- * ```typescript
382
- * const logger = createPail();
383
- * logger.info("Some message");
384
- * logger.clear(); // Clears the console
385
- * ```
386
- */
387
- clear(): void;
388
- /**
389
- * Logs a raw message bypassing normal processing.
390
- *
391
- * Sends a message directly to the raw reporter without going through
392
- * the normal logging pipeline (processors, throttling, etc.). This is
393
- * useful for logging that needs to bypass all formatting and processing.
394
- * @param message The raw message to log
395
- * @param arguments_ Additional arguments to include
396
- * @example
397
- * ```typescript
398
- * const logger = createPail();
399
- * logger.raw("Direct message", { data: "value" });
400
- * ```
401
- */
402
- raw(message: string, ...arguments_: unknown[]): void;
403
- protected extendReporter(reporter: Reporter<L>): Reporter<L>;
404
- protected registerReporters(reporters: Reporter<L>[]): void;
405
- protected registerProcessors(processors: Processor<L>[]): void;
406
- protected logger(type: LiteralUnion<DefaultLogTypes, T>, raw: boolean, force: boolean, ...messageObject: unknown[]): void;
407
- }
408
- export type PailBrowserType<T extends string = string, L extends string = string> = Console & (new <TC extends string = string, LC extends string = string>(options?: ConstructorOptions<TC, LC>) => PailBrowserType<TC, LC>) & PailBrowserImpl<T, L> & Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction> & {
409
- force: Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
410
- };
411
- export type PailConstructor<T extends string = string, L extends string = string> = new (options?: ConstructorOptions<T, L>) => PailBrowserType<T, L>;
412
- export declare const PailBrowser: PailBrowserType;
@@ -1,158 +0,0 @@
1
- import { InteractiveManager } from "@visulima/interactive-manager";
2
- import { PailBrowserImpl } from "./pail.d.ts";
3
- import type { ConstructorOptions, DefaultLogTypes, LoggerFunction, Reporter, ServerConstructorOptions } from "./types.d.ts";
4
- declare class PailServerImpl<T extends string = string, L extends string = string> extends PailBrowserImpl<T, L> {
5
- #private;
6
- readonly options: ServerConstructorOptions<T, L>;
7
- protected readonly stdout: NodeJS.WriteStream;
8
- protected readonly stderr: NodeJS.WriteStream;
9
- protected interactiveManager: InteractiveManager | undefined;
10
- protected readonly interactive: boolean;
11
- /**
12
- * Creates a new Pail server logger instance.
13
- *
14
- * Initializes the server-compatible logger with streams, interactive support,
15
- * and server-specific configuration options.
16
- * @param options Server-specific configuration options
17
- */
18
- constructor(options: ServerConstructorOptions<T, L>);
19
- scope<N extends string = T>(...name: string[]): PailServerType<N, L>;
20
- /**
21
- * Creates a child logger that inherits settings from the parent.
22
- *
23
- * Returns a new logger instance that inherits all configuration from the parent
24
- * (reporters, processors, types, log levels, throttle settings, etc.) while allowing
25
- * you to override only what you need. Child loggers are independent instances with
26
- * their own state (timers, counters, etc.).
27
- * @template N - The new custom logger type names
28
- * @template LC - The new log level types
29
- * @param options Configuration options to override or extend parent settings
30
- * @returns A new child logger instance
31
- * @example
32
- * ```typescript
33
- * const parent = createPail({
34
- * logLevel: "info",
35
- * types: { http: { label: "HTTP", logLevel: "info" } },
36
- * reporters: [new PrettyReporter()],
37
- * });
38
- *
39
- * // Child inherits parent settings but overrides log level
40
- * const child = parent.child({ logLevel: "debug" });
41
- * child.info("This will be logged"); // Uses debug level from child
42
- * child.http("GET /api 200"); // Inherits http type from parent
43
- *
44
- * // Child can add new types
45
- * const childWithNewType = parent.child({
46
- * types: { db: { label: "DB", logLevel: "info" } },
47
- * });
48
- * childWithNewType.db("Query executed"); // New type available
49
- * ```
50
- */
51
- child<N extends string = T, LC extends string = L>(options?: Partial<ConstructorOptions<N, LC>> & Partial<Pick<ServerConstructorOptions<N, LC>, "interactive" | "stderr" | "stdout">>): PailServerType<N, LC>;
52
- /**
53
- * Gets the interactive manager instance if interactive mode is enabled.
54
- *
55
- * Returns the InteractiveManager instance that handles interactive terminal
56
- * features like progress bars and dynamic updates. Only available when
57
- * interactive mode is enabled in the constructor options.
58
- * @returns The interactive manager instance, or undefined if not in interactive mode
59
- * @example
60
- * ```typescript
61
- * const logger = createPail({ interactive: true });
62
- * const manager = logger.getInteractiveManager();
63
- * if (manager) {
64
- * manager.hook();
65
- * // Use interactive features
66
- * manager.unhook();
67
- * }
68
- * ```
69
- */
70
- getInteractiveManager(): InteractiveManager | undefined;
71
- /**
72
- * Wraps stdout and stderr streams to redirect them through the logger.
73
- *
74
- * Intercepts writes to process.stdout and process.stderr, redirecting them
75
- * through the logger instead of writing directly to the streams. This allows
76
- * all output to be processed by the logging pipeline.
77
- * @example
78
- * ```typescript
79
- * const logger = createPail();
80
- * logger.wrapStd();
81
- *
82
- * console.log("This goes through logger");
83
- * process.stdout.write("This too");
84
- *
85
- * logger.restoreStd(); // Restore original streams
86
- * ```
87
- */
88
- wrapStd(): void;
89
- /**
90
- * Restores the original stdout and stderr streams.
91
- *
92
- * Removes the stream wrapping that was applied by wrapStd(),
93
- * restoring the original stream write methods.
94
- * @example
95
- * ```typescript
96
- * const logger = createPail();
97
- * logger.wrapStd();
98
- * // Streams are wrapped
99
- * logger.restoreStd();
100
- * // Streams are restored to original behavior
101
- * ```
102
- */
103
- restoreStd(): void;
104
- /**
105
- * Wraps all output sources (console and streams).
106
- *
107
- * Convenience method that calls both wrapConsole() and wrapStd()
108
- * to redirect all output through the logger.
109
- * @example
110
- * ```typescript
111
- * const logger = createPail();
112
- * logger.wrapAll(); // Wraps console and streams
113
- *
114
- * // All output now goes through logger
115
- * console.log("Console output");
116
- * process.stdout.write("Stream output");
117
- *
118
- * logger.restoreAll(); // Restore everything
119
- * ```
120
- */
121
- wrapAll(): void;
122
- /**
123
- * Restores all wrapped output sources.
124
- *
125
- * Convenience method that calls both restoreConsole() and restoreStd()
126
- * to restore all original output behavior.
127
- * @example
128
- * ```typescript
129
- * const logger = createPail();
130
- * logger.wrapAll();
131
- * // All output is wrapped
132
- * logger.restoreAll();
133
- * // All output sources are restored
134
- * ```
135
- */
136
- restoreAll(): void;
137
- /**
138
- * Clears the terminal screen.
139
- *
140
- * Sends ANSI escape sequences to clear the terminal screen and move
141
- * the cursor to the top-left position. This overrides the browser
142
- * implementation to work with terminal streams.
143
- * @example
144
- * ```typescript
145
- * const logger = createPail();
146
- * logger.info("Some output");
147
- * logger.clear(); // Clears the terminal screen
148
- * ```
149
- */
150
- clear(): void;
151
- protected extendReporter(reporter: Reporter<L>): Reporter<L>;
152
- }
153
- export type PailServerType<T extends string = string, L extends string = string> = Console & (new <TC extends string = string, LC extends string = string>(options?: ServerConstructorOptions<TC, LC>) => PailServerType<TC, LC>) & PailServerImpl<T, L> & Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction> & {
154
- force: Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
155
- };
156
- export type PailConstructor<T extends string = string, L extends string = string> = new (options?: ServerConstructorOptions<T, L>) => PailServerType<T, L>;
157
- export declare const PailServer: PailServerType;
158
- export {};
@@ -1,23 +0,0 @@
1
- /**
2
- * Gets the file location information of the caller.
3
- *
4
- * Uses Node.js stack trace API to analyze the call stack and determine
5
- * the file, line, and column where this function was called from.
6
- * Filters out internal pail files and native code.
7
- * @returns Object containing file location information
8
- * @example
9
- * ```typescript
10
- * const location = getCallerFilename();
11
- * console.log(location);
12
- * // { fileName: "/path/to/file.js", lineNumber: 42, columnNumber: 10 }
13
- * ```
14
- */
15
- declare const getCallerFilename: () => {
16
- /** Column number where the call originated */
17
- columnNumber?: number;
18
- /** File name/path where the call originated */
19
- fileName: string | undefined;
20
- /** Line number where the call originated */
21
- lineNumber?: number;
22
- };
23
- export default getCallerFilename;
@@ -1,48 +0,0 @@
1
- import type { Options as RfsOptions } from "rotating-file-stream";
2
- /**
3
- * Rotating File Stream.
4
- *
5
- * A wrapper for the `rotating-file-stream` module that provides optional immediate
6
- * writing to disk by creating and closing a new stream on each write operation.
7
- * This is useful for ensuring log messages are written immediately rather than buffered.
8
- * @example
9
- * ```typescript
10
- * // Buffered writing (default)
11
- * const bufferedStream = new RotatingFileStream("/var/log/app.log", false, {
12
- * interval: "1d",
13
- * size: "10M"
14
- * });
15
- *
16
- * // Immediate writing
17
- * const immediateStream = new RotatingFileStream("/var/log/app.log", true, {
18
- * interval: "1d"
19
- * });
20
- * ```
21
- */
22
- declare class RotatingFileStream {
23
- #private;
24
- /**
25
- * Creates a new RotatingFileStream instance.
26
- * @param filePath Path to the log file
27
- * @param writeImmediately Whether to write immediately or buffer writes
28
- * @param options Options for the rotating file stream
29
- * @throws {Error} If the 'rotating-file-stream' package is not installed
30
- */
31
- constructor(filePath: string, writeImmediately?: boolean, options?: RfsOptions);
32
- /**
33
- * Writes a message to the rotating file stream.
34
- *
35
- * If writeImmediately was set to true in the constructor, a new stream
36
- * is created for each write operation. Otherwise, uses the buffered stream.
37
- * @param message The message to write to the file
38
- */
39
- write(message: string): void;
40
- /**
41
- * Ends the rotating file stream.
42
- *
43
- * Closes the underlying stream. When `writeImmediately` is not `true`,
44
- * calling `write` after calling this method will throw an error.
45
- */
46
- end(): void;
47
- }
48
- export default RotatingFileStream;
@@ -1,7 +0,0 @@
1
- /**
2
- * Compresses data using gzip compression.
3
- * @param data The data to compress as a string
4
- * @returns A Promise that resolves to the compressed data as Uint8Array
5
- */
6
- declare const compressData: (data: string) => Promise<Uint8Array>;
7
- export default compressData;
@@ -1,30 +0,0 @@
1
- /**
2
- * Error thrown when a log entry exceeds the maximum allowed size.
3
- */
4
- declare class LogSizeError extends Error {
5
- /**
6
- * The log entry data that caused the error
7
- */
8
- readonly logData: Record<string, unknown>;
9
- /**
10
- * The actual size of the log entry in bytes
11
- */
12
- readonly actualSize: number;
13
- /**
14
- * The maximum allowed size in bytes
15
- */
16
- readonly maxSize: number;
17
- /**
18
- * Creates a new LogSizeError instance.
19
- * @param message Descriptive error message explaining the size violation
20
- * @param logData The log entry data that caused the error
21
- * @param actualSize Size of the log entry in bytes
22
- * @param maxSize Maximum allowed size in bytes
23
- * @example
24
- * ```typescript
25
- * throw new LogSizeError("Log too large", logData, 2000000, 1000000);
26
- * ```
27
- */
28
- constructor(message: string, logData: Record<string, unknown>, actualSize: number, maxSize: number);
29
- }
30
- export default LogSizeError;