@visulima/pail 4.0.0-alpha.10 → 4.0.0-alpha.12
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.
- package/CHANGELOG.md +57 -0
- package/LICENSE.md +143 -931
- package/dist/error.d.ts +95 -96
- package/dist/index.browser.d.ts +557 -47
- package/dist/index.browser.js +2 -2
- package/dist/index.server.d.ts +722 -65
- package/dist/index.server.js +27 -410
- package/dist/middleware/elysia.d.ts +65 -63
- package/dist/middleware/elysia.js +2 -2
- package/dist/middleware/express.d.ts +73 -71
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +69 -67
- package/dist/middleware/fastify.js +2 -2
- package/dist/middleware/hono.d.ts +74 -72
- package/dist/middleware/next/handler.d.ts +101 -34
- package/dist/middleware/sveltekit.d.ts +100 -98
- package/dist/object-tree.d.ts +67 -70
- package/dist/packem_shared/{AbstractJsonReporter-DlugSJpY.js → AbstractJsonReporter-BO8Calb4.js} +1 -5
- package/dist/packem_shared/{AbstractJsonReporter-CjtVgHbU.js → AbstractJsonReporter-nOj0Ft1F.js} +1 -5
- package/dist/packem_shared/{JsonReporter-Dbw82ewj.js → JsonReporter-CCmj7oYL.js} +1 -1
- package/dist/packem_shared/{JsonReporter-BgPvIyC2.js → JsonReporter-Ck2PIAEw.js} +2 -2
- package/dist/packem_shared/{PrettyReporter-C2dCzIaf.js → PrettyReporter-CIbrmjUV.js} +2 -4
- package/dist/packem_shared/{PrettyReporter-gMqa7j_m.js → PrettyReporter-CNJEO9g7.js} +1250 -15
- package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
- package/dist/packem_shared/{abstract-pretty-reporter-szQO-IgK.js → abstract-pretty-reporter-CkqCt5hg.js} +2300 -2298
- package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
- package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
- package/dist/packem_shared/types.d-BeLumqgD.d.ts +246 -0
- package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
- package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
- package/dist/packem_shared/wide-event.d-B-t8ZnhI.d.ts +704 -0
- package/dist/packem_shared/{write-stream-BuFtjATz.js → write-stream-MDqyXmc_.js} +1 -1
- package/dist/processor/caller/caller-processor.d.ts +49 -47
- package/dist/processor/caller/caller-processor.js +1 -1
- package/dist/processor/environment-processor.d.ts +113 -113
- package/dist/processor/message-formatter-processor.d.ts +51 -49
- package/dist/processor/message-formatter-processor.js +2 -2
- package/dist/processor/opentelemetry-processor.d.ts +69 -66
- package/dist/processor/redact-processor.d.ts +60 -41
- package/dist/processor/sampling-processor.d.ts +102 -101
- package/dist/reporter/file/json-file-reporter.d.ts +91 -42
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
- package/dist/reporter/http/abstract-http-reporter.js +1 -1
- package/dist/reporter/http/http-reporter.d.ts +40 -36
- package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
- package/dist/reporter/http/http-reporter.edge-light.js +1 -5
- package/dist/reporter/json/index.browser.d.ts +99 -3
- package/dist/reporter/json/index.browser.js +2 -2
- package/dist/reporter/json/index.d.ts +51 -3
- package/dist/reporter/json/index.js +2 -2
- package/dist/reporter/pretty/index.browser.d.ts +106 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +219 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
- package/dist/reporter/simple/simple-reporter.server.js +3 -2
- package/dist/wide-event.d.ts +5 -300
- package/dist/wide-event.js +3 -2
- package/package.json +9 -21
- package/dist/constants.d.ts +0 -37
- package/dist/interactive/index.d.ts +0 -2
- package/dist/interactive/index.js +0 -2
- package/dist/interactive/interactive-manager.d.ts +0 -108
- package/dist/interactive/interactive-stream-hook.d.ts +0 -68
- package/dist/middleware/next/middleware.d.ts +0 -59
- package/dist/middleware/next/storage.d.ts +0 -14
- package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
- package/dist/middleware/shared/headers.d.ts +0 -14
- package/dist/middleware/shared/routes.d.ts +0 -30
- package/dist/middleware/shared/storage.d.ts +0 -29
- package/dist/packem_shared/InteractiveManager-CowYA3Hx.js +0 -178
- package/dist/packem_shared/InteractiveStreamHook-BypRlYTX.js +0 -133
- package/dist/packem_shared/Spinner-Cokext9b.js +0 -2183
- package/dist/packem_shared/getBarChar-D7JfmdTr.js +0 -459
- package/dist/packem_shared/index-BEfVUy9P.js +0 -1256
- package/dist/pail.browser.d.ts +0 -412
- package/dist/pail.server.d.ts +0 -233
- package/dist/processor/caller/get-caller-filename.d.ts +0 -23
- package/dist/progress-bar.d.ts +0 -145
- package/dist/progress-bar.js +0 -459
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
- package/dist/reporter/http/utils/compression.d.ts +0 -7
- package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
- package/dist/reporter/http/utils/retry.d.ts +0 -27
- package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
- package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
- package/dist/reporter/json/json-reporter.server.d.ts +0 -50
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
- package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
- package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
- package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
- package/dist/reporter/utils/format-label.d.ts +0 -3
- package/dist/spinner.d.ts +0 -220
- package/dist/spinner.js +0 -2183
- package/dist/types.d.ts +0 -241
- package/dist/utils/ansi-escapes.d.ts +0 -4
- package/dist/utils/arrayify.d.ts +0 -2
- package/dist/utils/get-longest-badge.d.ts +0 -4
- package/dist/utils/get-longest-label.d.ts +0 -4
- package/dist/utils/merge-types.d.ts +0 -4
- package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
- package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
- package/dist/utils/write-stream.d.ts +0 -2
package/dist/types.d.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import type { AnsiColors } from "@visulima/colorize";
|
|
2
|
-
import type { stringify } from "safe-stable-stringify";
|
|
3
|
-
import type { LiteralUnion, Primitive } from "type-fest";
|
|
4
|
-
import type InteractiveManager from "./interactive/interactive-manager.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* Global namespace for extending Pail's metadata interface.
|
|
7
|
-
*
|
|
8
|
-
* This global declaration allows other packages and applications to extend
|
|
9
|
-
* the Meta interface with custom properties by declaring additional properties
|
|
10
|
-
* in the VisulimaPail.CustomMeta interface.
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* declare global {
|
|
14
|
-
* namespace VisulimaPail {
|
|
15
|
-
* interface CustomMeta<L> {
|
|
16
|
-
* userId?: string;
|
|
17
|
-
* requestId?: string;
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
declare global {
|
|
24
|
-
namespace VisulimaPail {
|
|
25
|
-
interface CustomMeta<L> {
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Metadata object containing all information about a log entry.
|
|
31
|
-
*
|
|
32
|
-
* This interface defines the structure of metadata that is passed to reporters
|
|
33
|
-
* and processors. It contains all the contextual information about a log message
|
|
34
|
-
* including the message itself, timing information, error details, and more.
|
|
35
|
-
* @template L - The log level type
|
|
36
|
-
*/
|
|
37
|
-
export interface Meta<L> extends VisulimaPail.CustomMeta<L> {
|
|
38
|
-
badge: string | undefined;
|
|
39
|
-
context: any[] | undefined;
|
|
40
|
-
date: Date | string;
|
|
41
|
-
error: Error | undefined;
|
|
42
|
-
groups: string[];
|
|
43
|
-
label: string | undefined;
|
|
44
|
-
message: Primitive | ReadonlyArray<unknown> | Record<PropertyKey, unknown>;
|
|
45
|
-
prefix: string | undefined;
|
|
46
|
-
repeated?: number;
|
|
47
|
-
scope: string[] | undefined;
|
|
48
|
-
suffix: string | undefined;
|
|
49
|
-
traceError: Error | undefined;
|
|
50
|
-
type: {
|
|
51
|
-
level: ExtendedRfc5424LogLevels | L;
|
|
52
|
-
name: string;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Extended RFC 5424 Log Levels.
|
|
57
|
-
*
|
|
58
|
-
* Standard syslog severity levels as defined in RFC 5424, plus additional
|
|
59
|
-
* levels commonly used in modern applications. Each level has a numeric
|
|
60
|
-
* priority where lower numbers indicate higher severity.
|
|
61
|
-
* @see https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
|
|
62
|
-
*/
|
|
63
|
-
export type ExtendedRfc5424LogLevels = "alert" | "critical" | "debug" | "emergency" | "error" | "informational" | "notice" | "trace" | "warning";
|
|
64
|
-
/**
|
|
65
|
-
* Default Log Types.
|
|
66
|
-
*
|
|
67
|
-
* Predefined semantic log types that provide meaningful categorization
|
|
68
|
-
* for different kinds of log messages. Each type has associated styling
|
|
69
|
-
* and log level configuration.
|
|
70
|
-
*/
|
|
71
|
-
export type DefaultLogTypes = "alert" | "await" | "complete" | "critical" | "debug" | "emergency" | "error" | "info" | "log" | "notice" | "pending" | "start" | "stop" | "success" | "trace" | "wait" | "warn" | "warning" | "watch";
|
|
72
|
-
/**
|
|
73
|
-
* Logger Function Type.
|
|
74
|
-
*
|
|
75
|
-
* Represents a logging function that can accept either a structured Message object
|
|
76
|
-
* or multiple arguments in the traditional console.log style.
|
|
77
|
-
*/
|
|
78
|
-
export interface LoggerFunction {
|
|
79
|
-
(message: Message): void;
|
|
80
|
-
(...message: any[]): void;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Logger Configuration.
|
|
84
|
-
*
|
|
85
|
-
* Configuration object that defines how a specific logger type should behave,
|
|
86
|
-
* including its visual appearance and log level.
|
|
87
|
-
* @template L - The log level type
|
|
88
|
-
*/
|
|
89
|
-
export interface LoggerConfiguration<L extends string> {
|
|
90
|
-
badge?: string;
|
|
91
|
-
color?: AnsiColors;
|
|
92
|
-
label: string;
|
|
93
|
-
logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Logger Types Configuration.
|
|
97
|
-
*
|
|
98
|
-
* A record mapping logger type names to their configurations.
|
|
99
|
-
* @template T - Custom logger type names
|
|
100
|
-
* @template L - Log level types
|
|
101
|
-
*/
|
|
102
|
-
export type LoggerTypesConfig<T extends string, L extends string> = Record<T, Partial<LoggerConfiguration<L>>>;
|
|
103
|
-
/**
|
|
104
|
-
* Default Logger Types Configuration.
|
|
105
|
-
*
|
|
106
|
-
* A complete mapping of all default log types to their full configurations.
|
|
107
|
-
* @template L - Log level types
|
|
108
|
-
*/
|
|
109
|
-
export type DefaultLoggerTypes<L extends string = string> = Record<DefaultLogTypes, LoggerConfiguration<L>>;
|
|
110
|
-
/**
|
|
111
|
-
* Read-only Metadata.
|
|
112
|
-
*
|
|
113
|
-
* Immutable version of the Meta interface for use in reporters.
|
|
114
|
-
* @template L - The log level type
|
|
115
|
-
*/
|
|
116
|
-
export type ReadonlyMeta<L extends string> = Readonly<Meta<L>>;
|
|
117
|
-
/**
|
|
118
|
-
* Reporter Interface.
|
|
119
|
-
*
|
|
120
|
-
* Base interface for all reporters. Reporters are responsible for
|
|
121
|
-
* outputting log messages to various destinations (console, files, etc.).
|
|
122
|
-
* @template L - The log level type
|
|
123
|
-
*/
|
|
124
|
-
export interface Reporter<L extends string> {
|
|
125
|
-
log: (meta: ReadonlyMeta<L>) => void;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Stream-Aware Reporter Interface.
|
|
129
|
-
*
|
|
130
|
-
* Extends Reporter with the ability to work with Node.js streams.
|
|
131
|
-
* Used for server-side reporters that need to write to stdout/stderr.
|
|
132
|
-
* @template L - The log level type
|
|
133
|
-
*/
|
|
134
|
-
export interface StreamAwareReporter<L extends string> extends Reporter<L> {
|
|
135
|
-
/** Set the stderr stream for error output */
|
|
136
|
-
setStderr: (stderr: NodeJS.WriteStream) => void;
|
|
137
|
-
/** Set the stdout stream for standard output */
|
|
138
|
-
setStdout: (stdout: NodeJS.WriteStream) => void;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Logger Types Aware Reporter Interface.
|
|
142
|
-
*
|
|
143
|
-
* Extends Reporter with the ability to receive logger type configurations.
|
|
144
|
-
* Allows reporters to customize their output based on logger types.
|
|
145
|
-
* @template T - Custom logger type names
|
|
146
|
-
* @template L - The log level type
|
|
147
|
-
*/
|
|
148
|
-
export interface LoggerTypesAwareReporter<T extends string, L extends string> extends Reporter<L> {
|
|
149
|
-
/** Set the logger types configuration */
|
|
150
|
-
setLoggerTypes: (types: LoggerTypesConfig<T, L> & Partial<LoggerTypesConfig<DefaultLogTypes, L>>) => void;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Stringify-Aware Reporter Interface.
|
|
154
|
-
*
|
|
155
|
-
* Extends Reporter with the ability to receive a custom stringify function.
|
|
156
|
-
* Useful for reporters that need to serialize complex objects.
|
|
157
|
-
* @template L - The log level type
|
|
158
|
-
*/
|
|
159
|
-
export interface StringifyAwareReporter<L extends string> extends Reporter<L> {
|
|
160
|
-
/** Set the stringify function for object serialization */
|
|
161
|
-
setStringify: (stringify: any) => void;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Interactive Stream Reporter Interface.
|
|
165
|
-
*
|
|
166
|
-
* Extends StreamAwareReporter with interactive capabilities for terminal UIs.
|
|
167
|
-
* Supports features like progress bars and dynamic updates.
|
|
168
|
-
* @template L - The log level type
|
|
169
|
-
*/
|
|
170
|
-
export interface InteractiveStreamReporter<L extends string> extends StreamAwareReporter<L> {
|
|
171
|
-
/** Set the interactive manager for handling interactive output */
|
|
172
|
-
setInteractiveManager: (manager?: InteractiveManager) => void;
|
|
173
|
-
/** Enable or disable interactive mode */
|
|
174
|
-
setIsInteractive: (interactive: boolean) => void;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Processor Interface.
|
|
178
|
-
*
|
|
179
|
-
* Base interface for all processors. Processors can modify or enhance
|
|
180
|
-
* log metadata before it reaches reporters.
|
|
181
|
-
* @template L - The log level type
|
|
182
|
-
*/
|
|
183
|
-
export interface Processor<L extends string> {
|
|
184
|
-
/** Process the log metadata */
|
|
185
|
-
process: (meta: Meta<L>) => Meta<L>;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Stringify-Aware Processor Interface.
|
|
189
|
-
*
|
|
190
|
-
* Extends Processor with the ability to receive a custom stringify function.
|
|
191
|
-
* Useful for processors that need to serialize complex objects.
|
|
192
|
-
* @template L - The log level type
|
|
193
|
-
*/
|
|
194
|
-
export interface StringifyAwareProcessor<L extends string> extends Processor<L> {
|
|
195
|
-
/** Set the stringify function for object serialization */
|
|
196
|
-
setStringify: (stringify: typeof JSON.stringify) => void;
|
|
197
|
-
}
|
|
198
|
-
export interface ConstructorOptions<T extends string, L extends string> {
|
|
199
|
-
disabled?: boolean;
|
|
200
|
-
logLevel?: LiteralUnion<ExtendedRfc5424LogLevels, L>;
|
|
201
|
-
logLevels?: Partial<Record<ExtendedRfc5424LogLevels, number>> & Record<L, number>;
|
|
202
|
-
messages?: {
|
|
203
|
-
timerEnd?: string;
|
|
204
|
-
timerStart?: string;
|
|
205
|
-
};
|
|
206
|
-
processors?: Processor<L>[];
|
|
207
|
-
rawReporter?: Reporter<L>;
|
|
208
|
-
reporters?: Reporter<L>[];
|
|
209
|
-
scope?: string[] | string;
|
|
210
|
-
throttle?: number;
|
|
211
|
-
throttleMin?: number;
|
|
212
|
-
types?: LoggerTypesConfig<T, L> & Partial<LoggerTypesConfig<DefaultLogTypes, L>>;
|
|
213
|
-
}
|
|
214
|
-
export interface ServerConstructorOptions<T extends string, L extends string> extends ConstructorOptions<T, L> {
|
|
215
|
-
interactive?: boolean;
|
|
216
|
-
stderr: NodeJS.WriteStream;
|
|
217
|
-
stdout: NodeJS.WriteStream;
|
|
218
|
-
}
|
|
219
|
-
export type Message = {
|
|
220
|
-
context?: any[];
|
|
221
|
-
message: any;
|
|
222
|
-
prefix?: string;
|
|
223
|
-
suffix?: string;
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* Internal interface for parent logger optimization properties.
|
|
227
|
-
*
|
|
228
|
-
* These properties are used internally to optimize child logger creation
|
|
229
|
-
* by reusing parent logger's computed values when they haven't changed.
|
|
230
|
-
* @internal
|
|
231
|
-
*/
|
|
232
|
-
export interface ParentLoggerOptimization<T extends string = string, L extends string = string> {
|
|
233
|
-
parentLogLevels?: Record<string, number>;
|
|
234
|
-
parentLongestLabel?: string;
|
|
235
|
-
parentMessages?: {
|
|
236
|
-
timerEnd: string;
|
|
237
|
-
timerStart: string;
|
|
238
|
-
};
|
|
239
|
-
parentStringify?: typeof stringify;
|
|
240
|
-
parentTypes?: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
241
|
-
}
|
package/dist/utils/arrayify.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { LiteralUnion } from "type-fest";
|
|
2
|
-
import type { DefaultLogTypes, LoggerTypesConfig } from "../types.d.ts";
|
|
3
|
-
declare const getLongestBadge: <L extends string, T extends string>(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>) => string;
|
|
4
|
-
export default getLongestBadge;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { LiteralUnion } from "type-fest";
|
|
2
|
-
import type { DefaultLogTypes, LoggerTypesConfig } from "../types.d.ts";
|
|
3
|
-
declare const getLongestLabel: <L extends string, T extends string>(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>) => string;
|
|
4
|
-
export default getLongestLabel;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { LiteralUnion } from "type-fest";
|
|
2
|
-
import type { DefaultLoggerTypes, DefaultLogTypes, LoggerTypesConfig } from "../types.d.ts";
|
|
3
|
-
declare const mergeTypes: <L extends string, T extends string>(standard: DefaultLoggerTypes<L>, custom: LoggerTypesConfig<T, L>) => LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
4
|
-
export default mergeTypes;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Writable } from "node:stream";
|
|
2
|
-
/**
|
|
3
|
-
* A handler for writable streams that only writes if the stream has finished
|
|
4
|
-
* processing or draining
|
|
5
|
-
*/
|
|
6
|
-
declare class SafeStreamHandler {
|
|
7
|
-
#private;
|
|
8
|
-
constructor(stream: Writable, name: string);
|
|
9
|
-
/**
|
|
10
|
-
* Writes `message` to the instance's internal stream.
|
|
11
|
-
* @param message Message to write
|
|
12
|
-
*/
|
|
13
|
-
write(message: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* Calls `end` on this instance's internal stream
|
|
16
|
-
*/
|
|
17
|
-
end(...arguments_: any[]): void;
|
|
18
|
-
get isReady(): boolean;
|
|
19
|
-
protected writeStream(message: string): void;
|
|
20
|
-
}
|
|
21
|
-
export default SafeStreamHandler;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { LiteralUnion } from "type-fest";
|
|
2
|
-
import type { ExtendedRfc5424LogLevels } from "../types.d.ts";
|
|
3
|
-
declare const writeConsoleLogBasedOnLevel: <L extends string = string>(level: LiteralUnion<ExtendedRfc5424LogLevels, L>) => (...data: any[]) => void;
|
|
4
|
-
export default writeConsoleLogBasedOnLevel;
|