@visulima/pail 4.0.0-alpha.6 → 4.0.0-alpha.8

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 (52) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE.md +2 -2
  3. package/README.md +323 -0
  4. package/dist/error.d.ts +104 -0
  5. package/dist/error.js +76 -0
  6. package/dist/index.browser.d.ts +2 -0
  7. package/dist/index.browser.js +4 -3
  8. package/dist/index.server.d.ts +2 -0
  9. package/dist/index.server.js +5 -3
  10. package/dist/middleware/elysia.d.ts +71 -0
  11. package/dist/middleware/elysia.js +70 -0
  12. package/dist/middleware/express.d.ts +86 -0
  13. package/dist/middleware/express.js +29 -0
  14. package/dist/middleware/fastify.d.ts +81 -0
  15. package/dist/middleware/fastify.js +46 -0
  16. package/dist/middleware/hono.d.ts +85 -0
  17. package/dist/middleware/hono.js +33 -0
  18. package/dist/middleware/next/handler.d.ts +36 -0
  19. package/dist/middleware/next/handler.js +53 -0
  20. package/dist/middleware/next/middleware.d.ts +59 -0
  21. package/dist/middleware/next/storage.d.ts +14 -0
  22. package/dist/middleware/shared/create-middleware-logger.d.ts +82 -0
  23. package/dist/middleware/shared/headers.d.ts +14 -0
  24. package/dist/middleware/shared/routes.d.ts +30 -0
  25. package/dist/middleware/shared/storage.d.ts +29 -0
  26. package/dist/middleware/sveltekit.d.ts +123 -0
  27. package/dist/middleware/sveltekit.js +43 -0
  28. package/dist/packem_shared/{AbstractJsonReporter-DWRpTtGw.js → AbstractJsonReporter-CGKHS8_M.js} +103 -21
  29. package/dist/packem_shared/{AbstractJsonReporter-BaZ33PlE.js → AbstractJsonReporter-DDjDkciI.js} +103 -21
  30. package/dist/packem_shared/{JsonReporter-BV5lMnJX.js → JsonReporter-B3XX8GHN.js} +1 -1
  31. package/dist/packem_shared/{JsonReporter-BRw4skd5.js → JsonReporter-p_BXg6Sj.js} +1 -1
  32. package/dist/packem_shared/{PrettyReporter-BjXCFQlo.js → PrettyReporter-CvBn-hxP.js} +2 -1
  33. package/dist/packem_shared/createPailError-B11aRfrT.js +76 -0
  34. package/dist/packem_shared/headers-Cp4uLtr4.js +123 -0
  35. package/dist/packem_shared/pailMiddleware-Ci88geIF.js +24 -0
  36. package/dist/packem_shared/storage-D0vqz8OX.js +36 -0
  37. package/dist/packem_shared/useLogger-D0rU3lcX.js +33 -0
  38. package/dist/processor/environment-processor.d.ts +124 -0
  39. package/dist/processor/environment-processor.js +78 -0
  40. package/dist/processor/message-formatter-processor.d.ts +1 -2
  41. package/dist/processor/sampling-processor.d.ts +111 -0
  42. package/dist/processor/sampling-processor.js +59 -0
  43. package/dist/reporter/file/json-file-reporter.js +1 -1
  44. package/dist/reporter/http/abstract-http-reporter.js +1 -1
  45. package/dist/reporter/http/http-reporter.edge-light.js +103 -21
  46. package/dist/reporter/json/index.browser.js +2 -2
  47. package/dist/reporter/json/index.js +2 -2
  48. package/dist/reporter/pretty/index.js +1 -1
  49. package/dist/reporter/simple/simple-reporter.server.js +2 -1
  50. package/dist/wide-event.d.ts +300 -0
  51. package/dist/wide-event.js +281 -0
  52. package/package.json +70 -5
@@ -0,0 +1,300 @@
1
+ import type { PailBrowserImpl } from "./pail.d.ts";
2
+ import type { DefaultLogTypes, LoggerFunction } from "./types.d.ts";
3
+ /**
4
+ * A pail instance with dynamically generated log methods.
5
+ * This is the minimal interface WideEvent needs from a pail logger.
6
+ */
7
+ type PailLike<T extends string = string> = PailBrowserImpl<T> & Record<DefaultLogTypes | T, LoggerFunction>;
8
+ /**
9
+ * Makes all properties in T optional recursively.
10
+ */
11
+ type DeepPartial<T> = {
12
+ [K in keyof T]?: T[K] extends Record<string, unknown> ? DeepPartial<T[K]> : T[K];
13
+ };
14
+ /**
15
+ * Severity levels for wide events.
16
+ */
17
+ export type WideEventLevel = "debug" | "error" | "info" | "warn";
18
+ /**
19
+ * An entry in the request lifecycle log.
20
+ */
21
+ export interface RequestLogEntry {
22
+ /**
23
+ * Additional structured context for this log entry.
24
+ */
25
+ context?: Record<string, unknown>;
26
+ /**
27
+ * Severity level of this entry.
28
+ */
29
+ level: WideEventLevel;
30
+ /**
31
+ * Human-readable message describing what happened.
32
+ */
33
+ message: string;
34
+ /**
35
+ * ISO 8601 timestamp of when this entry was recorded.
36
+ */
37
+ timestamp: string;
38
+ }
39
+ /**
40
+ * Serialized error information included in the emitted wide event.
41
+ */
42
+ export interface SerializedError {
43
+ cause?: SerializedError;
44
+ data?: unknown;
45
+ message: string;
46
+ name: string;
47
+ stack?: string;
48
+ status?: number;
49
+ }
50
+ /**
51
+ * Options for finishing a wide event with HTTP context.
52
+ */
53
+ export interface WideEventFinishOptions {
54
+ /**
55
+ * An error that occurred during the operation.
56
+ * Will be serialized and included in the emitted event.
57
+ */
58
+ error?: Error;
59
+ /**
60
+ * HTTP response status code.
61
+ */
62
+ status?: number;
63
+ }
64
+ /**
65
+ * Options for creating a WideEvent instance.
66
+ * @template T - Custom logger type names
67
+ */
68
+ export interface WideEventOptions<T extends string = string> {
69
+ /**
70
+ * Auto-emit the event when disposed via `Symbol.dispose`.
71
+ * Works with TC39 Explicit Resource Management (`using`).
72
+ * @default true
73
+ */
74
+ autoEmit?: boolean;
75
+ /**
76
+ * Event name identifying this wide event, e.g. "api.checkout", "worker.send-email".
77
+ */
78
+ name: string;
79
+ /**
80
+ * The pail logger instance to use for emission.
81
+ */
82
+ pail: PailLike<T>;
83
+ /**
84
+ * Service name for this event. Overrides any service name from pail's scope.
85
+ */
86
+ service?: string;
87
+ /**
88
+ * Base log type to use when emitting. Defaults to "info".
89
+ * The actual type may be escalated based on logged warnings/errors.
90
+ */
91
+ type?: DefaultLogTypes | T;
92
+ }
93
+ /**
94
+ * A wide event logger that accumulates context incrementally and emits
95
+ * a single comprehensive log event through pail.
96
+ *
97
+ * Instead of scattering multiple log calls throughout an operation,
98
+ * use `set()` to build up context as information becomes available,
99
+ * then emit once at the end. Lifecycle methods (`info()`, `warn()`, `error()`,
100
+ * `debug()`) record timestamped entries in a `requestLogs` array and
101
+ * automatically escalate the event's severity level.
102
+ *
103
+ * Implements `Disposable` for use with TC39 Explicit Resource Management.
104
+ * @template TData - Shape of the accumulated event data
105
+ * @template T - Custom logger type names from the pail instance
106
+ * @example
107
+ * ```typescript
108
+ * // Manual finish
109
+ * const ev = createWideEvent({ pail: logger, name: "api.checkout" });
110
+ * ev.set({ user: { id: 1 } });
111
+ * ev.info("Validated cart");
112
+ * ev.set({ cart: { items: 3, total: 9999 } });
113
+ * ev.finish({ status: 200 });
114
+ *
115
+ * // Auto-emit with Explicit Resource Management
116
+ * using ev = createWideEvent({ pail: logger, name: "api.checkout" });
117
+ * ev.set({ user: { id: 1 } });
118
+ * // emits automatically when scope exits
119
+ *
120
+ * // Typed data shape
121
+ * interface CheckoutData {
122
+ * user: { id: number; plan: string };
123
+ * cart: { items: number; total: number };
124
+ * }
125
+ * const ev = createWideEvent<CheckoutData>({ pail: logger, name: "api.checkout" });
126
+ * ev.set({ user: { id: 1, plan: "pro" } }); // fully typed
127
+ * ```
128
+ */
129
+ export declare class WideEvent<TData extends Record<string, unknown> = Record<string, unknown>, T extends string = string> implements Disposable {
130
+ [Symbol.dispose]: () => void;
131
+ readonly name: string;
132
+ private readonly autoEmit;
133
+ private data;
134
+ private emitted;
135
+ private attachedError?;
136
+ private level;
137
+ private readonly pail;
138
+ private readonly requestLogs;
139
+ private readonly service;
140
+ private readonly startTime;
141
+ private status;
142
+ private readonly timestamp;
143
+ private readonly type;
144
+ constructor(options: WideEventOptions<T>);
145
+ /**
146
+ * Record a debug-level lifecycle log entry.
147
+ * Does not escalate the event level.
148
+ * @param message Description of what happened
149
+ * @param context Optional structured context
150
+ * @returns `this` for chaining
151
+ */
152
+ debug(message: string, context?: Record<string, unknown>): this;
153
+ /**
154
+ * Emit the wide event through the pail logger. Can only be called once;
155
+ * subsequent calls are no-ops.
156
+ *
157
+ * Automatically calculates duration, determines the log type based on
158
+ * the highest severity level reached, and serializes any attached error.
159
+ *
160
+ * Prefer `finish()` for HTTP request contexts where you have a status code.
161
+ * @param typeOverride Override the log type for this emission
162
+ */
163
+ emit(typeOverride?: DefaultLogTypes | T): void;
164
+ /**
165
+ * Record an error-level lifecycle log entry and attach the error.
166
+ * Escalates the event level to "error".
167
+ * @param message Description of what went wrong
168
+ * @param error The error that occurred
169
+ * @param context Optional structured context
170
+ * @returns `this` for chaining
171
+ */
172
+ error(message: string, error?: Error, context?: Record<string, unknown>): this;
173
+ /**
174
+ * Finish and emit the wide event with HTTP context.
175
+ * Sets the response status and optional error before emitting.
176
+ * @example
177
+ * ```typescript
178
+ * ev.finish({ status: 200 });
179
+ * ev.finish({ status: 500, error: new Error("DB timeout") });
180
+ * ```
181
+ * @param options Status code and/or error
182
+ */
183
+ finish(options?: WideEventFinishOptions): void;
184
+ /**
185
+ * Get a read-only snapshot of the accumulated data.
186
+ */
187
+ getData(): Readonly<TData>;
188
+ /**
189
+ * Get the current severity level of the event.
190
+ * The level auto-escalates as `warn()` or `error()` entries are added.
191
+ */
192
+ getLevel(): WideEventLevel;
193
+ /**
194
+ * Get a read-only copy of the request lifecycle log entries.
195
+ */
196
+ getRequestLogs(): ReadonlyArray<RequestLogEntry>;
197
+ /**
198
+ * Record an info-level lifecycle log entry.
199
+ * Does not escalate the event level.
200
+ * @param message Description of what happened
201
+ * @param context Optional structured context
202
+ * @returns `this` for chaining
203
+ */
204
+ info(message: string, context?: Record<string, unknown>): this;
205
+ /**
206
+ * Accumulate context into the wide event via deep merge.
207
+ * Call as many times as needed throughout the operation.
208
+ * @example
209
+ * ```typescript
210
+ * ev.set({ user: { id: 1 } });
211
+ * ev.set({ user: { plan: "pro" } });
212
+ * // data = { user: { id: 1, plan: "pro" } }
213
+ * ```
214
+ * @param data Partial data to merge into the event
215
+ * @returns `this` for chaining
216
+ */
217
+ set(data: DeepPartial<TData>): this;
218
+ /**
219
+ * Attach an error to the event. Automatically escalates the event
220
+ * level to "error".
221
+ * @param error The error to attach
222
+ * @returns `this` for chaining
223
+ */
224
+ setError(error: Error): this;
225
+ /**
226
+ * Set the HTTP response status code.
227
+ * @param status HTTP status code
228
+ * @returns `this` for chaining
229
+ */
230
+ setStatus(status: number): this;
231
+ /**
232
+ * Record a warn-level lifecycle log entry.
233
+ * Escalates the event level to "warn" (unless already "error").
234
+ * @param message Description of the warning
235
+ * @param context Optional structured context
236
+ * @returns `this` for chaining
237
+ */
238
+ warn(message: string, context?: Record<string, unknown>): this;
239
+ /**
240
+ * Disposable implementation. Auto-emits the event if `autoEmit` is true
241
+ * and the event hasn't been manually emitted yet.
242
+ *
243
+ * Enables usage with TC39 Explicit Resource Management:
244
+ * ```typescript
245
+ * using ev = createWideEvent({ pail: logger, name: "api.checkout" });
246
+ * ev.set({ user: { id: 1 } });
247
+ * // auto-emits here when scope exits
248
+ * ```
249
+ */
250
+ [Symbol.dispose](): void;
251
+ /**
252
+ * Add an entry to the request lifecycle log and escalate level if needed.
253
+ */
254
+ private addLogEntry;
255
+ /**
256
+ * Escalate the event level if the new level has higher severity.
257
+ */
258
+ private escalateLevel;
259
+ }
260
+ /**
261
+ * Create a wide event logger that accumulates context and emits a single
262
+ * comprehensive log event through pail.
263
+ * @template TData - Shape of the accumulated event data
264
+ * @template T - Custom logger type names from the pail instance
265
+ * @param options Configuration options
266
+ * @returns A new WideEvent instance
267
+ * @example
268
+ * ```typescript
269
+ * import { createPail } from "@visulima/pail";
270
+ * import { createWideEvent } from "@visulima/pail/wide-event";
271
+ *
272
+ * const logger = createPail();
273
+ *
274
+ * // In a request handler:
275
+ * const ev = createWideEvent({ pail: logger, name: "api.checkout" });
276
+ *
277
+ * ev.set({ user: { id: 1, plan: "pro" } });
278
+ * ev.info("Validated cart", { itemCount: 3 });
279
+ * ev.set({ cart: { id: 42, items: 3, total: 9999 } });
280
+ * ev.info("Payment processed");
281
+ * ev.finish({ status: 200 });
282
+ *
283
+ * // Emits a single structured log:
284
+ * // {
285
+ * // event: "api.checkout",
286
+ * // timestamp: "2025-01-24T10:23:45.612Z",
287
+ * // duration: "127ms",
288
+ * // duration_ms: 127,
289
+ * // status: 200,
290
+ * // user: { id: 1, plan: "pro" },
291
+ * // cart: { id: 42, items: 3, total: 9999 },
292
+ * // requestLogs: [
293
+ * // { level: "info", message: "Validated cart", timestamp: "...", context: { itemCount: 3 } },
294
+ * // { level: "info", message: "Payment processed", timestamp: "..." }
295
+ * // ]
296
+ * // }
297
+ * ```
298
+ */
299
+ export declare const createWideEvent: <TData extends Record<string, unknown> = Record<string, unknown>, T extends string = string>(options: WideEventOptions<T>) => WideEvent<TData, T>;
300
+ export {};
@@ -0,0 +1,281 @@
1
+ const LEVEL_PRIORITY = {
2
+ debug: 0,
3
+ error: 3,
4
+ info: 1,
5
+ warn: 2
6
+ };
7
+ const LEVEL_TO_LOG_TYPE = {
8
+ debug: "debug",
9
+ error: "error",
10
+ info: "info",
11
+ warn: "warn"
12
+ };
13
+ const deepMerge = (target, source) => {
14
+ const result = { ...target };
15
+ for (const key of Object.keys(source)) {
16
+ const sourceValue = source[key];
17
+ const targetValue = result[key];
18
+ if (sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) && targetValue !== null && typeof targetValue === "object" && !Array.isArray(targetValue)) {
19
+ result[key] = deepMerge(targetValue, sourceValue);
20
+ } else {
21
+ result[key] = sourceValue;
22
+ }
23
+ }
24
+ return result;
25
+ };
26
+ const formatDuration = (ms) => {
27
+ if (ms < 1e3) {
28
+ return `${ms}ms`;
29
+ }
30
+ return `${(ms / 1e3).toFixed(2)}s`;
31
+ };
32
+ const serializeError = (error) => {
33
+ const serialized = {
34
+ message: error.message,
35
+ name: error.name
36
+ };
37
+ if (error.stack) {
38
+ serialized.stack = error.stack;
39
+ }
40
+ const errorWithStatus = error;
41
+ if (errorWithStatus.status !== void 0) {
42
+ serialized.status = errorWithStatus.status;
43
+ } else if (errorWithStatus.statusCode !== void 0) {
44
+ serialized.status = errorWithStatus.statusCode;
45
+ }
46
+ if (errorWithStatus.data !== void 0) {
47
+ serialized.data = errorWithStatus.data;
48
+ }
49
+ if (error.cause instanceof Error) {
50
+ serialized.cause = serializeError(error.cause);
51
+ }
52
+ return serialized;
53
+ };
54
+ class WideEvent {
55
+ name;
56
+ autoEmit;
57
+ data;
58
+ emitted;
59
+ attachedError;
60
+ level;
61
+ pail;
62
+ requestLogs;
63
+ service;
64
+ startTime;
65
+ status;
66
+ timestamp;
67
+ type;
68
+ constructor(options) {
69
+ this.name = options.name;
70
+ this.pail = options.pail;
71
+ this.data = {};
72
+ this.startTime = performance.now();
73
+ this.timestamp = (/* @__PURE__ */ new Date()).toISOString();
74
+ this.emitted = false;
75
+ this.autoEmit = options.autoEmit ?? true;
76
+ this.type = options.type ?? "info";
77
+ this.level = "info";
78
+ this.requestLogs = [];
79
+ this.service = options.service;
80
+ }
81
+ /**
82
+ * Record a debug-level lifecycle log entry.
83
+ * Does not escalate the event level.
84
+ * @param message Description of what happened
85
+ * @param context Optional structured context
86
+ * @returns `this` for chaining
87
+ */
88
+ debug(message, context) {
89
+ return this.addLogEntry("debug", message, context);
90
+ }
91
+ /**
92
+ * Emit the wide event through the pail logger. Can only be called once;
93
+ * subsequent calls are no-ops.
94
+ *
95
+ * Automatically calculates duration, determines the log type based on
96
+ * the highest severity level reached, and serializes any attached error.
97
+ *
98
+ * Prefer `finish()` for HTTP request contexts where you have a status code.
99
+ * @param typeOverride Override the log type for this emission
100
+ */
101
+ emit(typeOverride) {
102
+ if (this.emitted) {
103
+ return;
104
+ }
105
+ this.emitted = true;
106
+ const durationMs = Math.round(performance.now() - this.startTime);
107
+ const resolvedLevel = this.attachedError ? "error" : this.level;
108
+ const type = typeOverride ?? LEVEL_TO_LOG_TYPE[resolvedLevel] ?? this.type;
109
+ const payload = {
110
+ duration: formatDuration(durationMs),
111
+ duration_ms: durationMs,
112
+ event: this.name,
113
+ timestamp: this.timestamp,
114
+ ...this.data
115
+ };
116
+ if (this.service) {
117
+ payload.service = this.service;
118
+ }
119
+ if (this.status !== void 0) {
120
+ payload.status = this.status;
121
+ }
122
+ if (this.attachedError) {
123
+ payload.error = serializeError(this.attachedError);
124
+ }
125
+ if (this.requestLogs.length > 0) {
126
+ payload.requestLogs = this.requestLogs;
127
+ }
128
+ const logFunction = this.pail[type];
129
+ logFunction({ message: payload });
130
+ }
131
+ /**
132
+ * Record an error-level lifecycle log entry and attach the error.
133
+ * Escalates the event level to "error".
134
+ * @param message Description of what went wrong
135
+ * @param error The error that occurred
136
+ * @param context Optional structured context
137
+ * @returns `this` for chaining
138
+ */
139
+ error(message, error, context) {
140
+ if (error) {
141
+ this.attachedError = error;
142
+ }
143
+ return this.addLogEntry("error", message, context);
144
+ }
145
+ /**
146
+ * Finish and emit the wide event with HTTP context.
147
+ * Sets the response status and optional error before emitting.
148
+ * @example
149
+ * ```typescript
150
+ * ev.finish({ status: 200 });
151
+ * ev.finish({ status: 500, error: new Error("DB timeout") });
152
+ * ```
153
+ * @param options Status code and/or error
154
+ */
155
+ finish(options) {
156
+ if (options?.status !== void 0) {
157
+ this.status = options.status;
158
+ }
159
+ if (options?.error) {
160
+ this.attachedError = options.error;
161
+ }
162
+ this.emit();
163
+ }
164
+ /**
165
+ * Get a read-only snapshot of the accumulated data.
166
+ */
167
+ getData() {
168
+ return this.data;
169
+ }
170
+ /**
171
+ * Get the current severity level of the event.
172
+ * The level auto-escalates as `warn()` or `error()` entries are added.
173
+ */
174
+ getLevel() {
175
+ return this.attachedError ? "error" : this.level;
176
+ }
177
+ /**
178
+ * Get a read-only copy of the request lifecycle log entries.
179
+ */
180
+ getRequestLogs() {
181
+ return this.requestLogs;
182
+ }
183
+ /**
184
+ * Record an info-level lifecycle log entry.
185
+ * Does not escalate the event level.
186
+ * @param message Description of what happened
187
+ * @param context Optional structured context
188
+ * @returns `this` for chaining
189
+ */
190
+ info(message, context) {
191
+ return this.addLogEntry("info", message, context);
192
+ }
193
+ /**
194
+ * Accumulate context into the wide event via deep merge.
195
+ * Call as many times as needed throughout the operation.
196
+ * @example
197
+ * ```typescript
198
+ * ev.set({ user: { id: 1 } });
199
+ * ev.set({ user: { plan: "pro" } });
200
+ * // data = { user: { id: 1, plan: "pro" } }
201
+ * ```
202
+ * @param data Partial data to merge into the event
203
+ * @returns `this` for chaining
204
+ */
205
+ set(data) {
206
+ this.data = deepMerge(this.data, data);
207
+ return this;
208
+ }
209
+ /**
210
+ * Attach an error to the event. Automatically escalates the event
211
+ * level to "error".
212
+ * @param error The error to attach
213
+ * @returns `this` for chaining
214
+ */
215
+ setError(error) {
216
+ this.attachedError = error;
217
+ return this;
218
+ }
219
+ /**
220
+ * Set the HTTP response status code.
221
+ * @param status HTTP status code
222
+ * @returns `this` for chaining
223
+ */
224
+ setStatus(status) {
225
+ this.status = status;
226
+ return this;
227
+ }
228
+ /**
229
+ * Record a warn-level lifecycle log entry.
230
+ * Escalates the event level to "warn" (unless already "error").
231
+ * @param message Description of the warning
232
+ * @param context Optional structured context
233
+ * @returns `this` for chaining
234
+ */
235
+ warn(message, context) {
236
+ return this.addLogEntry("warn", message, context);
237
+ }
238
+ /**
239
+ * Disposable implementation. Auto-emits the event if `autoEmit` is true
240
+ * and the event hasn't been manually emitted yet.
241
+ *
242
+ * Enables usage with TC39 Explicit Resource Management:
243
+ * ```typescript
244
+ * using ev = createWideEvent({ pail: logger, name: "api.checkout" });
245
+ * ev.set({ user: { id: 1 } });
246
+ * // auto-emits here when scope exits
247
+ * ```
248
+ */
249
+ [Symbol.dispose]() {
250
+ if (this.autoEmit && !this.emitted) {
251
+ this.emit();
252
+ }
253
+ }
254
+ /**
255
+ * Add an entry to the request lifecycle log and escalate level if needed.
256
+ */
257
+ addLogEntry(level, message, context) {
258
+ const entry = {
259
+ level,
260
+ message,
261
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
262
+ };
263
+ if (context) {
264
+ entry.context = context;
265
+ }
266
+ this.requestLogs.push(entry);
267
+ this.escalateLevel(level);
268
+ return this;
269
+ }
270
+ /**
271
+ * Escalate the event level if the new level has higher severity.
272
+ */
273
+ escalateLevel(level) {
274
+ if ((LEVEL_PRIORITY[level] ?? 0) > (LEVEL_PRIORITY[this.level] ?? 0)) {
275
+ this.level = level;
276
+ }
277
+ }
278
+ }
279
+ const createWideEvent = (options) => new WideEvent(options);
280
+
281
+ export { WideEvent, createWideEvent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/pail",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.8",
4
4
  "description": "Highly configurable Logger for Node.js, Edge and Browser.",
5
5
  "keywords": [
6
6
  "ansi",
@@ -114,6 +114,18 @@
114
114
  "types": "./dist/processor/opentelemetry-processor.d.ts",
115
115
  "default": "./dist/processor/opentelemetry-processor.js"
116
116
  },
117
+ "./processor/sampling": {
118
+ "types": "./dist/processor/sampling-processor.d.ts",
119
+ "default": "./dist/processor/sampling-processor.js"
120
+ },
121
+ "./processor/environment": {
122
+ "types": "./dist/processor/environment-processor.d.ts",
123
+ "default": "./dist/processor/environment-processor.js"
124
+ },
125
+ "./error": {
126
+ "types": "./dist/error.d.ts",
127
+ "default": "./dist/error.js"
128
+ },
117
129
  "./reporter/file": {
118
130
  "types": "./dist/reporter/file/json-file-reporter.d.ts",
119
131
  "default": "./dist/reporter/file/json-file-reporter.js"
@@ -194,6 +206,34 @@
194
206
  "types": "./dist/object-tree.d.ts",
195
207
  "default": "./dist/object-tree.js"
196
208
  },
209
+ "./wide-event": {
210
+ "types": "./dist/wide-event.d.ts",
211
+ "default": "./dist/wide-event.js"
212
+ },
213
+ "./middleware/express": {
214
+ "types": "./dist/middleware/express.d.ts",
215
+ "default": "./dist/middleware/express.js"
216
+ },
217
+ "./middleware/fastify": {
218
+ "types": "./dist/middleware/fastify.d.ts",
219
+ "default": "./dist/middleware/fastify.js"
220
+ },
221
+ "./middleware/hono": {
222
+ "types": "./dist/middleware/hono.d.ts",
223
+ "default": "./dist/middleware/hono.js"
224
+ },
225
+ "./middleware/elysia": {
226
+ "types": "./dist/middleware/elysia.d.ts",
227
+ "default": "./dist/middleware/elysia.js"
228
+ },
229
+ "./middleware/sveltekit": {
230
+ "types": "./dist/middleware/sveltekit.d.ts",
231
+ "default": "./dist/middleware/sveltekit.js"
232
+ },
233
+ "./middleware/next": {
234
+ "types": "./dist/middleware/next/handler.d.ts",
235
+ "default": "./dist/middleware/next/handler.js"
236
+ },
197
237
  "./package.json": "./package.json"
198
238
  },
199
239
  "files": [
@@ -203,25 +243,50 @@
203
243
  "LICENSE.md"
204
244
  ],
205
245
  "dependencies": {
206
- "@visulima/colorize": "2.0.0-alpha.5",
207
- "type-fest": "^5.4.4"
246
+ "@visulima/colorize": "2.0.0-alpha.6",
247
+ "type-fest": "5.5.0"
208
248
  },
209
249
  "peerDependencies": {
210
250
  "@opentelemetry/api": "^1.9",
211
- "@visulima/redact": "3.0.0-alpha.5",
212
- "rotating-file-stream": "^3.2.7"
251
+ "@sveltejs/kit": ">=2.0",
252
+ "@visulima/redact": "3.0.0-alpha.6",
253
+ "elysia": ">=1.0",
254
+ "express": ">=4.0",
255
+ "fastify": ">=4.0",
256
+ "hono": ">=4.0",
257
+ "next": ">=14.0",
258
+ "rotating-file-stream": "3.2.9"
213
259
  },
214
260
  "peerDependenciesMeta": {
215
261
  "@opentelemetry/api": {
216
262
  "optional": true
217
263
  },
264
+ "@sveltejs/kit": {
265
+ "optional": true
266
+ },
218
267
  "@visulima/redact": {
219
268
  "optional": true
220
269
  },
270
+ "elysia": {
271
+ "optional": true
272
+ },
273
+ "express": {
274
+ "optional": true
275
+ },
276
+ "fastify": {
277
+ "optional": true
278
+ },
279
+ "hono": {
280
+ "optional": true
281
+ },
282
+ "next": {
283
+ "optional": true
284
+ },
221
285
  "rotating-file-stream": {
222
286
  "optional": true
223
287
  }
224
288
  },
289
+ "optionalDependencies": {},
225
290
  "engines": {
226
291
  "node": ">=22.13 <=25.x"
227
292
  },