@visulima/pail 3.2.0 → 3.2.2

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 (64) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE.md +3 -0
  3. package/dist/constants.d.ts +37 -0
  4. package/dist/index.browser.d.ts +47 -12
  5. package/dist/index.browser.js +1 -1
  6. package/dist/index.server.d.ts +65 -43
  7. package/dist/index.server.js +1 -3
  8. package/dist/interactive/index.d.ts +2 -28
  9. package/dist/interactive/interactive-manager.d.ts +108 -0
  10. package/dist/interactive/interactive-stream-hook.d.ts +68 -0
  11. package/dist/object-tree.d.ts +65 -7
  12. package/dist/packem_shared/{JsonReporter-BqWsVkHP.js → JsonReporter-C0AXk99i.js} +0 -2
  13. package/dist/packem_shared/{pail.browser-CPDOE_d1.js → pail.browser-CPjQrsyy.js} +3 -3
  14. package/dist/pail.browser.d.ts +412 -0
  15. package/dist/pail.server.d.ts +233 -0
  16. package/dist/processor/caller/caller-processor.d.ts +40 -7
  17. package/dist/processor/caller/get-caller-filename.d.ts +23 -0
  18. package/dist/processor/message-formatter-processor.d.ts +44 -9
  19. package/dist/processor/message-formatter-processor.js +1 -1
  20. package/dist/processor/opentelemetry-processor.d.ts +61 -10
  21. package/dist/processor/redact-processor.d.ts +39 -8
  22. package/dist/progress-bar.d.ts +75 -15
  23. package/dist/reporter/file/json-file-reporter.d.ts +39 -20
  24. package/dist/reporter/file/utils/rotating-file-stream.d.ts +48 -0
  25. package/dist/reporter/http/abstract-http-reporter.d.ts +125 -12
  26. package/dist/reporter/http/http-reporter.d.ts +36 -10
  27. package/dist/reporter/http/http-reporter.edge-light.d.ts +37 -165
  28. package/dist/reporter/http/utils/compression.d.ts +7 -0
  29. package/dist/reporter/http/utils/log-size-error.d.ts +30 -0
  30. package/dist/reporter/http/utils/retry.d.ts +27 -0
  31. package/dist/reporter/json/abstract-json-reporter.d.ts +61 -0
  32. package/dist/reporter/json/index.browser.d.ts +3 -13
  33. package/dist/reporter/json/index.d.ts +3 -16
  34. package/dist/reporter/json/index.js +1 -1
  35. package/dist/reporter/json/json-reporter.browser.d.ts +40 -0
  36. package/dist/reporter/json/json-reporter.server.d.ts +50 -0
  37. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +83 -0
  38. package/dist/reporter/pretty/index.browser.d.ts +2 -13
  39. package/dist/reporter/pretty/index.d.ts +2 -25
  40. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +36 -0
  41. package/dist/reporter/pretty/pretty-reporter.server.d.ts +70 -0
  42. package/dist/reporter/raw/raw-reporter.browser.d.ts +5 -0
  43. package/dist/reporter/raw/raw-reporter.server.d.ts +13 -0
  44. package/dist/reporter/simple/simple-reporter.server.d.ts +10 -14
  45. package/dist/reporter/utils/default-inspector-config.d.ts +3 -0
  46. package/dist/reporter/utils/format-label.d.ts +3 -0
  47. package/dist/spinner.d.ts +170 -104
  48. package/dist/spinner.js +89 -89
  49. package/dist/types.d.ts +241 -0
  50. package/dist/utils/ansi-escapes.d.ts +4 -0
  51. package/dist/utils/arrayify.d.ts +2 -0
  52. package/dist/utils/get-longest-badge.d.ts +4 -0
  53. package/dist/utils/get-longest-label.d.ts +4 -0
  54. package/dist/utils/merge-types.d.ts +4 -0
  55. package/dist/utils/stream/safe-stream-handler.d.ts +21 -0
  56. package/dist/utils/write-console-log-based-on-level.d.ts +4 -0
  57. package/dist/utils/write-stream.d.ts +2 -0
  58. package/package.json +3 -4
  59. package/dist/packem_shared/abstract-json-reporter-DiyVyU0j.d.ts +0 -22
  60. package/dist/packem_shared/abstract-pretty-reporter-BbOWXMCs.d.ts +0 -28
  61. package/dist/packem_shared/index.d-BR1GjZri.d.ts +0 -53
  62. package/dist/packem_shared/index.d-oxZvg_y7.d.ts +0 -20
  63. package/dist/packem_shared/pail.browser-By9KjOH7.d.ts +0 -69
  64. package/dist/packem_shared/types-D3ycu8-x.d.ts +0 -95
@@ -0,0 +1,412 @@
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: any[]): 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;
@@ -0,0 +1,233 @@
1
+ import InteractiveManager from "./interactive/interactive-manager.d.ts";
2
+ import { PailBrowserImpl } from "./pail.d.ts";
3
+ import type { MultiBarOptions, SingleBarOptions } from "./progress-bar.d.ts";
4
+ import { MultiProgressBar, ProgressBar } from "./progress-bar.d.ts";
5
+ import type { SpinnerOptions } from "./spinner.d.ts";
6
+ import { MultiSpinner, Spinner } from "./spinner.d.ts";
7
+ import type { ConstructorOptions, DefaultLogTypes, LoggerFunction, Reporter, ServerConstructorOptions } from "./types.d.ts";
8
+ declare class PailServerImpl<T extends string = string, L extends string = string> extends PailBrowserImpl<T, L> {
9
+ #private;
10
+ readonly options: ServerConstructorOptions<T, L>;
11
+ protected readonly stdout: NodeJS.WriteStream;
12
+ protected readonly stderr: NodeJS.WriteStream;
13
+ protected interactiveManager: InteractiveManager | undefined;
14
+ protected readonly interactive: boolean;
15
+ /**
16
+ * Creates a new Pail server logger instance.
17
+ *
18
+ * Initializes the server-compatible logger with streams, interactive support,
19
+ * and server-specific configuration options.
20
+ * @param options Server-specific configuration options
21
+ */
22
+ constructor(options: ServerConstructorOptions<T, L>);
23
+ scope<N extends string = T>(...name: string[]): PailServerType<N, L>;
24
+ /**
25
+ * Creates a child logger that inherits settings from the parent.
26
+ *
27
+ * Returns a new logger instance that inherits all configuration from the parent
28
+ * (reporters, processors, types, log levels, throttle settings, etc.) while allowing
29
+ * you to override only what you need. Child loggers are independent instances with
30
+ * their own state (timers, counters, etc.).
31
+ * @template N - The new custom logger type names
32
+ * @template LC - The new log level types
33
+ * @param options Configuration options to override or extend parent settings
34
+ * @returns A new child logger instance
35
+ * @example
36
+ * ```typescript
37
+ * const parent = createPail({
38
+ * logLevel: "info",
39
+ * types: { http: { label: "HTTP", logLevel: "info" } },
40
+ * reporters: [new PrettyReporter()],
41
+ * });
42
+ *
43
+ * // Child inherits parent settings but overrides log level
44
+ * const child = parent.child({ logLevel: "debug" });
45
+ * child.info("This will be logged"); // Uses debug level from child
46
+ * child.http("GET /api 200"); // Inherits http type from parent
47
+ *
48
+ * // Child can add new types
49
+ * const childWithNewType = parent.child({
50
+ * types: { db: { label: "DB", logLevel: "info" } },
51
+ * });
52
+ * childWithNewType.db("Query executed"); // New type available
53
+ * ```
54
+ */
55
+ 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>;
56
+ /**
57
+ * Gets the interactive manager instance if interactive mode is enabled.
58
+ *
59
+ * Returns the InteractiveManager instance that handles interactive terminal
60
+ * features like progress bars and dynamic updates. Only available when
61
+ * interactive mode is enabled in the constructor options.
62
+ * @returns The interactive manager instance, or undefined if not in interactive mode
63
+ * @example
64
+ * ```typescript
65
+ * const logger = createPail({ interactive: true });
66
+ * const manager = logger.getInteractiveManager();
67
+ * if (manager) {
68
+ * manager.hook();
69
+ * // Use interactive features
70
+ * manager.unhook();
71
+ * }
72
+ * ```
73
+ */
74
+ getInteractiveManager(): InteractiveManager | undefined;
75
+ /**
76
+ * Wraps stdout and stderr streams to redirect them through the logger.
77
+ *
78
+ * Intercepts writes to process.stdout and process.stderr, redirecting them
79
+ * through the logger instead of writing directly to the streams. This allows
80
+ * all output to be processed by the logging pipeline.
81
+ * @example
82
+ * ```typescript
83
+ * const logger = createPail();
84
+ * logger.wrapStd();
85
+ *
86
+ * console.log("This goes through logger");
87
+ * process.stdout.write("This too");
88
+ *
89
+ * logger.restoreStd(); // Restore original streams
90
+ * ```
91
+ */
92
+ wrapStd(): void;
93
+ /**
94
+ * Restores the original stdout and stderr streams.
95
+ *
96
+ * Removes the stream wrapping that was applied by wrapStd(),
97
+ * restoring the original stream write methods.
98
+ * @example
99
+ * ```typescript
100
+ * const logger = createPail();
101
+ * logger.wrapStd();
102
+ * // Streams are wrapped
103
+ * logger.restoreStd();
104
+ * // Streams are restored to original behavior
105
+ * ```
106
+ */
107
+ restoreStd(): void;
108
+ /**
109
+ * Wraps all output sources (console and streams).
110
+ *
111
+ * Convenience method that calls both wrapConsole() and wrapStd()
112
+ * to redirect all output through the logger.
113
+ * @example
114
+ * ```typescript
115
+ * const logger = createPail();
116
+ * logger.wrapAll(); // Wraps console and streams
117
+ *
118
+ * // All output now goes through logger
119
+ * console.log("Console output");
120
+ * process.stdout.write("Stream output");
121
+ *
122
+ * logger.restoreAll(); // Restore everything
123
+ * ```
124
+ */
125
+ wrapAll(): void;
126
+ /**
127
+ * Restores all wrapped output sources.
128
+ *
129
+ * Convenience method that calls both restoreConsole() and restoreStd()
130
+ * to restore all original output behavior.
131
+ * @example
132
+ * ```typescript
133
+ * const logger = createPail();
134
+ * logger.wrapAll();
135
+ * // All output is wrapped
136
+ * logger.restoreAll();
137
+ * // All output sources are restored
138
+ * ```
139
+ */
140
+ restoreAll(): void;
141
+ /**
142
+ * Creates a single progress bar.
143
+ * @param options Configuration options for the progress bar
144
+ * @returns A new ProgressBar instance
145
+ * @example
146
+ * ```typescript
147
+ * const logger = createPail({ interactive: true });
148
+ * const bar = logger.createProgressBar({
149
+ * total: 100,
150
+ * format: 'Downloading [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}'
151
+ * });
152
+ *
153
+ * bar.start();
154
+ * // ... do work and update progress
155
+ * bar.update(50);
156
+ * bar.stop();
157
+ * ```
158
+ */
159
+ createProgressBar(options: SingleBarOptions): ProgressBar;
160
+ /**
161
+ * Creates a multi-bar progress manager for displaying multiple progress bars.
162
+ * @param options Configuration options for the multi-bar manager
163
+ * @returns A new MultiProgressBar instance
164
+ * @example
165
+ * ```typescript
166
+ * const logger = createPail({ interactive: true });
167
+ * const multiBar = logger.createMultiProgressBar();
168
+ *
169
+ * const bar1 = multiBar.create(100);
170
+ * const bar2 = multiBar.create(200);
171
+ *
172
+ * bar1.start();
173
+ * bar2.start();
174
+ * // ... update bars as needed
175
+ * multiBar.stop();
176
+ * ```
177
+ */
178
+ createMultiProgressBar(options?: MultiBarOptions): MultiProgressBar;
179
+ /**
180
+ * Creates a single spinner.
181
+ * @param options Configuration options for the spinner
182
+ * @returns A new Spinner instance
183
+ * @example
184
+ * ```typescript
185
+ * const logger = createPail({ interactive: true });
186
+ * const spinner = logger.createSpinner({ name: 'dots' });
187
+ * spinner.start('Loading...');
188
+ * // ... do work
189
+ * spinner.succeed('Done');
190
+ * ```
191
+ */
192
+ createSpinner(options?: SpinnerOptions): Spinner;
193
+ /**
194
+ * Creates a multi-spinner manager for displaying multiple spinners.
195
+ * @param options Configuration options for the multi-spinner manager
196
+ * @returns A new MultiSpinner instance
197
+ * @example
198
+ * ```typescript
199
+ * const logger = createPail({ interactive: true });
200
+ * const multiSpinner = logger.createMultiSpinner();
201
+ *
202
+ * const spinner1 = multiSpinner.create('Loading 1');
203
+ * const spinner2 = multiSpinner.create('Loading 2');
204
+ *
205
+ * spinner1.start();
206
+ * spinner2.start();
207
+ * // ... update spinners as needed
208
+ * multiSpinner.stop();
209
+ * ```
210
+ */
211
+ createMultiSpinner(options?: SpinnerOptions): MultiSpinner;
212
+ /**
213
+ * Clears the terminal screen.
214
+ *
215
+ * Sends ANSI escape sequences to clear the terminal screen and move
216
+ * the cursor to the top-left position. This overrides the browser
217
+ * implementation to work with terminal streams.
218
+ * @example
219
+ * ```typescript
220
+ * const logger = createPail();
221
+ * logger.info("Some output");
222
+ * logger.clear(); // Clears the terminal screen
223
+ * ```
224
+ */
225
+ clear(): void;
226
+ protected extendReporter(reporter: Reporter<L>): Reporter<L>;
227
+ }
228
+ 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> & {
229
+ force: Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
230
+ };
231
+ export type PailConstructor<T extends string = string, L extends string = string> = new (options?: ServerConstructorOptions<T, L>) => PailServerType<T, L>;
232
+ export declare const PailServer: PailServerType;
233
+ export {};