@visulima/cerebro 3.0.0-alpha.9 → 3.0.1

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 (96) hide show
  1. package/CHANGELOG.md +593 -0
  2. package/LICENSE.md +1295 -3950
  3. package/README.md +182 -2
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +5 -203
  6. package/dist/commands/help-command.d.ts +10 -9
  7. package/dist/commands/help-command.js +1 -3
  8. package/dist/commands/readme-command.d.ts +6 -5
  9. package/dist/commands/readme-command.js +32 -330
  10. package/dist/commands/version-command.d.ts +4 -3
  11. package/dist/commands/version-command.js +1 -18
  12. package/dist/index.d.ts +516 -95
  13. package/dist/index.js +1 -7
  14. package/dist/logger/create-pail-logger.d.ts +770 -8
  15. package/dist/logger/create-pail-logger.js +1 -34
  16. package/dist/packem_chunks/has-new-version.js +1 -259
  17. package/dist/packem_shared/Cerebro-Czc4t-75.js +4 -0
  18. package/dist/packem_shared/VERBOSITY_DEBUG-XPultrIA.js +1 -0
  19. package/dist/packem_shared/VisulimaError-C90oeIMu.js +76 -0
  20. package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +1 -0
  21. package/dist/packem_shared/cerebro-error-BjBcYVRO.js +1 -0
  22. package/dist/packem_shared/command.d-DbhtfXF4.d.ts +639 -0
  23. package/dist/packem_shared/index-DvVGK4kr.js +29 -0
  24. package/dist/packem_shared/index.d-BL4NtVR3.d.ts +127 -0
  25. package/dist/packem_shared/lazyNamed-DMUm8mZe.js +1 -0
  26. package/dist/packem_shared/renderError-B3ePOoBG-BmZlyMcr.js +25 -0
  27. package/dist/packem_shared/runtime-process-Dmz0vCJy.js +1 -0
  28. package/dist/packem_shared/split-by-case-Dbpgd7rf.js +1 -0
  29. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  30. package/dist/plugins/error-handler-plugin.js +1 -636
  31. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  32. package/dist/plugins/runtime-version-check-plugin.js +1 -77
  33. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +28 -8
  34. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -517
  35. package/dist/util/general/compile-cache.d.ts +41 -0
  36. package/dist/util/general/compile-cache.js +1 -0
  37. package/dist/util/general/heap-tuning.d.ts +18 -0
  38. package/dist/util/general/heap-tuning.js +1 -0
  39. package/package.json +53 -48
  40. package/dist/cli.d.ts +0 -203
  41. package/dist/constants.d.ts +0 -29
  42. package/dist/default-env.d.ts +0 -7
  43. package/dist/default-options.d.ts +0 -3
  44. package/dist/empty-toolbox.d.ts +0 -15
  45. package/dist/errors/cerebro-error.d.ts +0 -10
  46. package/dist/errors/command-not-found-error.d.ts +0 -9
  47. package/dist/errors/command-validation-error.d.ts +0 -10
  48. package/dist/errors/completion-error.d.ts +0 -9
  49. package/dist/errors/conflicting-options-error.d.ts +0 -10
  50. package/dist/errors/plugin-error.d.ts +0 -9
  51. package/dist/errors/update-notifier-error.d.ts +0 -7
  52. package/dist/packem_shared/Cerebro-C2mnCyQf.js +0 -3313
  53. package/dist/packem_shared/VERBOSITY_QUIET-Dp46zlLW.js +0 -10
  54. package/dist/packem_shared/VisulimaError-DA7QsCxH.js +0 -34
  55. package/dist/packem_shared/cerebro-error-GmJ3jN7Q.js +0 -16
  56. package/dist/packem_shared/help-command-BY7rQUvM.js +0 -249
  57. package/dist/packem_shared/index-C2-8b3A4.js +0 -259
  58. package/dist/packem_shared/runtime-process-B6ZplyWn.js +0 -187
  59. package/dist/plugin-manager.d.ts +0 -53
  60. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  61. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  62. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  63. package/dist/types/cli.d.ts +0 -102
  64. package/dist/types/command-line-usage.d.ts +0 -37
  65. package/dist/types/command.d.ts +0 -136
  66. package/dist/types/option-types.d.ts +0 -83
  67. package/dist/types/options.d.ts +0 -4
  68. package/dist/types/plugin.d.ts +0 -53
  69. package/dist/types/toolbox.d.ts +0 -96
  70. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  71. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  72. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  73. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  74. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  75. package/dist/util/command-line-commands.d.ts +0 -10
  76. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  77. package/dist/util/command-line-usage/index.d.ts +0 -3
  78. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  79. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  80. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  81. package/dist/util/command-processing/command-processor.d.ts +0 -37
  82. package/dist/util/command-processing/command-validation.d.ts +0 -17
  83. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  84. package/dist/util/command-processing/option-processor.d.ts +0 -44
  85. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  86. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  87. package/dist/util/general/find-alternatives.d.ts +0 -8
  88. package/dist/util/general/hide-bin.d.ts +0 -2
  89. package/dist/util/general/parse-raw-command.d.ts +0 -7
  90. package/dist/util/general/register-exception-handler.d.ts +0 -9
  91. package/dist/util/general/runtime-process.d.ts +0 -65
  92. package/dist/util/general/semver-gt.d.ts +0 -2
  93. package/dist/util/general/validate-input.d.ts +0 -24
  94. package/dist/util/process-env-variables.d.ts +0 -9
  95. package/dist/util/security.d.ts +0 -58
  96. package/dist/util/text-processing/template-format.d.ts +0 -5
@@ -1,8 +1,770 @@
1
- import type { ConstructorOptions, PailServerType } from "@visulima/pail";
2
- /**
3
- * Create a Pail logger.
4
- * @param options Optional configuration options for the logger
5
- * @returns A configured Pail logger instance
6
- */
7
- declare const createPailLogger: (options?: Partial<ConstructorOptions<string, string>>) => PailServerType<string, string>;
8
- export default createPailLogger;
1
+ import { InteractiveManager } from '@visulima/interactive-manager';
2
+ import { LiteralUnion, Primitive } from 'type-fest';
3
+ import { AnsiColors } from '@visulima/colorize';
4
+ /**
5
+ * Global namespace for extending Pail's metadata interface.
6
+ *
7
+ * This global declaration allows other packages and applications to extend
8
+ * the Meta interface with custom properties by declaring additional properties
9
+ * in the VisulimaPail.CustomMeta interface.
10
+ * @example
11
+ * ```typescript
12
+ * declare global {
13
+ * namespace VisulimaPail {
14
+ * interface CustomMeta<L> {
15
+ * userId?: string;
16
+ * requestId?: string;
17
+ * }
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ declare global {
23
+ namespace VisulimaPail {
24
+ interface CustomMeta<L> {}
25
+ }
26
+ }
27
+ /**
28
+ * Metadata object containing all information about a log entry.
29
+ *
30
+ * This interface defines the structure of metadata that is passed to reporters
31
+ * and processors. It contains all the contextual information about a log message
32
+ * including the message itself, timing information, error details, and more.
33
+ * @template L - The log level type
34
+ */
35
+ interface Meta<L> extends VisulimaPail.CustomMeta<L> {
36
+ badge: string | undefined;
37
+ context: any[] | undefined;
38
+ date: Date | string;
39
+ error: Error | undefined;
40
+ groups: string[];
41
+ label: string | undefined;
42
+ message: Primitive | ReadonlyArray<unknown> | Record<PropertyKey, unknown>;
43
+ prefix: string | undefined;
44
+ repeated?: number;
45
+ scope: string[] | undefined;
46
+ suffix: string | undefined;
47
+ traceError: Error | undefined;
48
+ type: {
49
+ level: ExtendedRfc5424LogLevels | L;
50
+ name: string;
51
+ };
52
+ }
53
+ /**
54
+ * Extended RFC 5424 Log Levels.
55
+ *
56
+ * Standard syslog severity levels as defined in RFC 5424, plus additional
57
+ * levels commonly used in modern applications. Each level has a numeric
58
+ * priority where lower numbers indicate higher severity.
59
+ * @see https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
60
+ */
61
+ type ExtendedRfc5424LogLevels = "alert" | "critical" | "debug" | "emergency" | "error" | "informational" | "notice" | "trace" | "warning";
62
+ /**
63
+ * Default Log Types.
64
+ *
65
+ * Predefined semantic log types that provide meaningful categorization
66
+ * for different kinds of log messages. Each type has associated styling
67
+ * and log level configuration.
68
+ */
69
+ type DefaultLogTypes = "alert" | "await" | "complete" | "critical" | "debug" | "emergency" | "error" | "info" | "log" | "notice" | "pending" | "start" | "stop" | "success" | "trace" | "wait" | "warn" | "warning" | "watch";
70
+ /**
71
+ * Logger Function Type.
72
+ *
73
+ * Represents a logging function that can accept either a structured Message object
74
+ * or multiple arguments in the traditional console.log style.
75
+ */
76
+ interface LoggerFunction {
77
+ (message: Message): void;
78
+ (...message: any[]): void;
79
+ }
80
+ /**
81
+ * Logger Configuration.
82
+ *
83
+ * Configuration object that defines how a specific logger type should behave,
84
+ * including its visual appearance and log level.
85
+ * @template L - The log level type
86
+ */
87
+ interface LoggerConfiguration<L extends string> {
88
+ badge?: string;
89
+ color?: AnsiColors;
90
+ label: string;
91
+ logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;
92
+ }
93
+ /**
94
+ * Logger Types Configuration.
95
+ *
96
+ * A record mapping logger type names to their configurations.
97
+ * @template T - Custom logger type names
98
+ * @template L - Log level types
99
+ */
100
+ type LoggerTypesConfig<T extends string, L extends string> = Record<T, Partial<LoggerConfiguration<L>>>;
101
+ /**
102
+ * Default Logger Types Configuration.
103
+ *
104
+ * A complete mapping of all default log types to their full configurations.
105
+ * @template L - Log level types
106
+ */
107
+
108
+ /**
109
+ * Read-only Metadata.
110
+ *
111
+ * Immutable version of the Meta interface for use in reporters.
112
+ * @template L - The log level type
113
+ */
114
+ type ReadonlyMeta<L extends string> = Readonly<Meta<L>>;
115
+ /**
116
+ * Reporter Interface.
117
+ *
118
+ * Base interface for all reporters. Reporters are responsible for
119
+ * outputting log messages to various destinations (console, files, etc.).
120
+ * @template L - The log level type
121
+ */
122
+ interface Reporter<L extends string> {
123
+ log: (meta: ReadonlyMeta<L>) => void;
124
+ }
125
+ /**
126
+ * Stream-Aware Reporter Interface.
127
+ *
128
+ * Extends Reporter with the ability to work with Node.js streams.
129
+ * Used for server-side reporters that need to write to stdout/stderr.
130
+ * @template L - The log level type
131
+ */
132
+
133
+ /**
134
+ * Processor Interface.
135
+ *
136
+ * Base interface for all processors. Processors can modify or enhance
137
+ * log metadata before it reaches reporters.
138
+ * @template L - The log level type
139
+ */
140
+ interface Processor<L extends string> {
141
+ /** Process the log metadata */
142
+ process: (meta: Meta<L>) => Meta<L>;
143
+ }
144
+ interface ConstructorOptions<T extends string, L extends string> {
145
+ disabled?: boolean;
146
+ logLevel?: LiteralUnion<ExtendedRfc5424LogLevels, L>;
147
+ logLevels?: Partial<Record<ExtendedRfc5424LogLevels, number>> & Record<L, number>;
148
+ messages?: {
149
+ timerEnd?: string;
150
+ timerStart?: string;
151
+ };
152
+ processors?: Processor<L>[];
153
+ rawReporter?: Reporter<L>;
154
+ reporters?: Reporter<L>[];
155
+ scope?: string[] | string;
156
+ throttle?: number;
157
+ throttleMin?: number;
158
+ types?: LoggerTypesConfig<T, L> & Partial<LoggerTypesConfig<DefaultLogTypes, L>>;
159
+ }
160
+ interface ServerConstructorOptions<T extends string, L extends string> extends ConstructorOptions<T, L> {
161
+ interactive?: boolean;
162
+ stderr: NodeJS.WriteStream;
163
+ stdout: NodeJS.WriteStream;
164
+ }
165
+ type Message = {
166
+ context?: any[];
167
+ message: any;
168
+ prefix?: string;
169
+ suffix?: string;
170
+ };
171
+ type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object);
172
+ declare function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined;
173
+ declare function stringify(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer, space?: string | number): string;
174
+ declare function stringify(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined;
175
+ declare namespace stringify {
176
+ export function configure(options: StringifyOptions): typeof stringify;
177
+ }
178
+ interface StringifyOptions {
179
+ bigint?: boolean;
180
+ circularValue?: string | null | TypeErrorConstructor | ErrorConstructor;
181
+ deterministic?: boolean | ((a: string, b: string) => number);
182
+ maximumBreadth?: number;
183
+ maximumDepth?: number;
184
+ strict?: boolean;
185
+ }
186
+ /**
187
+ * Pail Browser Implementation.
188
+ *
189
+ * A comprehensive logging library for browser environments with support for
190
+ * multiple log levels, custom types, processors, reporters, and advanced features
191
+ * like throttling, scoping, timers, and counters.
192
+ * @template T - Custom logger types (string union)
193
+ * @template L - Log level types (string union)
194
+ * @example
195
+ * ```typescript
196
+ * const logger = new PailBrowserImpl({
197
+ * logLevel: "debug",
198
+ * types: {
199
+ * http: { color: "blue", label: "HTTP", logLevel: "info" }
200
+ * },
201
+ * reporters: [new JsonReporter()]
202
+ * });
203
+ *
204
+ * logger.info("Application started");
205
+ * logger.http("GET /api/users 200");
206
+ * logger.error("Something went wrong", error);
207
+ * ```
208
+ */
209
+ declare class PailBrowserImpl<T extends string = string, L extends string = string> {
210
+ #private;
211
+ protected readonly lastLog: {
212
+ count?: number;
213
+ object?: Meta<L>;
214
+ signature?: string;
215
+ time?: Date;
216
+ timeout?: ReturnType<typeof setTimeout>;
217
+ };
218
+ protected readonly logLevels: Record<string, number>;
219
+ protected disabled: boolean;
220
+ protected paused: boolean;
221
+ protected messageQueue: {
222
+ messageObject: any[];
223
+ raw: boolean;
224
+ type: LiteralUnion<DefaultLogTypes, T>;
225
+ }[];
226
+ protected scopeName: string[];
227
+ protected readonly types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
228
+ protected readonly longestLabel: string;
229
+ protected readonly processors: Set<Processor<L>>;
230
+ protected readonly generalLogLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;
231
+ protected reporters: Set<Reporter<L>>;
232
+ protected readonly throttle: number;
233
+ protected readonly throttleMin: number;
234
+ protected readonly stringify: typeof stringify;
235
+ protected groups: string[];
236
+ protected readonly startTimerMessage: string;
237
+ protected readonly endTimerMessage: string;
238
+ protected rawReporter: Reporter<L>;
239
+ protected force: Record<string, LoggerFunction>;
240
+ /**
241
+ * Creates a new Pail browser logger instance.
242
+ *
243
+ * Initializes the logger with the provided configuration options,
244
+ * setting up reporters, processors, log levels, and other internal state.
245
+ * @param options Configuration options for the logger
246
+ */
247
+ constructor(options: ConstructorOptions<T, L>);
248
+ /**
249
+ * Wraps the global console methods to redirect them through the logger.
250
+ *
251
+ * This method replaces console methods (log, info, warn, error, etc.) with
252
+ * calls to the corresponding logger methods. The original console methods
253
+ * are backed up and can be restored using restoreConsole().
254
+ * @example
255
+ * ```typescript
256
+ * const logger = createPail();
257
+ * logger.wrapConsole();
258
+ *
259
+ * console.log("This will go through the logger");
260
+ * console.error("This too!");
261
+ *
262
+ * logger.restoreConsole(); // Restore original console methods
263
+ * ```
264
+ */
265
+ wrapConsole(): void;
266
+ /**
267
+ * Restores the original global console methods.
268
+ *
269
+ * This method restores the console methods that were backed up by wrapConsole().
270
+ * After calling this, console methods will work as they did before wrapping.
271
+ * @example
272
+ * ```typescript
273
+ * const logger = createPail();
274
+ * logger.wrapConsole();
275
+ *
276
+ * // Console methods are now wrapped
277
+ * logger.restoreConsole();
278
+ * // Console methods are restored to original behavior
279
+ * ```
280
+ */
281
+ restoreConsole(): void;
282
+ /**
283
+ * Wraps uncaught exception and unhandled rejection handlers.
284
+ *
285
+ * This method sets up global error handlers that will log uncaught exceptions
286
+ * and unhandled promise rejections through the logger. This is useful for
287
+ * capturing and logging application crashes.
288
+ * @example
289
+ * ```typescript
290
+ * const logger = createPail();
291
+ * logger.wrapException();
292
+ *
293
+ * // Now uncaught errors will be logged
294
+ * throw new Error("This will be logged");
295
+ * ```
296
+ */
297
+ wrapException(): void;
298
+ /**
299
+ * Removes the global exception/rejection handlers installed by {@link wrapException}.
300
+ *
301
+ * Counterpart to `wrapException()` (mirrors `wrapConsole()`/`restoreConsole()`).
302
+ * Safe to call when no handlers are installed.
303
+ * @example
304
+ * ```typescript
305
+ * const logger = createPail();
306
+ * logger.wrapException();
307
+ * // ... later ...
308
+ * logger.restoreException(); // global handlers removed
309
+ * ```
310
+ */
311
+ restoreException(): void;
312
+ /**
313
+ * Disables all logging output.
314
+ *
315
+ * When disabled, all log calls will be silently ignored and no output
316
+ * will be produced by any reporters. This can be useful for temporarily
317
+ * suppressing log output in production or during testing.
318
+ * @example
319
+ * ```typescript
320
+ * const logger = createPail();
321
+ * logger.disable();
322
+ * logger.info("This won't be logged"); // Silent
323
+ * logger.enable();
324
+ * logger.info("This will be logged"); // Output produced
325
+ * ```
326
+ */
327
+ disable(): void;
328
+ /**
329
+ * Enables logging output.
330
+ *
331
+ * Re-enables logging after it has been disabled. All subsequent log calls
332
+ * will produce output according to the configured reporters.
333
+ * @example
334
+ * ```typescript
335
+ * const logger = createPail();
336
+ * logger.disable();
337
+ * logger.info("This won't be logged");
338
+ * logger.enable(); // Re-enable logging
339
+ * logger.info("This will be logged");
340
+ * ```
341
+ */
342
+ enable(): void;
343
+ /**
344
+ * Checks if logging is currently enabled.
345
+ *
346
+ * Returns true if logging is enabled and false if it has been disabled.
347
+ * @returns True if logging is enabled, false if disabled
348
+ * @example
349
+ * ```typescript
350
+ * const logger = createPail();
351
+ * console.log(logger.isEnabled()); // true
352
+ * logger.disable();
353
+ * console.log(logger.isEnabled()); // false
354
+ * ```
355
+ */
356
+ isEnabled(): boolean;
357
+ /**
358
+ * Pauses logging and starts queuing messages.
359
+ *
360
+ * When paused, all log calls will be queued instead of being output immediately.
361
+ * The queued messages will be processed when resume() is called. This is useful
362
+ * for temporarily buffering log output during critical operations.
363
+ * @example
364
+ * ```typescript
365
+ * const logger = createPail();
366
+ * logger.pause();
367
+ * logger.info("This will be queued"); // Queued, not output yet
368
+ * logger.warn("This too"); // Also queued
369
+ * logger.resume(); // Now both messages are output
370
+ * ```
371
+ */
372
+ pause(): void;
373
+ /**
374
+ * Resumes logging and flushes all queued messages.
375
+ *
376
+ * Processes all messages that were queued during the pause period and
377
+ * resumes normal logging behavior. Messages are output in the order
378
+ * they were originally called.
379
+ * @example
380
+ * ```typescript
381
+ * const logger = createPail();
382
+ * logger.pause();
383
+ * logger.info("Message 1"); // Queued
384
+ * logger.info("Message 2"); // Queued
385
+ * logger.resume(); // Both messages are now output in order
386
+ * logger.info("Message 3"); // Output immediately
387
+ * ```
388
+ */
389
+ resume(): void;
390
+ /**
391
+ * Creates a scoped logger instance.
392
+ *
393
+ * Returns a new logger instance that inherits all configuration but adds
394
+ * the specified scope names to all log messages. This is useful for
395
+ * categorizing logs by component, module, or feature.
396
+ * @template N - The new custom logger type names
397
+ * @param name Scope names to apply to all log messages
398
+ * @returns A new scoped logger instance
399
+ * @throws {Error} If no scope name is provided
400
+ * @example
401
+ * ```typescript
402
+ * const logger = createPail();
403
+ * const scopedLogger = logger.scope("auth", "login");
404
+ * scopedLogger.info("User logged in"); // Will include scope: ["auth", "login"]
405
+ * ```
406
+ */
407
+ scope<N extends string = T>(...name: string[]): PailBrowserType<N, L>;
408
+ /**
409
+ * Removes the current scope from the logger.
410
+ *
411
+ * Clears all scope names that were set by previous scope() calls.
412
+ * After calling this, log messages will no longer include scope information.
413
+ * @example
414
+ * ```typescript
415
+ * const logger = createPail();
416
+ * const scopedLogger = logger.scope("auth");
417
+ * scopedLogger.info("Scoped message"); // Has scope
418
+ * scopedLogger.unscope();
419
+ * scopedLogger.info("Unscoped message"); // No scope
420
+ * ```
421
+ */
422
+ unscope(): void;
423
+ /**
424
+ * Creates a child logger that inherits settings from the parent.
425
+ *
426
+ * Returns a new logger instance that inherits all configuration from the parent
427
+ * (reporters, processors, types, log levels, throttle settings, etc.) while allowing
428
+ * you to override only what you need. Child loggers are independent instances with
429
+ * their own state (timers, counters, etc.).
430
+ * @template N - The new custom logger type names
431
+ * @template LC - The new log level types
432
+ * @param options Configuration options to override or extend parent settings
433
+ * @returns A new child logger instance
434
+ * @example
435
+ * ```typescript
436
+ * const parent = createPail({
437
+ * logLevel: "info",
438
+ * types: { http: { label: "HTTP", logLevel: "info" } },
439
+ * reporters: [new PrettyReporter()],
440
+ * });
441
+ *
442
+ * // Child inherits parent settings but overrides log level
443
+ * const child = parent.child({ logLevel: "debug" });
444
+ * child.info("This will be logged"); // Uses debug level from child
445
+ * child.http("GET /api 200"); // Inherits http type from parent
446
+ *
447
+ * // Child can add new types
448
+ * const childWithNewType = parent.child({
449
+ * types: { db: { label: "DB", logLevel: "info" } },
450
+ * });
451
+ * childWithNewType.db("Query executed"); // New type available
452
+ * ```
453
+ */
454
+ child<N extends string = T, LC extends string = L>(options?: Partial<ConstructorOptions<N, LC>>): PailBrowserType<N, LC>;
455
+ /**
456
+ * Starts a timer with the specified label.
457
+ *
458
+ * Records the current timestamp and associates it with the given label.
459
+ * Multiple timers can be active simultaneously with different labels.
460
+ * @param label The timer label (defaults to "default")
461
+ * @example
462
+ * ```typescript
463
+ * const logger = createPail();
464
+ * logger.time("operation");
465
+ * // ... some operation ...
466
+ * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
467
+ * ```
468
+ */
469
+ time(label?: string): void;
470
+ /**
471
+ * Logs the current elapsed time for a timer without stopping it.
472
+ *
473
+ * Calculates and logs the time elapsed since the timer was started,
474
+ * but keeps the timer running. If no label is provided, uses the
475
+ * most recently started timer.
476
+ * @param label The timer label (uses last timer if not specified)
477
+ * @param data Additional data to include in the log message
478
+ * @example
479
+ * ```typescript
480
+ * const logger = createPail();
481
+ * logger.time("task");
482
+ * // ... some work ...
483
+ * logger.timeLog("task"); // Logs current elapsed time
484
+ * // ... more work ...
485
+ * logger.timeEnd("task"); // Logs final time and stops timer
486
+ * ```
487
+ */
488
+ timeLog(label?: string, ...data: unknown[]): void;
489
+ /**
490
+ * Stops a timer and logs the final elapsed time.
491
+ *
492
+ * Calculates the total time elapsed since the timer was started,
493
+ * logs the result, and removes the timer. If no label is provided,
494
+ * uses the most recently started timer.
495
+ * @param label The timer label (uses last timer if not specified)
496
+ * @example
497
+ * ```typescript
498
+ * const logger = createPail();
499
+ * logger.time("operation");
500
+ * // ... perform operation ...
501
+ * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
502
+ * ```
503
+ */
504
+ timeEnd(label?: string): void;
505
+ /**
506
+ * Starts a log group with the specified label.
507
+ *
508
+ * Groups related log messages together. In browser environments,
509
+ * this uses the native console.group() functionality. In other
510
+ * environments, it tracks group nesting internally.
511
+ * @param label The group label (defaults to "console.group")
512
+ * @example
513
+ * ```typescript
514
+ * const logger = createPail();
515
+ * logger.group("Database Operations");
516
+ * logger.info("Connecting to database");
517
+ * logger.info("Running migration");
518
+ * logger.groupEnd(); // End the group
519
+ * ```
520
+ */
521
+ group(label?: string): void;
522
+ /**
523
+ * Ends the current log group.
524
+ *
525
+ * Closes the most recently opened log group. In browser environments,
526
+ * this uses the native console.groupEnd() functionality.
527
+ * @example
528
+ * ```typescript
529
+ * const logger = createPail();
530
+ * logger.group("Processing");
531
+ * logger.info("Step 1");
532
+ * logger.info("Step 2");
533
+ * logger.groupEnd(); // Closes the "Processing" group
534
+ * ```
535
+ */
536
+ groupEnd(): void;
537
+ /**
538
+ * Increments and logs a counter with the specified label.
539
+ *
540
+ * Maintains an internal counter for each label and logs the current count
541
+ * each time it's called. Useful for tracking how many times certain
542
+ * code paths are executed.
543
+ * @param label The counter label (defaults to "default")
544
+ * @example
545
+ * ```typescript
546
+ * const logger = createPail();
547
+ * logger.count("requests"); // Logs: "requests: 1"
548
+ * logger.count("requests"); // Logs: "requests: 2"
549
+ * logger.count("errors"); // Logs: "errors: 1"
550
+ * ```
551
+ */
552
+ count(label?: string): void;
553
+ /**
554
+ * Resets a counter to zero.
555
+ *
556
+ * Removes the counter with the specified label, effectively resetting
557
+ * it to zero. If the counter doesn't exist, logs a warning.
558
+ * @param label The counter label to reset (defaults to "default")
559
+ * @example
560
+ * ```typescript
561
+ * const logger = createPail();
562
+ * logger.count("requests"); // Logs: "requests: 1"
563
+ * logger.countReset("requests"); // Resets counter
564
+ * logger.count("requests"); // Logs: "requests: 1" (starts over)
565
+ * ```
566
+ */
567
+ countReset(label?: string): void;
568
+ /**
569
+ * Clears the console output.
570
+ *
571
+ * Calls the native console.clear() method to clear all output from
572
+ * the console. This is a convenience method that wraps the native
573
+ * console.clear() functionality.
574
+ * @example
575
+ * ```typescript
576
+ * const logger = createPail();
577
+ * logger.info("Some message");
578
+ * logger.clear(); // Clears the console
579
+ * ```
580
+ */
581
+ clear(): void;
582
+ /**
583
+ * Logs a raw message bypassing normal processing.
584
+ *
585
+ * Sends a message directly to the raw reporter without going through
586
+ * the normal logging pipeline (processors, throttling, etc.). This is
587
+ * useful for logging that needs to bypass all formatting and processing.
588
+ * @param message The raw message to log
589
+ * @param arguments_ Additional arguments to include
590
+ * @example
591
+ * ```typescript
592
+ * const logger = createPail();
593
+ * logger.raw("Direct message", { data: "value" });
594
+ * ```
595
+ */
596
+ raw(message: string, ...arguments_: unknown[]): void;
597
+ protected extendReporter(reporter: Reporter<L>): Reporter<L>;
598
+ protected registerReporters(reporters: Reporter<L>[]): void;
599
+ protected registerProcessors(processors: Processor<L>[]): void;
600
+ protected logger(type: LiteralUnion<DefaultLogTypes, T>, raw: boolean, force: boolean, ...messageObject: unknown[]): void;
601
+ }
602
+ 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> & {
603
+ force: Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
604
+ };
605
+ declare class PailServerImpl<T extends string = string, L extends string = string> extends PailBrowserImpl<T, L> {
606
+ #private;
607
+ readonly options: ServerConstructorOptions<T, L>;
608
+ protected readonly stdout: NodeJS.WriteStream;
609
+ protected readonly stderr: NodeJS.WriteStream;
610
+ protected interactiveManager: InteractiveManager | undefined;
611
+ protected readonly interactive: boolean;
612
+ /**
613
+ * Creates a new Pail server logger instance.
614
+ *
615
+ * Initializes the server-compatible logger with streams, interactive support,
616
+ * and server-specific configuration options.
617
+ * @param options Server-specific configuration options
618
+ */
619
+ constructor(options: ServerConstructorOptions<T, L>);
620
+ override scope<N extends string = T>(...name: string[]): PailServerType<N, L>;
621
+ /**
622
+ * Creates a child logger that inherits settings from the parent.
623
+ *
624
+ * Returns a new logger instance that inherits all configuration from the parent
625
+ * (reporters, processors, types, log levels, throttle settings, etc.) while allowing
626
+ * you to override only what you need. Child loggers are independent instances with
627
+ * their own state (timers, counters, etc.).
628
+ * @template N - The new custom logger type names
629
+ * @template LC - The new log level types
630
+ * @param options Configuration options to override or extend parent settings
631
+ * @returns A new child logger instance
632
+ * @example
633
+ * ```typescript
634
+ * const parent = createPail({
635
+ * logLevel: "info",
636
+ * types: { http: { label: "HTTP", logLevel: "info" } },
637
+ * reporters: [new PrettyReporter()],
638
+ * });
639
+ *
640
+ * // Child inherits parent settings but overrides log level
641
+ * const child = parent.child({ logLevel: "debug" });
642
+ * child.info("This will be logged"); // Uses debug level from child
643
+ * child.http("GET /api 200"); // Inherits http type from parent
644
+ *
645
+ * // Child can add new types
646
+ * const childWithNewType = parent.child({
647
+ * types: { db: { label: "DB", logLevel: "info" } },
648
+ * });
649
+ * childWithNewType.db("Query executed"); // New type available
650
+ * ```
651
+ */
652
+ override 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>;
653
+ /**
654
+ * Gets the interactive manager instance if interactive mode is enabled.
655
+ *
656
+ * Returns the InteractiveManager instance that handles interactive terminal
657
+ * features like progress bars and dynamic updates. Only available when
658
+ * interactive mode is enabled in the constructor options.
659
+ * @returns The interactive manager instance, or undefined if not in interactive mode
660
+ * @example
661
+ * ```typescript
662
+ * const logger = createPail({ interactive: true });
663
+ * const manager = logger.getInteractiveManager();
664
+ * if (manager) {
665
+ * manager.hook();
666
+ * // Use interactive features
667
+ * manager.unhook();
668
+ * }
669
+ * ```
670
+ */
671
+ getInteractiveManager(): InteractiveManager | undefined;
672
+ /**
673
+ * Wraps stdout and stderr streams to redirect them through the logger.
674
+ *
675
+ * Intercepts writes to process.stdout and process.stderr, redirecting them
676
+ * through the logger instead of writing directly to the streams. This allows
677
+ * all output to be processed by the logging pipeline.
678
+ * @example
679
+ * ```typescript
680
+ * const logger = createPail();
681
+ * logger.wrapStd();
682
+ *
683
+ * console.log("This goes through logger");
684
+ * process.stdout.write("This too");
685
+ *
686
+ * logger.restoreStd(); // Restore original streams
687
+ * ```
688
+ */
689
+ wrapStd(): void;
690
+ /**
691
+ * Restores the original stdout and stderr streams.
692
+ *
693
+ * Removes the stream wrapping that was applied by wrapStd(),
694
+ * restoring the original stream write methods.
695
+ * @example
696
+ * ```typescript
697
+ * const logger = createPail();
698
+ * logger.wrapStd();
699
+ * // Streams are wrapped
700
+ * logger.restoreStd();
701
+ * // Streams are restored to original behavior
702
+ * ```
703
+ */
704
+ restoreStd(): void;
705
+ /**
706
+ * Wraps all output sources (console and streams).
707
+ *
708
+ * Convenience method that calls both wrapConsole() and wrapStd()
709
+ * to redirect all output through the logger.
710
+ * @example
711
+ * ```typescript
712
+ * const logger = createPail();
713
+ * logger.wrapAll(); // Wraps console and streams
714
+ *
715
+ * // All output now goes through logger
716
+ * console.log("Console output");
717
+ * process.stdout.write("Stream output");
718
+ *
719
+ * logger.restoreAll(); // Restore everything
720
+ * ```
721
+ */
722
+ wrapAll(): void;
723
+ /**
724
+ * Restores all wrapped output sources.
725
+ *
726
+ * Convenience method that calls both restoreConsole() and restoreStd()
727
+ * to restore all original output behavior.
728
+ * @example
729
+ * ```typescript
730
+ * const logger = createPail();
731
+ * logger.wrapAll();
732
+ * // All output is wrapped
733
+ * logger.restoreAll();
734
+ * // All output sources are restored
735
+ * ```
736
+ */
737
+ restoreAll(): void;
738
+ /**
739
+ * Clears the terminal screen.
740
+ *
741
+ * Sends ANSI escape sequences to clear the terminal screen and move
742
+ * the cursor to the top-left position. This overrides the browser
743
+ * implementation to work with terminal streams.
744
+ * @example
745
+ * ```typescript
746
+ * const logger = createPail();
747
+ * logger.info("Some output");
748
+ * logger.clear(); // Clears the terminal screen
749
+ * ```
750
+ */
751
+ override clear(): void;
752
+ protected override extendReporter(reporter: Reporter<L>): Reporter<L>;
753
+ }
754
+ 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> & {
755
+ force: Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
756
+ };
757
+ /**
758
+ * Options for creating a PailError.
759
+ *
760
+ * Extends standard error properties with self-documenting fields
761
+ * that provide actionable context for debugging, particularly useful
762
+ * for AI-assisted log analysis.
763
+ */
764
+ /**
765
+ * Create a Pail logger.
766
+ * @param options Optional configuration options for the logger
767
+ * @returns A configured Pail logger instance
768
+ */
769
+ declare const createPailLogger: (options?: Partial<ConstructorOptions<string, string>>) => PailServerType;
770
+ export { createPailLogger as default };