@visulima/pail 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +14 -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
@@ -37,36 +37,36 @@ const petWithAutoComplete: Pet2 = '';
37
37
  */
38
38
  type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
39
39
  /**
40
- * Global namespace for extending Pail's metadata interface.
41
- *
42
- * This global declaration allows other packages and applications to extend
43
- * the Meta interface with custom properties by declaring additional properties
44
- * in the VisulimaPail.CustomMeta interface.
45
- * @example
46
- * ```typescript
47
- * declare global {
48
- * namespace VisulimaPail {
49
- * interface CustomMeta<L> {
50
- * userId?: string;
51
- * requestId?: string;
52
- * }
53
- * }
54
- * }
55
- * ```
56
- */
40
+ * Global namespace for extending Pail's metadata interface.
41
+ *
42
+ * This global declaration allows other packages and applications to extend
43
+ * the Meta interface with custom properties by declaring additional properties
44
+ * in the VisulimaPail.CustomMeta interface.
45
+ * @example
46
+ * ```typescript
47
+ * declare global {
48
+ * namespace VisulimaPail {
49
+ * interface CustomMeta<L> {
50
+ * userId?: string;
51
+ * requestId?: string;
52
+ * }
53
+ * }
54
+ * }
55
+ * ```
56
+ */
57
57
  declare global {
58
58
  namespace VisulimaPail {
59
59
  interface CustomMeta<L> {}
60
60
  }
61
61
  }
62
62
  /**
63
- * Metadata object containing all information about a log entry.
64
- *
65
- * This interface defines the structure of metadata that is passed to reporters
66
- * and processors. It contains all the contextual information about a log message
67
- * including the message itself, timing information, error details, and more.
68
- * @template L - The log level type
69
- */
63
+ * Metadata object containing all information about a log entry.
64
+ *
65
+ * This interface defines the structure of metadata that is passed to reporters
66
+ * and processors. It contains all the contextual information about a log message
67
+ * including the message itself, timing information, error details, and more.
68
+ * @template L - The log level type
69
+ */
70
70
  interface Meta<L> extends VisulimaPail.CustomMeta<L> {
71
71
  badge: string | undefined;
72
72
  context: any[] | undefined;
@@ -86,38 +86,38 @@ interface Meta<L> extends VisulimaPail.CustomMeta<L> {
86
86
  };
87
87
  }
88
88
  /**
89
- * Extended RFC 5424 Log Levels.
90
- *
91
- * Standard syslog severity levels as defined in RFC 5424, plus additional
92
- * levels commonly used in modern applications. Each level has a numeric
93
- * priority where lower numbers indicate higher severity.
94
- * @see https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
95
- */
89
+ * Extended RFC 5424 Log Levels.
90
+ *
91
+ * Standard syslog severity levels as defined in RFC 5424, plus additional
92
+ * levels commonly used in modern applications. Each level has a numeric
93
+ * priority where lower numbers indicate higher severity.
94
+ * @see https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
95
+ */
96
96
  type ExtendedRfc5424LogLevels = "alert" | "critical" | "debug" | "emergency" | "error" | "informational" | "notice" | "trace" | "warning";
97
97
  /**
98
- * Read-only Metadata.
99
- *
100
- * Immutable version of the Meta interface for use in reporters.
101
- * @template L - The log level type
102
- */
98
+ * Read-only Metadata.
99
+ *
100
+ * Immutable version of the Meta interface for use in reporters.
101
+ * @template L - The log level type
102
+ */
103
103
  type ReadonlyMeta<L extends string> = Readonly<Meta<L>>;
104
104
  /**
105
- * Reporter Interface.
106
- *
107
- * Base interface for all reporters. Reporters are responsible for
108
- * outputting log messages to various destinations (console, files, etc.).
109
- * @template L - The log level type
110
- */
105
+ * Reporter Interface.
106
+ *
107
+ * Base interface for all reporters. Reporters are responsible for
108
+ * outputting log messages to various destinations (console, files, etc.).
109
+ * @template L - The log level type
110
+ */
111
111
  interface Reporter<L extends string> {
112
112
  log: (meta: ReadonlyMeta<L>) => void;
113
113
  }
114
114
  /**
115
- * Stringify-Aware Reporter Interface.
116
- *
117
- * Extends Reporter with the ability to receive a custom stringify function.
118
- * Useful for reporters that need to serialize complex objects.
119
- * @template L - The log level type
120
- */
115
+ * Stringify-Aware Reporter Interface.
116
+ *
117
+ * Extends Reporter with the ability to receive a custom stringify function.
118
+ * Useful for reporters that need to serialize complex objects.
119
+ * @template L - The log level type
120
+ */
121
121
  interface StringifyAwareReporter<L extends string> extends Reporter<L> {
122
122
  /** Set the stringify function for object serialization */
123
123
  setStringify: (stringify: any) => void;
@@ -138,8 +138,8 @@ interface StringifyOptions {
138
138
  strict?: boolean;
139
139
  }
140
140
  /**
141
- * Options for configuring JSON reporters.
142
- */
141
+ * Options for configuring JSON reporters.
142
+ */
143
143
  type AbstractJsonReporterOptions = {
144
144
  /** Error serialization options */
145
145
  error: Partial<{
@@ -152,145 +152,148 @@ type AbstractJsonReporterOptions = {
152
152
  }>;
153
153
  };
154
154
  /**
155
- * Abstract JSON Reporter.
156
- *
157
- * Base class for JSON-based reporters that provides common functionality
158
- * for serializing log metadata to JSON format. Handles error serialization,
159
- * context processing, and provides a template method for actual output.
160
- * @template L - The log level type
161
- * @example
162
- * ```typescript
163
- * class CustomJsonReporter extends AbstractJsonReporter {
164
- * protected _log(message: string): void {
165
- * console.log(message);
166
- * }
167
- * }
168
- * ```
169
- */
155
+ * Abstract JSON Reporter.
156
+ *
157
+ * Base class for JSON-based reporters that provides common functionality
158
+ * for serializing log metadata to JSON format. Handles error serialization,
159
+ * context processing, and provides a template method for actual output.
160
+ * @template L - The log level type
161
+ * @example
162
+ * ```typescript
163
+ * class CustomJsonReporter extends AbstractJsonReporter {
164
+ * protected _log(message: string): void {
165
+ * console.log(message);
166
+ * }
167
+ * }
168
+ * ```
169
+ */
170
170
  declare abstract class AbstractJsonReporter<L extends string = string> implements StringifyAwareReporter<L> {
171
171
  /** Custom stringify function for object serialization */
172
172
  protected stringify: typeof stringify | undefined;
173
173
  /** Error serialization options */
174
174
  protected errorOptions: AbstractJsonReporterOptions["error"];
175
175
  /**
176
- * Creates a new AbstractJsonReporter instance.
177
- * @param options Configuration options for JSON formatting and error handling
178
- */
176
+ * Creates a new AbstractJsonReporter instance.
177
+ * @param options Configuration options for JSON formatting and error handling
178
+ */
179
179
  constructor(options?: Partial<AbstractJsonReporterOptions>);
180
180
  /**
181
- * Sets a custom stringify function for object serialization.
182
- * @param function_ The stringify function to use for serialization
183
- */
181
+ * Sets a custom stringify function for object serialization.
182
+ * @param function_ The stringify function to use for serialization
183
+ */
184
184
  setStringify(function_: typeof stringify): void;
185
185
  log(meta: ReadonlyMeta<L>): void;
186
186
  /**
187
- * Template method for outputting the JSON log message.
188
- *
189
- * Subclasses must implement this method to define how the JSON message
190
- * is actually written (to console, file, network, etc.).
191
- * @param message The JSON-formatted log message
192
- * @param logLevel The log level of the message
193
- * @protected
194
- * @abstract
195
- */
187
+ * Template method for outputting the JSON log message.
188
+ *
189
+ * Subclasses must implement this method to define how the JSON message
190
+ * is actually written (to console, file, network, etc.).
191
+ * @param message The JSON-formatted log message
192
+ * @param logLevel The log level of the message
193
+ * @protected
194
+ * @abstract
195
+ */
196
196
  protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
197
197
  }
198
198
  /**
199
- * Configuration options for the HTTP reporter.
200
- */
199
+ * Configuration options for the HTTP reporter.
200
+ */
201
201
  type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
202
202
  /**
203
- * Content type for batch log requests. User-specified headers take precedence.
204
- * @default "application/json"
205
- */
203
+ * Content type for batch log requests. User-specified headers take precedence.
204
+ * @default "application/json"
205
+ */
206
206
  batchContentType?: string;
207
207
  /**
208
- * Field name to wrap batch entries in when batchMode is "field" (e.g., "batch" for Logflare)
209
- * @default undefined
210
- */
208
+ * Field name to wrap batch entries in when batchMode is "field" (e.g., "batch" for Logflare)
209
+ * @default undefined
210
+ */
211
211
  batchFieldName?: string;
212
212
  /**
213
- * Batch mode for sending multiple log entries
214
- * - "delimiter": Join entries with a delimiter (default)
215
- * - "field": Wrap entries in an object with a field name
216
- * - "array": Send entries as a plain JSON array
217
- * @default "delimiter"
218
- */
213
+ * Batch mode for sending multiple log entries
214
+ * - "delimiter": Join entries with a delimiter (default)
215
+ * - "field": Wrap entries in an object with a field name
216
+ * - "array": Send entries as a plain JSON array
217
+ * @default "delimiter"
218
+ */
219
219
  batchMode?: "delimiter" | "field" | "array";
220
220
  /**
221
- * Delimiter to use between log entries in batch mode
222
- * @default "\n"
223
- */
221
+ * Delimiter to use between log entries in batch mode
222
+ * @default "\n"
223
+ */
224
224
  batchSendDelimiter?: string;
225
225
  /**
226
- * Timeout in milliseconds for sending batches regardless of size
227
- * @default 5000
228
- */
226
+ * Timeout in milliseconds for sending batches regardless of size
227
+ * @default 5000
228
+ */
229
229
  batchSendTimeout?: number;
230
230
  /**
231
- * Number of log entries to batch before sending
232
- * @default 100
233
- */
231
+ * Number of log entries to batch before sending
232
+ * @default 100
233
+ */
234
234
  batchSize?: number;
235
235
  /**
236
- * Whether to use gzip compression
237
- * @default false
238
- */
236
+ * Whether to use gzip compression
237
+ * @default false
238
+ */
239
239
  compression?: boolean;
240
240
  /**
241
- * Content type for single log requests. User-specified headers take precedence.
242
- * @default "application/json"
243
- */
241
+ * Content type for single log requests. User-specified headers take precedence.
242
+ * @default "application/json"
243
+ */
244
244
  contentType?: string;
245
245
  /**
246
- * Whether to enable Edge Runtime compatibility mode
247
- * When enabled, TextEncoder and compression are disabled
248
- * @default false
249
- */
246
+ * Whether to enable Edge Runtime compatibility mode.
247
+ *
248
+ * When enabled, gzip compression is skipped so the reporter never depends on a
249
+ * compression implementation the runtime may not provide. Payload size accounting
250
+ * always uses the Web-standard `TextEncoder` and is unaffected by this flag.
251
+ * @default false
252
+ */
250
253
  edgeCompat?: boolean;
251
254
  /**
252
- * Whether to enable batch sending
253
- * @default true
254
- */
255
+ * Whether to enable batch sending
256
+ * @default true
257
+ */
255
258
  enableBatchSend?: boolean;
256
259
  /**
257
- * Headers to include in the request. Can be an object or a function that returns headers.
258
- */
260
+ * Headers to include in the request. Can be an object or a function that returns headers.
261
+ */
259
262
  headers?: Record<string, string> | (() => Record<string, string>);
260
263
  /**
261
- * Maximum size of a single log entry in bytes
262
- * @default 1048576 (1MB)
263
- */
264
+ * Maximum size of a single log entry in bytes
265
+ * @default 1048576 (1MB)
266
+ */
264
267
  maxLogSize?: number;
265
268
  /**
266
- * Maximum size of the payload (uncompressed) in bytes
267
- * @default 5242880 (5MB)
268
- */
269
+ * Maximum size of the payload (uncompressed) in bytes
270
+ * @default 5242880 (5MB)
271
+ */
269
272
  maxPayloadSize?: number;
270
273
  /**
271
- * Maximum number of entries to keep queued while the endpoint is unavailable.
272
- * When the queue exceeds this limit, the oldest entries are dropped (drop-oldest)
273
- * so a sustained outage cannot grow memory without bound.
274
- * @default 10000
275
- */
274
+ * Maximum number of entries to keep queued while the endpoint is unavailable.
275
+ * When the queue exceeds this limit, the oldest entries are dropped (drop-oldest)
276
+ * so a sustained outage cannot grow memory without bound.
277
+ * @default 10000
278
+ */
276
279
  maxQueueSize?: number;
277
280
  /**
278
- * Number of retry attempts before giving up
279
- * @default 3
280
- */
281
+ * Number of retry attempts before giving up
282
+ * @default 3
283
+ */
281
284
  maxRetries?: number;
282
285
  /**
283
- * HTTP method to use for requests
284
- * @default "POST"
285
- */
286
+ * HTTP method to use for requests
287
+ * @default "POST"
288
+ */
286
289
  method?: string;
287
290
  /**
288
- * Optional callback for debugging log entries before they are sent
289
- */
291
+ * Optional callback for debugging log entries before they are sent
292
+ */
290
293
  onDebug?: (entry: Record<string, unknown>) => void;
291
294
  /**
292
- * Optional callback for debugging HTTP requests and responses
293
- */
295
+ * Optional callback for debugging HTTP requests and responses
296
+ */
294
297
  onDebugRequestResponse?: (requestResponse: {
295
298
  req: {
296
299
  body: string | Uint8Array;
@@ -306,45 +309,45 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
306
309
  };
307
310
  }) => void;
308
311
  /**
309
- * Optional callback invoked when queued log entries are dropped because the queue
310
- * exceeded `maxQueueSize`. Receives the number of dropped entries.
311
- */
312
+ * Optional callback invoked when queued log entries are dropped because the queue
313
+ * exceeded `maxQueueSize`. Receives the number of dropped entries.
314
+ */
312
315
  onDrop?: (droppedCount: number) => void;
313
316
  /**
314
- * Optional callback for error handling
315
- */
317
+ * Optional callback for error handling
318
+ */
316
319
  onError?: (error: Error) => void;
317
320
  /**
318
- * Function to transform log data into the payload format.
319
- * By default, uses the JSON stringified log entry.
320
- */
321
+ * Function to transform log data into the payload format.
322
+ * By default, uses the JSON stringified log entry.
323
+ */
321
324
  payloadTemplate?: (data: {
322
325
  data?: Record<string, unknown>;
323
326
  logLevel: string;
324
327
  message: string;
325
328
  }) => string;
326
329
  /**
327
- * Whether to respect rate limiting by waiting when a 429 response is received
328
- * @default true
329
- */
330
+ * Whether to respect rate limiting by waiting when a 429 response is received
331
+ * @default true
332
+ */
330
333
  respectRateLimit?: boolean;
331
334
  /**
332
- * Base delay between retries in milliseconds
333
- * @default 1000
334
- */
335
+ * Base delay between retries in milliseconds
336
+ * @default 1000
337
+ */
335
338
  retryDelay?: number;
336
339
  /**
337
- * The URL to send logs to
338
- */
340
+ * The URL to send logs to
341
+ */
339
342
  url: string;
340
343
  };
341
344
  /**
342
- * Abstract HTTP Reporter.
343
- *
344
- * Base class for HTTP-based reporters that sends logs to HTTP endpoints.
345
- * Supports batching, compression, retries, and rate limiting.
346
- * @template L - The log level type
347
- */
345
+ * Abstract HTTP Reporter.
346
+ *
347
+ * Base class for HTTP-based reporters that sends logs to HTTP endpoints.
348
+ * Supports batching, compression, retries, and rate limiting.
349
+ * @template L - The log level type
350
+ */
348
351
  declare abstract class AbstractHttpReporter<L extends string = string> extends AbstractJsonReporter<L> implements StringifyAwareReporter<L> {
349
352
  #private;
350
353
  protected url: string;
@@ -389,100 +392,102 @@ declare abstract class AbstractHttpReporter<L extends string = string> extends A
389
392
  protected maxPayloadSize: number;
390
393
  protected edgeCompat: boolean;
391
394
  protected batchQueue: string[];
395
+ /** Per-entry UTF-8 byte sizes, kept in lockstep with `batchQueue`, so the tracked queue size never re-encodes payloads. */
396
+ protected batchSizeQueue: number[];
392
397
  protected batchTimeout?: ReturnType<typeof setTimeout>;
393
398
  protected isProcessingBatch: boolean;
394
399
  protected currentBatchSize: number;
395
400
  /**
396
- * Creates a new instance of AbstractHttpReporter.
397
- * @param config Configuration options for the reporter
398
- */
401
+ * Creates a new instance of AbstractHttpReporter.
402
+ * @param config Configuration options for the reporter
403
+ */
399
404
  constructor(config: AbstractHttpReporterOptions);
400
405
  /**
401
- * Flushes all queued log entries to the HTTP endpoint immediately.
402
- *
403
- * Returns a promise that resolves once the queue has been drained (or rejects
404
- * if a batch send fails terminally). Use this before a serverless function or
405
- * short-lived process exits so the tail of the batch is not lost.
406
- * @example
407
- * ```typescript
408
- * await reporter.flush();
409
- * ```
410
- */
406
+ * Flushes all queued log entries to the HTTP endpoint immediately.
407
+ *
408
+ * Returns a promise that resolves once the queue has been drained (or rejects
409
+ * if a batch send fails terminally). Use this before a serverless function or
410
+ * short-lived process exits so the tail of the batch is not lost.
411
+ * @example
412
+ * ```typescript
413
+ * await reporter.flush();
414
+ * ```
415
+ */
411
416
  flush(): Promise<void>;
412
417
  /**
413
- * Flushes any remaining queued entries and clears pending timers.
414
- *
415
- * Counterpart to a transport lifecycle `end`/`dispose`. After calling `close()`
416
- * the reporter can still be used, but any pending batch timeout is cleared.
417
- * @example
418
- * ```typescript
419
- * process.on("beforeExit", () => reporter.close());
420
- * ```
421
- */
418
+ * Flushes any remaining queued entries and clears pending timers.
419
+ *
420
+ * Counterpart to a transport lifecycle `end`/`dispose`. After calling `close()`
421
+ * the reporter can still be used, but any pending batch timeout is cleared.
422
+ * @example
423
+ * ```typescript
424
+ * process.on("beforeExit", () => reporter.close());
425
+ * ```
426
+ */
422
427
  close(): Promise<void>;
423
428
  /**
424
- * Alias for {@link close} to match common transport `dispose` conventions.
425
- */
429
+ * Alias for {@link close} to match common transport `dispose` conventions.
430
+ */
426
431
  dispose(): Promise<void>;
427
432
  /**
428
- * Processes and ships log entries to the HTTP endpoint.
429
- * @param message The JSON-formatted log message
430
- * @param logLevel The log level of the message
431
- * @protected
432
- */
433
+ * Processes and ships log entries to the HTTP endpoint.
434
+ * @param message The JSON-formatted log message
435
+ * @param logLevel The log level of the message
436
+ * @protected
437
+ */
433
438
  protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
434
439
  /**
435
- * Adds a payload to the batch queue and triggers sending if conditions are met.
436
- */
440
+ * Adds a payload to the batch queue and triggers sending if conditions are met.
441
+ */
437
442
  protected addToBatch(payload: string, logEntrySize: number): void;
438
443
  /**
439
- * Processes the current batch and sends it to the HTTP endpoint.
440
- */
444
+ * Processes the current batch and sends it to the HTTP endpoint.
445
+ */
441
446
  protected processBatch(): Promise<void>;
442
447
  /**
443
- * Sends a batch of payloads to the HTTP endpoint.
444
- */
448
+ * Sends a batch of payloads to the HTTP endpoint.
449
+ */
445
450
  protected sendBatch(batch: string[]): Promise<void>;
446
451
  /**
447
- * Sends a single payload to the HTTP endpoint.
448
- */
452
+ * Sends a single payload to the HTTP endpoint.
453
+ */
449
454
  protected sendPayload(payload: string, contentType?: string): Promise<void>;
450
455
  }
451
456
  /**
452
- * HTTP Reporter for Edge Runtime environments.
453
- *
454
- * A reporter optimized for Edge Runtime environments (Next.js Edge, Cloudflare Workers, etc.)
455
- * that sends logs to HTTP endpoints. Edge compatibility mode is enabled by default.
456
- * Supports batching, retries, and rate limiting. Compression is disabled for Edge compatibility.
457
- * @template L - The log level type
458
- * @example
459
- * ```typescript
460
- * import { createPail } from "@visulima/pail";
461
- * import { HttpReporterEdgeLight } from "@visulima/pail/reporter/http/edge-light";
462
- *
463
- * const logger = createPail({
464
- * reporters: [
465
- * new HttpReporterEdgeLight({
466
- * url: "https://api.example.com/logs",
467
- * method: "POST",
468
- * headers: {
469
- * "Authorization": "Bearer token"
470
- * },
471
- * enableBatchSend: true,
472
- * batchSize: 50
473
- * })
474
- * ]
475
- * });
476
- *
477
- * logger.info("Edge function started");
478
- * ```
479
- */
457
+ * HTTP Reporter for Edge Runtime environments.
458
+ *
459
+ * A reporter optimized for Edge Runtime environments (Next.js Edge, Cloudflare Workers, etc.)
460
+ * that sends logs to HTTP endpoints. Edge compatibility mode is enabled by default.
461
+ * Supports batching, retries, and rate limiting. Compression is disabled for Edge compatibility.
462
+ * @template L - The log level type
463
+ * @example
464
+ * ```typescript
465
+ * import { createPail } from "@visulima/pail";
466
+ * import { HttpReporterEdgeLight } from "@visulima/pail/reporter/http/edge-light";
467
+ *
468
+ * const logger = createPail({
469
+ * reporters: [
470
+ * new HttpReporterEdgeLight({
471
+ * url: "https://api.example.com/logs",
472
+ * method: "POST",
473
+ * headers: {
474
+ * "Authorization": "Bearer token"
475
+ * },
476
+ * enableBatchSend: true,
477
+ * batchSize: 50
478
+ * })
479
+ * ]
480
+ * });
481
+ *
482
+ * logger.info("Edge function started");
483
+ * ```
484
+ */
480
485
  declare class HttpReporterEdgeLight<L extends string = string> extends AbstractHttpReporter<L> {
481
486
  /**
482
- * Creates a new HTTP Reporter Edge Light instance.
483
- * Edge compatibility mode is automatically enabled.
484
- * @param options Configuration options for HTTP reporting
485
- */
487
+ * Creates a new HTTP Reporter Edge Light instance.
488
+ * Edge compatibility mode is automatically enabled.
489
+ * @param options Configuration options for HTTP reporting
490
+ */
486
491
  constructor(options: Omit<AbstractHttpReporterOptions, "edgeCompat">);
487
492
  }
488
493
  export { HttpReporterEdgeLight as default };