@visulima/pail 4.0.2 → 4.1.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 (83) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE.md +346 -0
  3. package/README.md +17 -0
  4. package/dist/error.d.ts +69 -69
  5. package/dist/index.browser.d.ts +446 -445
  6. package/dist/index.browser.js +17 -17
  7. package/dist/index.server.d.ts +582 -582
  8. package/dist/index.server.js +27 -27
  9. package/dist/middleware/elysia.d.ts +44 -42
  10. package/dist/middleware/elysia.js +1 -1
  11. package/dist/middleware/express.d.ts +58 -59
  12. package/dist/middleware/express.js +1 -1
  13. package/dist/middleware/fastify.d.ts +55 -56
  14. package/dist/middleware/fastify.js +1 -1
  15. package/dist/middleware/hono.d.ts +56 -57
  16. package/dist/middleware/hono.js +1 -1
  17. package/dist/middleware/next/handler.d.ts +67 -68
  18. package/dist/middleware/next/handler.js +1 -1
  19. package/dist/middleware/sveltekit.d.ts +72 -73
  20. package/dist/middleware/sveltekit.js +1 -1
  21. package/dist/object-tree.d.ts +44 -44
  22. package/dist/packem_shared/AbstractJsonReporter-BpWRnN0L.js +1 -0
  23. package/dist/packem_shared/AbstractJsonReporter-DxZwImm5.js +1 -0
  24. package/dist/packem_shared/JsonReporter-9IcELa1m.js +2 -0
  25. package/dist/packem_shared/JsonReporter-Dd3kuj8X.js +1 -0
  26. package/dist/packem_shared/{PrettyReporter-DsHfKOU7.js → PrettyReporter-BUWNEg3_.js} +1 -1
  27. package/dist/packem_shared/{PrettyReporter-CcDdPQSt.js → PrettyReporter-DbgD89ck.js} +56 -30
  28. package/dist/packem_shared/abstract-json-reporter.d-B6NoO-hG.d.ts +61 -0
  29. package/dist/packem_shared/{abstract-pretty-reporter-DrLBJ6ds.js → abstract-pretty-reporter-CyfTvmKf.js} +41 -39
  30. package/dist/packem_shared/create-middleware-logger.d-BRkkBMlk.d.ts +47 -0
  31. package/dist/packem_shared/headers-DI58djdG.js +1 -0
  32. package/dist/packem_shared/index-CbkPnylC.js +1 -0
  33. package/dist/packem_shared/serializeError-52C4oiKx-CrnRcq9R.js +1 -0
  34. package/dist/packem_shared/storage-DVcJumyk.js +1 -0
  35. package/dist/packem_shared/types.d-4ge_rME4.d.ts +246 -0
  36. package/dist/packem_shared/{types.d-Cz9S7jZh.d.ts → types.d-BW8kAXUv.d.ts} +95 -95
  37. package/dist/packem_shared/types.d-DGHeA2iJ.d.ts +194 -0
  38. package/dist/packem_shared/useLogger-7p55yvvc.js +1 -0
  39. package/dist/packem_shared/wide-event.d-BMLastMR.d.ts +716 -0
  40. package/dist/packem_shared/write-stream-ytl_vhg_.js +1 -0
  41. package/dist/processor/caller/caller-processor.d.ts +32 -33
  42. package/dist/processor/environment-processor.d.ts +83 -84
  43. package/dist/processor/message-formatter-processor.d.ts +40 -45
  44. package/dist/processor/message-formatter-processor.js +1 -1
  45. package/dist/processor/opentelemetry-processor.d.ts +51 -52
  46. package/dist/processor/redact-processor.d.ts +57 -65
  47. package/dist/processor/sampling-processor.d.ts +90 -91
  48. package/dist/reporter/file/json-file-reporter.d.ts +77 -78
  49. package/dist/reporter/file/json-file-reporter.js +1 -1
  50. package/dist/reporter/http/abstract-http-reporter.d.ts +125 -121
  51. package/dist/reporter/http/abstract-http-reporter.js +2 -2
  52. package/dist/reporter/http/http-reporter.d.ts +33 -34
  53. package/dist/reporter/http/http-reporter.edge-light.d.ts +235 -230
  54. package/dist/reporter/http/http-reporter.edge-light.js +2 -2
  55. package/dist/reporter/json/index.browser.d.ts +62 -61
  56. package/dist/reporter/json/index.browser.js +1 -1
  57. package/dist/reporter/json/index.d.ts +36 -37
  58. package/dist/reporter/json/index.js +1 -1
  59. package/dist/reporter/pretty/index.browser.d.ts +57 -56
  60. package/dist/reporter/pretty/index.browser.js +1 -1
  61. package/dist/reporter/pretty/index.d.ts +133 -133
  62. package/dist/reporter/pretty/index.js +1 -1
  63. package/dist/reporter/simple/simple-reporter.server.d.ts +91 -90
  64. package/dist/reporter/simple/simple-reporter.server.js +7 -7
  65. package/dist/wide-event.d.ts +2 -3
  66. package/dist/wide-event.js +1 -1
  67. package/package.json +58 -37
  68. package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +0 -1
  69. package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +0 -1
  70. package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +0 -2
  71. package/dist/packem_shared/JsonReporter-bmem9lcg.js +0 -1
  72. package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +0 -62
  73. package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +0 -25
  74. package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +0 -47
  75. package/dist/packem_shared/headers-DH0H2s8W.js +0 -1
  76. package/dist/packem_shared/index-Q1764hvO.js +0 -1
  77. package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +0 -1
  78. package/dist/packem_shared/storage-DaXAlpiO.js +0 -1
  79. package/dist/packem_shared/types.d-bWnqHJKL.d.ts +0 -211
  80. package/dist/packem_shared/types.d-xxE3FOD3.d.ts +0 -229
  81. package/dist/packem_shared/useLogger-DB34CuU5.js +0 -1
  82. package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +0 -717
  83. package/dist/packem_shared/write-stream-C7jxLxIT.js +0 -1
@@ -1,31 +1,32 @@
1
1
  import { s as stringify } from "./packem_shared/index.d-T71KjNAr.js";
2
- import { C as ConstructorOptions, M as Meta, D as DefaultLogTypes, L as LiteralUnion, a as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, c as Reporter, d as LoggerFunction } from "./packem_shared/types.d-xxE3FOD3.js";
3
- export type { e as DefaultLoggerTypes, f as LoggerConfiguration, b as LoggerTypesAwareReporter, g as StreamAwareReporter } from "./packem_shared/types.d-xxE3FOD3.js";
2
+ import { LiteralUnion } from 'type-fest';
3
+ import { C as ConstructorOptions, M as Meta, D as DefaultLogTypes, L as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, b as Reporter, c as LoggerFunction } from "./packem_shared/types.d-DGHeA2iJ.js";
4
+ export type { d as DefaultLoggerTypes, e as LoggerConfiguration, a as LoggerTypesAwareReporter, f as StreamAwareReporter } from "./packem_shared/types.d-DGHeA2iJ.js";
4
5
  import '@visulima/colorize';
5
6
  import '@visulima/interactive-manager';
6
7
  /**
7
- * Pail Browser Implementation.
8
- *
9
- * A comprehensive logging library for browser environments with support for
10
- * multiple log levels, custom types, processors, reporters, and advanced features
11
- * like throttling, scoping, timers, and counters.
12
- * @template T - Custom logger types (string union)
13
- * @template L - Log level types (string union)
14
- * @example
15
- * ```typescript
16
- * const logger = new PailBrowserImpl({
17
- * logLevel: "debug",
18
- * types: {
19
- * http: { color: "blue", label: "HTTP", logLevel: "info" }
20
- * },
21
- * reporters: [new JsonReporter()]
22
- * });
23
- *
24
- * logger.info("Application started");
25
- * logger.http("GET /api/users 200");
26
- * logger.error("Something went wrong", error);
27
- * ```
28
- */
8
+ * Pail Browser Implementation.
9
+ *
10
+ * A comprehensive logging library for browser environments with support for
11
+ * multiple log levels, custom types, processors, reporters, and advanced features
12
+ * like throttling, scoping, timers, and counters.
13
+ * @template T - Custom logger types (string union)
14
+ * @template L - Log level types (string union)
15
+ * @example
16
+ * ```typescript
17
+ * const logger = new PailBrowserImpl({
18
+ * logLevel: "debug",
19
+ * types: {
20
+ * http: { color: "blue", label: "HTTP", logLevel: "info" }
21
+ * },
22
+ * reporters: [new JsonReporter()]
23
+ * });
24
+ *
25
+ * logger.info("Application started");
26
+ * logger.http("GET /api/users 200");
27
+ * logger.error("Something went wrong", error);
28
+ * ```
29
+ */
29
30
  declare class PailBrowserImpl<T extends string = string, L extends string = string> {
30
31
  #private;
31
32
  protected readonly lastLog: {
@@ -58,361 +59,361 @@ declare class PailBrowserImpl<T extends string = string, L extends string = stri
58
59
  protected rawReporter: Reporter<L>;
59
60
  protected force: Record<string, LoggerFunction>;
60
61
  /**
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
- */
62
+ * Creates a new Pail browser logger instance.
63
+ *
64
+ * Initializes the logger with the provided configuration options,
65
+ * setting up reporters, processors, log levels, and other internal state.
66
+ * @param options Configuration options for the logger
67
+ */
67
68
  constructor(options: ConstructorOptions<T, L>);
68
69
  /**
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
- */
70
+ * Wraps the global console methods to redirect them through the logger.
71
+ *
72
+ * This method replaces console methods (log, info, warn, error, etc.) with
73
+ * calls to the corresponding logger methods. The original console methods
74
+ * are backed up and can be restored using restoreConsole().
75
+ * @example
76
+ * ```typescript
77
+ * const logger = createPail();
78
+ * logger.wrapConsole();
79
+ *
80
+ * console.log("This will go through the logger");
81
+ * console.error("This too!");
82
+ *
83
+ * logger.restoreConsole(); // Restore original console methods
84
+ * ```
85
+ */
85
86
  wrapConsole(): void;
86
87
  /**
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
- */
88
+ * Restores the original global console methods.
89
+ *
90
+ * This method restores the console methods that were backed up by wrapConsole().
91
+ * After calling this, console methods will work as they did before wrapping.
92
+ * @example
93
+ * ```typescript
94
+ * const logger = createPail();
95
+ * logger.wrapConsole();
96
+ *
97
+ * // Console methods are now wrapped
98
+ * logger.restoreConsole();
99
+ * // Console methods are restored to original behavior
100
+ * ```
101
+ */
101
102
  restoreConsole(): void;
102
103
  /**
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
- */
104
+ * Wraps uncaught exception and unhandled rejection handlers.
105
+ *
106
+ * This method sets up global error handlers that will log uncaught exceptions
107
+ * and unhandled promise rejections through the logger. This is useful for
108
+ * capturing and logging application crashes.
109
+ * @example
110
+ * ```typescript
111
+ * const logger = createPail();
112
+ * logger.wrapException();
113
+ *
114
+ * // Now uncaught errors will be logged
115
+ * throw new Error("This will be logged");
116
+ * ```
117
+ */
117
118
  wrapException(): void;
118
119
  /**
119
- * Removes the global exception/rejection handlers installed by {@link wrapException}.
120
- *
121
- * Counterpart to `wrapException()` (mirrors `wrapConsole()`/`restoreConsole()`).
122
- * Safe to call when no handlers are installed.
123
- * @example
124
- * ```typescript
125
- * const logger = createPail();
126
- * logger.wrapException();
127
- * // ... later ...
128
- * logger.restoreException(); // global handlers removed
129
- * ```
130
- */
120
+ * Removes the global exception/rejection handlers installed by {@link wrapException}.
121
+ *
122
+ * Counterpart to `wrapException()` (mirrors `wrapConsole()`/`restoreConsole()`).
123
+ * Safe to call when no handlers are installed.
124
+ * @example
125
+ * ```typescript
126
+ * const logger = createPail();
127
+ * logger.wrapException();
128
+ * // ... later ...
129
+ * logger.restoreException(); // global handlers removed
130
+ * ```
131
+ */
131
132
  restoreException(): void;
132
133
  /**
133
- * Disables all logging output.
134
- *
135
- * When disabled, all log calls will be silently ignored and no output
136
- * will be produced by any reporters. This can be useful for temporarily
137
- * suppressing log output in production or during testing.
138
- * @example
139
- * ```typescript
140
- * const logger = createPail();
141
- * logger.disable();
142
- * logger.info("This won't be logged"); // Silent
143
- * logger.enable();
144
- * logger.info("This will be logged"); // Output produced
145
- * ```
146
- */
134
+ * Disables all logging output.
135
+ *
136
+ * When disabled, all log calls will be silently ignored and no output
137
+ * will be produced by any reporters. This can be useful for temporarily
138
+ * suppressing log output in production or during testing.
139
+ * @example
140
+ * ```typescript
141
+ * const logger = createPail();
142
+ * logger.disable();
143
+ * logger.info("This won't be logged"); // Silent
144
+ * logger.enable();
145
+ * logger.info("This will be logged"); // Output produced
146
+ * ```
147
+ */
147
148
  disable(): void;
148
149
  /**
149
- * Enables logging output.
150
- *
151
- * Re-enables logging after it has been disabled. All subsequent log calls
152
- * will produce output according to the configured reporters.
153
- * @example
154
- * ```typescript
155
- * const logger = createPail();
156
- * logger.disable();
157
- * logger.info("This won't be logged");
158
- * logger.enable(); // Re-enable logging
159
- * logger.info("This will be logged");
160
- * ```
161
- */
150
+ * Enables logging output.
151
+ *
152
+ * Re-enables logging after it has been disabled. All subsequent log calls
153
+ * will produce output according to the configured reporters.
154
+ * @example
155
+ * ```typescript
156
+ * const logger = createPail();
157
+ * logger.disable();
158
+ * logger.info("This won't be logged");
159
+ * logger.enable(); // Re-enable logging
160
+ * logger.info("This will be logged");
161
+ * ```
162
+ */
162
163
  enable(): void;
163
164
  /**
164
- * Checks if logging is currently enabled.
165
- *
166
- * Returns true if logging is enabled and false if it has been disabled.
167
- * @returns True if logging is enabled, false if disabled
168
- * @example
169
- * ```typescript
170
- * const logger = createPail();
171
- * console.log(logger.isEnabled()); // true
172
- * logger.disable();
173
- * console.log(logger.isEnabled()); // false
174
- * ```
175
- */
165
+ * Checks if logging is currently enabled.
166
+ *
167
+ * Returns true if logging is enabled and false if it has been disabled.
168
+ * @returns True if logging is enabled, false if disabled
169
+ * @example
170
+ * ```typescript
171
+ * const logger = createPail();
172
+ * console.log(logger.isEnabled()); // true
173
+ * logger.disable();
174
+ * console.log(logger.isEnabled()); // false
175
+ * ```
176
+ */
176
177
  isEnabled(): boolean;
177
178
  /**
178
- * Pauses logging and starts queuing messages.
179
- *
180
- * When paused, all log calls will be queued instead of being output immediately.
181
- * The queued messages will be processed when resume() is called. This is useful
182
- * for temporarily buffering log output during critical operations.
183
- * @example
184
- * ```typescript
185
- * const logger = createPail();
186
- * logger.pause();
187
- * logger.info("This will be queued"); // Queued, not output yet
188
- * logger.warn("This too"); // Also queued
189
- * logger.resume(); // Now both messages are output
190
- * ```
191
- */
179
+ * Pauses logging and starts queuing messages.
180
+ *
181
+ * When paused, all log calls will be queued instead of being output immediately.
182
+ * The queued messages will be processed when resume() is called. This is useful
183
+ * for temporarily buffering log output during critical operations.
184
+ * @example
185
+ * ```typescript
186
+ * const logger = createPail();
187
+ * logger.pause();
188
+ * logger.info("This will be queued"); // Queued, not output yet
189
+ * logger.warn("This too"); // Also queued
190
+ * logger.resume(); // Now both messages are output
191
+ * ```
192
+ */
192
193
  pause(): void;
193
194
  /**
194
- * Resumes logging and flushes all queued messages.
195
- *
196
- * Processes all messages that were queued during the pause period and
197
- * resumes normal logging behavior. Messages are output in the order
198
- * they were originally called.
199
- * @example
200
- * ```typescript
201
- * const logger = createPail();
202
- * logger.pause();
203
- * logger.info("Message 1"); // Queued
204
- * logger.info("Message 2"); // Queued
205
- * logger.resume(); // Both messages are now output in order
206
- * logger.info("Message 3"); // Output immediately
207
- * ```
208
- */
195
+ * Resumes logging and flushes all queued messages.
196
+ *
197
+ * Processes all messages that were queued during the pause period and
198
+ * resumes normal logging behavior. Messages are output in the order
199
+ * they were originally called.
200
+ * @example
201
+ * ```typescript
202
+ * const logger = createPail();
203
+ * logger.pause();
204
+ * logger.info("Message 1"); // Queued
205
+ * logger.info("Message 2"); // Queued
206
+ * logger.resume(); // Both messages are now output in order
207
+ * logger.info("Message 3"); // Output immediately
208
+ * ```
209
+ */
209
210
  resume(): void;
210
211
  /**
211
- * Creates a scoped logger instance.
212
- *
213
- * Returns a new logger instance that inherits all configuration but adds
214
- * the specified scope names to all log messages. This is useful for
215
- * categorizing logs by component, module, or feature.
216
- * @template N - The new custom logger type names
217
- * @param name Scope names to apply to all log messages
218
- * @returns A new scoped logger instance
219
- * @throws {Error} If no scope name is provided
220
- * @example
221
- * ```typescript
222
- * const logger = createPail();
223
- * const scopedLogger = logger.scope("auth", "login");
224
- * scopedLogger.info("User logged in"); // Will include scope: ["auth", "login"]
225
- * ```
226
- */
212
+ * Creates a scoped logger instance.
213
+ *
214
+ * Returns a new logger instance that inherits all configuration but adds
215
+ * the specified scope names to all log messages. This is useful for
216
+ * categorizing logs by component, module, or feature.
217
+ * @template N - The new custom logger type names
218
+ * @param name Scope names to apply to all log messages
219
+ * @returns A new scoped logger instance
220
+ * @throws {Error} If no scope name is provided
221
+ * @example
222
+ * ```typescript
223
+ * const logger = createPail();
224
+ * const scopedLogger = logger.scope("auth", "login");
225
+ * scopedLogger.info("User logged in"); // Will include scope: ["auth", "login"]
226
+ * ```
227
+ */
227
228
  scope<N extends string = T>(...name: string[]): PailBrowserType<N, L>;
228
229
  /**
229
- * Removes the current scope from the logger.
230
- *
231
- * Clears all scope names that were set by previous scope() calls.
232
- * After calling this, log messages will no longer include scope information.
233
- * @example
234
- * ```typescript
235
- * const logger = createPail();
236
- * const scopedLogger = logger.scope("auth");
237
- * scopedLogger.info("Scoped message"); // Has scope
238
- * scopedLogger.unscope();
239
- * scopedLogger.info("Unscoped message"); // No scope
240
- * ```
241
- */
230
+ * Removes the current scope from the logger.
231
+ *
232
+ * Clears all scope names that were set by previous scope() calls.
233
+ * After calling this, log messages will no longer include scope information.
234
+ * @example
235
+ * ```typescript
236
+ * const logger = createPail();
237
+ * const scopedLogger = logger.scope("auth");
238
+ * scopedLogger.info("Scoped message"); // Has scope
239
+ * scopedLogger.unscope();
240
+ * scopedLogger.info("Unscoped message"); // No scope
241
+ * ```
242
+ */
242
243
  unscope(): void;
243
244
  /**
244
- * Creates a child logger that inherits settings from the parent.
245
- *
246
- * Returns a new logger instance that inherits all configuration from the parent
247
- * (reporters, processors, types, log levels, throttle settings, etc.) while allowing
248
- * you to override only what you need. Child loggers are independent instances with
249
- * their own state (timers, counters, etc.).
250
- * @template N - The new custom logger type names
251
- * @template LC - The new log level types
252
- * @param options Configuration options to override or extend parent settings
253
- * @returns A new child logger instance
254
- * @example
255
- * ```typescript
256
- * const parent = createPail({
257
- * logLevel: "info",
258
- * types: { http: { label: "HTTP", logLevel: "info" } },
259
- * reporters: [new PrettyReporter()],
260
- * });
261
- *
262
- * // Child inherits parent settings but overrides log level
263
- * const child = parent.child({ logLevel: "debug" });
264
- * child.info("This will be logged"); // Uses debug level from child
265
- * child.http("GET /api 200"); // Inherits http type from parent
266
- *
267
- * // Child can add new types
268
- * const childWithNewType = parent.child({
269
- * types: { db: { label: "DB", logLevel: "info" } },
270
- * });
271
- * childWithNewType.db("Query executed"); // New type available
272
- * ```
273
- */
245
+ * Creates a child logger that inherits settings from the parent.
246
+ *
247
+ * Returns a new logger instance that inherits all configuration from the parent
248
+ * (reporters, processors, types, log levels, throttle settings, etc.) while allowing
249
+ * you to override only what you need. Child loggers are independent instances with
250
+ * their own state (timers, counters, etc.).
251
+ * @template N - The new custom logger type names
252
+ * @template LC - The new log level types
253
+ * @param options Configuration options to override or extend parent settings
254
+ * @returns A new child logger instance
255
+ * @example
256
+ * ```typescript
257
+ * const parent = createPail({
258
+ * logLevel: "info",
259
+ * types: { http: { label: "HTTP", logLevel: "info" } },
260
+ * reporters: [new PrettyReporter()],
261
+ * });
262
+ *
263
+ * // Child inherits parent settings but overrides log level
264
+ * const child = parent.child({ logLevel: "debug" });
265
+ * child.info("This will be logged"); // Uses debug level from child
266
+ * child.http("GET /api 200"); // Inherits http type from parent
267
+ *
268
+ * // Child can add new types
269
+ * const childWithNewType = parent.child({
270
+ * types: { db: { label: "DB", logLevel: "info" } },
271
+ * });
272
+ * childWithNewType.db("Query executed"); // New type available
273
+ * ```
274
+ */
274
275
  child<N extends string = T, LC extends string = L>(options?: Partial<ConstructorOptions<N, LC>>): PailBrowserType<N, LC>;
275
276
  /**
276
- * Starts a timer with the specified label.
277
- *
278
- * Records the current timestamp and associates it with the given label.
279
- * Multiple timers can be active simultaneously with different labels.
280
- * @param label The timer label (defaults to "default")
281
- * @example
282
- * ```typescript
283
- * const logger = createPail();
284
- * logger.time("operation");
285
- * // ... some operation ...
286
- * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
287
- * ```
288
- */
277
+ * Starts a timer with the specified label.
278
+ *
279
+ * Records the current timestamp and associates it with the given label.
280
+ * Multiple timers can be active simultaneously with different labels.
281
+ * @param label The timer label (defaults to "default")
282
+ * @example
283
+ * ```typescript
284
+ * const logger = createPail();
285
+ * logger.time("operation");
286
+ * // ... some operation ...
287
+ * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
288
+ * ```
289
+ */
289
290
  time(label?: string): void;
290
291
  /**
291
- * Logs the current elapsed time for a timer without stopping it.
292
- *
293
- * Calculates and logs the time elapsed since the timer was started,
294
- * but keeps the timer running. If no label is provided, uses the
295
- * most recently started timer.
296
- * @param label The timer label (uses last timer if not specified)
297
- * @param data Additional data to include in the log message
298
- * @example
299
- * ```typescript
300
- * const logger = createPail();
301
- * logger.time("task");
302
- * // ... some work ...
303
- * logger.timeLog("task"); // Logs current elapsed time
304
- * // ... more work ...
305
- * logger.timeEnd("task"); // Logs final time and stops timer
306
- * ```
307
- */
292
+ * Logs the current elapsed time for a timer without stopping it.
293
+ *
294
+ * Calculates and logs the time elapsed since the timer was started,
295
+ * but keeps the timer running. If no label is provided, uses the
296
+ * most recently started timer.
297
+ * @param label The timer label (uses last timer if not specified)
298
+ * @param data Additional data to include in the log message
299
+ * @example
300
+ * ```typescript
301
+ * const logger = createPail();
302
+ * logger.time("task");
303
+ * // ... some work ...
304
+ * logger.timeLog("task"); // Logs current elapsed time
305
+ * // ... more work ...
306
+ * logger.timeEnd("task"); // Logs final time and stops timer
307
+ * ```
308
+ */
308
309
  timeLog(label?: string, ...data: unknown[]): void;
309
310
  /**
310
- * Stops a timer and logs the final elapsed time.
311
- *
312
- * Calculates the total time elapsed since the timer was started,
313
- * logs the result, and removes the timer. If no label is provided,
314
- * uses the most recently started timer.
315
- * @param label The timer label (uses last timer if not specified)
316
- * @example
317
- * ```typescript
318
- * const logger = createPail();
319
- * logger.time("operation");
320
- * // ... perform operation ...
321
- * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
322
- * ```
323
- */
311
+ * Stops a timer and logs the final elapsed time.
312
+ *
313
+ * Calculates the total time elapsed since the timer was started,
314
+ * logs the result, and removes the timer. If no label is provided,
315
+ * uses the most recently started timer.
316
+ * @param label The timer label (uses last timer if not specified)
317
+ * @example
318
+ * ```typescript
319
+ * const logger = createPail();
320
+ * logger.time("operation");
321
+ * // ... perform operation ...
322
+ * logger.timeEnd("operation"); // Logs: "Timer run for: X ms"
323
+ * ```
324
+ */
324
325
  timeEnd(label?: string): void;
325
326
  /**
326
- * Starts a log group with the specified label.
327
- *
328
- * Groups related log messages together. In browser environments,
329
- * this uses the native console.group() functionality. In other
330
- * environments, it tracks group nesting internally.
331
- * @param label The group label (defaults to "console.group")
332
- * @example
333
- * ```typescript
334
- * const logger = createPail();
335
- * logger.group("Database Operations");
336
- * logger.info("Connecting to database");
337
- * logger.info("Running migration");
338
- * logger.groupEnd(); // End the group
339
- * ```
340
- */
327
+ * Starts a log group with the specified label.
328
+ *
329
+ * Groups related log messages together. In browser environments,
330
+ * this uses the native console.group() functionality. In other
331
+ * environments, it tracks group nesting internally.
332
+ * @param label The group label (defaults to "console.group")
333
+ * @example
334
+ * ```typescript
335
+ * const logger = createPail();
336
+ * logger.group("Database Operations");
337
+ * logger.info("Connecting to database");
338
+ * logger.info("Running migration");
339
+ * logger.groupEnd(); // End the group
340
+ * ```
341
+ */
341
342
  group(label?: string): void;
342
343
  /**
343
- * Ends the current log group.
344
- *
345
- * Closes the most recently opened log group. In browser environments,
346
- * this uses the native console.groupEnd() functionality.
347
- * @example
348
- * ```typescript
349
- * const logger = createPail();
350
- * logger.group("Processing");
351
- * logger.info("Step 1");
352
- * logger.info("Step 2");
353
- * logger.groupEnd(); // Closes the "Processing" group
354
- * ```
355
- */
344
+ * Ends the current log group.
345
+ *
346
+ * Closes the most recently opened log group. In browser environments,
347
+ * this uses the native console.groupEnd() functionality.
348
+ * @example
349
+ * ```typescript
350
+ * const logger = createPail();
351
+ * logger.group("Processing");
352
+ * logger.info("Step 1");
353
+ * logger.info("Step 2");
354
+ * logger.groupEnd(); // Closes the "Processing" group
355
+ * ```
356
+ */
356
357
  groupEnd(): void;
357
358
  /**
358
- * Increments and logs a counter with the specified label.
359
- *
360
- * Maintains an internal counter for each label and logs the current count
361
- * each time it's called. Useful for tracking how many times certain
362
- * code paths are executed.
363
- * @param label The counter label (defaults to "default")
364
- * @example
365
- * ```typescript
366
- * const logger = createPail();
367
- * logger.count("requests"); // Logs: "requests: 1"
368
- * logger.count("requests"); // Logs: "requests: 2"
369
- * logger.count("errors"); // Logs: "errors: 1"
370
- * ```
371
- */
359
+ * Increments and logs a counter with the specified label.
360
+ *
361
+ * Maintains an internal counter for each label and logs the current count
362
+ * each time it's called. Useful for tracking how many times certain
363
+ * code paths are executed.
364
+ * @param label The counter label (defaults to "default")
365
+ * @example
366
+ * ```typescript
367
+ * const logger = createPail();
368
+ * logger.count("requests"); // Logs: "requests: 1"
369
+ * logger.count("requests"); // Logs: "requests: 2"
370
+ * logger.count("errors"); // Logs: "errors: 1"
371
+ * ```
372
+ */
372
373
  count(label?: string): void;
373
374
  /**
374
- * Resets a counter to zero.
375
- *
376
- * Removes the counter with the specified label, effectively resetting
377
- * it to zero. If the counter doesn't exist, logs a warning.
378
- * @param label The counter label to reset (defaults to "default")
379
- * @example
380
- * ```typescript
381
- * const logger = createPail();
382
- * logger.count("requests"); // Logs: "requests: 1"
383
- * logger.countReset("requests"); // Resets counter
384
- * logger.count("requests"); // Logs: "requests: 1" (starts over)
385
- * ```
386
- */
375
+ * Resets a counter to zero.
376
+ *
377
+ * Removes the counter with the specified label, effectively resetting
378
+ * it to zero. If the counter doesn't exist, logs a warning.
379
+ * @param label The counter label to reset (defaults to "default")
380
+ * @example
381
+ * ```typescript
382
+ * const logger = createPail();
383
+ * logger.count("requests"); // Logs: "requests: 1"
384
+ * logger.countReset("requests"); // Resets counter
385
+ * logger.count("requests"); // Logs: "requests: 1" (starts over)
386
+ * ```
387
+ */
387
388
  countReset(label?: string): void;
388
389
  /**
389
- * Clears the console output.
390
- *
391
- * Calls the native console.clear() method to clear all output from
392
- * the console. This is a convenience method that wraps the native
393
- * console.clear() functionality.
394
- * @example
395
- * ```typescript
396
- * const logger = createPail();
397
- * logger.info("Some message");
398
- * logger.clear(); // Clears the console
399
- * ```
400
- */
390
+ * Clears the console output.
391
+ *
392
+ * Calls the native console.clear() method to clear all output from
393
+ * the console. This is a convenience method that wraps the native
394
+ * console.clear() functionality.
395
+ * @example
396
+ * ```typescript
397
+ * const logger = createPail();
398
+ * logger.info("Some message");
399
+ * logger.clear(); // Clears the console
400
+ * ```
401
+ */
401
402
  clear(): void;
402
403
  /**
403
- * Logs a raw message bypassing normal processing.
404
- *
405
- * Sends a message directly to the raw reporter without going through
406
- * the normal logging pipeline (processors, throttling, etc.). This is
407
- * useful for logging that needs to bypass all formatting and processing.
408
- * @param message The raw message to log
409
- * @param arguments_ Additional arguments to include
410
- * @example
411
- * ```typescript
412
- * const logger = createPail();
413
- * logger.raw("Direct message", { data: "value" });
414
- * ```
415
- */
404
+ * Logs a raw message bypassing normal processing.
405
+ *
406
+ * Sends a message directly to the raw reporter without going through
407
+ * the normal logging pipeline (processors, throttling, etc.). This is
408
+ * useful for logging that needs to bypass all formatting and processing.
409
+ * @param message The raw message to log
410
+ * @param arguments_ Additional arguments to include
411
+ * @example
412
+ * ```typescript
413
+ * const logger = createPail();
414
+ * logger.raw("Direct message", { data: "value" });
415
+ * ```
416
+ */
416
417
  raw(message: string, ...arguments_: unknown[]): void;
417
418
  protected extendReporter(reporter: Reporter<L>): Reporter<L>;
418
419
  protected registerReporters(reporters: Reporter<L>[]): void;
@@ -423,12 +424,12 @@ type PailBrowserType<T extends string = string, L extends string = string> = Con
423
424
  force: Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
424
425
  };
425
426
  /**
426
- * Options for creating a PailError.
427
- *
428
- * Extends standard error properties with self-documenting fields
429
- * that provide actionable context for debugging, particularly useful
430
- * for AI-assisted log analysis.
431
- */
427
+ * Options for creating a PailError.
428
+ *
429
+ * Extends standard error properties with self-documenting fields
430
+ * that provide actionable context for debugging, particularly useful
431
+ * for AI-assisted log analysis.
432
+ */
432
433
  interface PailErrorOptions {
433
434
  /** The root cause of this error */
434
435
  cause?: unknown;
@@ -444,41 +445,41 @@ interface PailErrorOptions {
444
445
  why?: string;
445
446
  }
446
447
  /**
447
- * Self-documenting error class for structured logging.
448
- *
449
- * Inspired by evlog's structured error approach, PailError extends the native
450
- * Error class with additional fields that make log entries immediately actionable:
451
- * - `why`: Explains what caused the failure
452
- * - `fix`: Suggests how to resolve the issue
453
- * - `link`: Points to relevant documentation
454
- * - `status`: HTTP status code for request-related errors
455
- *
456
- * These fields are preserved through the logging pipeline and displayed by reporters,
457
- * making it easier for both humans and AI agents to understand and resolve issues.
458
- * @example
459
- * ```typescript
460
- * import { PailError, createPailError } from "@visulima/pail/error";
461
- *
462
- * // Using the class directly
463
- * throw new PailError({
464
- * message: "Payment processing failed",
465
- * status: 402,
466
- * why: "The customer's card was declined by the payment provider",
467
- * fix: "Retry with a different payment method or contact the card issuer",
468
- * link: "https://docs.example.com/payments/declined",
469
- * });
470
- *
471
- * // Using the factory function
472
- * throw createPailError("Connection timeout");
473
- *
474
- * // With full options
475
- * throw createPailError({
476
- * message: "Database connection failed",
477
- * why: "Connection pool exhausted after 30s timeout",
478
- * fix: "Increase pool size or check for connection leaks",
479
- * });
480
- * ```
481
- */
448
+ * Self-documenting error class for structured logging.
449
+ *
450
+ * Inspired by evlog's structured error approach, PailError extends the native
451
+ * Error class with additional fields that make log entries immediately actionable:
452
+ * - `why`: Explains what caused the failure
453
+ * - `fix`: Suggests how to resolve the issue
454
+ * - `link`: Points to relevant documentation
455
+ * - `status`: HTTP status code for request-related errors
456
+ *
457
+ * These fields are preserved through the logging pipeline and displayed by reporters,
458
+ * making it easier for both humans and AI agents to understand and resolve issues.
459
+ * @example
460
+ * ```typescript
461
+ * import { PailError, createPailError } from "@visulima/pail/error";
462
+ *
463
+ * // Using the class directly
464
+ * throw new PailError({
465
+ * message: "Payment processing failed",
466
+ * status: 402,
467
+ * why: "The customer's card was declined by the payment provider",
468
+ * fix: "Retry with a different payment method or contact the card issuer",
469
+ * link: "https://docs.example.com/payments/declined",
470
+ * });
471
+ *
472
+ * // Using the factory function
473
+ * throw createPailError("Connection timeout");
474
+ *
475
+ * // With full options
476
+ * throw createPailError({
477
+ * message: "Database connection failed",
478
+ * why: "Connection pool exhausted after 30s timeout",
479
+ * fix: "Increase pool size or check for connection leaks",
480
+ * });
481
+ * ```
482
+ */
482
483
  declare class PailError extends Error {
483
484
  /** HTTP status code (defaults to 500) */
484
485
  readonly status: number;
@@ -490,81 +491,81 @@ declare class PailError extends Error {
490
491
  readonly link: string | undefined;
491
492
  constructor(options: PailErrorOptions | string);
492
493
  /**
493
- * Converts the error to a JSON-serializable object.
494
- *
495
- * Includes all self-documenting fields in the output for structured logging.
496
- * @returns A plain object representation of the error
497
- */
494
+ * Converts the error to a JSON-serializable object.
495
+ *
496
+ * Includes all self-documenting fields in the output for structured logging.
497
+ * @returns A plain object representation of the error
498
+ */
498
499
  toJSON(): Record<string, unknown>;
499
500
  /**
500
- * Returns a formatted string representation including self-documenting fields.
501
- * @returns Formatted error string with why/fix/link context
502
- */
501
+ * Returns a formatted string representation including self-documenting fields.
502
+ * @returns Formatted error string with why/fix/link context
503
+ */
503
504
  override toString(): string;
504
505
  }
505
506
  /**
506
- * Factory function for creating PailError instances.
507
- *
508
- * A convenient shorthand for creating PailError objects. Accepts either
509
- * a string message or a full PailErrorOptions object.
510
- * @param options Error message string or PailErrorOptions object
511
- * @returns A new PailError instance
512
- * @example
513
- * ```typescript
514
- * import { createPailError } from "@visulima/pail/error";
515
- *
516
- * throw createPailError("Something went wrong");
517
- *
518
- * throw createPailError({
519
- * message: "Auth failed",
520
- * status: 401,
521
- * why: "Token expired",
522
- * fix: "Refresh the authentication token",
523
- * });
524
- * ```
525
- */
507
+ * Factory function for creating PailError instances.
508
+ *
509
+ * A convenient shorthand for creating PailError objects. Accepts either
510
+ * a string message or a full PailErrorOptions object.
511
+ * @param options Error message string or PailErrorOptions object
512
+ * @returns A new PailError instance
513
+ * @example
514
+ * ```typescript
515
+ * import { createPailError } from "@visulima/pail/error";
516
+ *
517
+ * throw createPailError("Something went wrong");
518
+ *
519
+ * throw createPailError({
520
+ * message: "Auth failed",
521
+ * status: 401,
522
+ * why: "Token expired",
523
+ * fix: "Refresh the authentication token",
524
+ * });
525
+ * ```
526
+ */
526
527
  declare const createPailError: (options: PailErrorOptions | string) => PailError;
527
528
  /**
528
- * Creates a new Pail logger instance configured for browser environments.
529
- *
530
- * This factory function creates a browser-compatible logger with default processors
531
- * and reporters suitable for client-side logging.
532
- * @template T - Custom logger types
533
- * @template L - Log level types
534
- * @param options Configuration options for the logger
535
- * @returns A new PailBrowser instance
536
- * @example
537
- * ```typescript
538
- * import { createPail } from "@visulima/pail";
539
- *
540
- * const logger = createPail({
541
- * logLevel: "debug",
542
- * types: {
543
- * custom: {
544
- * color: "blue",
545
- * label: "CUSTOM",
546
- * logLevel: "info"
547
- * }
548
- * }
549
- * });
550
- *
551
- * logger.info("Hello world!");
552
- * logger.custom("Custom message");
553
- * ```
554
- */
529
+ * Creates a new Pail logger instance configured for browser environments.
530
+ *
531
+ * This factory function creates a browser-compatible logger with default processors
532
+ * and reporters suitable for client-side logging.
533
+ * @template T - Custom logger types
534
+ * @template L - Log level types
535
+ * @param options Configuration options for the logger
536
+ * @returns A new PailBrowser instance
537
+ * @example
538
+ * ```typescript
539
+ * import { createPail } from "@visulima/pail";
540
+ *
541
+ * const logger = createPail({
542
+ * logLevel: "debug",
543
+ * types: {
544
+ * custom: {
545
+ * color: "blue",
546
+ * label: "CUSTOM",
547
+ * logLevel: "info"
548
+ * }
549
+ * }
550
+ * });
551
+ *
552
+ * logger.info("Hello world!");
553
+ * logger.custom("Custom message");
554
+ * ```
555
+ */
555
556
  declare const createPail: <T extends string = string, L extends string = string>(options?: ConstructorOptions<T, L>) => PailBrowserType<T, L>;
556
557
  /**
557
- * Default Pail logger instance for browser environments.
558
- *
559
- * A pre-configured logger instance ready for immediate use in browser environments.
560
- * Uses default configuration with JSON reporter and message formatter processor.
561
- * @example
562
- * ```typescript
563
- * import { pail } from "@visulima/pail";
564
- *
565
- * pail.info("Application started");
566
- * pail.error("Something went wrong", new Error("Test error"));
567
- * ```
568
- */
558
+ * Default Pail logger instance for browser environments.
559
+ *
560
+ * A pre-configured logger instance ready for immediate use in browser environments.
561
+ * Uses default configuration with JSON reporter and message formatter processor.
562
+ * @example
563
+ * ```typescript
564
+ * import { pail } from "@visulima/pail";
565
+ *
566
+ * pail.info("Application started");
567
+ * pail.error("Something went wrong", new Error("Test error"));
568
+ * ```
569
+ */
569
570
  declare const pail: PailBrowserType;
570
571
  export { type ConstructorOptions, type DefaultLogTypes, type ExtendedRfc5424LogLevels, type LoggerFunction, type LoggerTypesConfig, type PailBrowserType as Pail, PailError, type PailErrorOptions, type Processor, type Reporter, createPail, createPailError, pail };