@visulima/pail 3.2.0 → 3.2.2

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 (64) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE.md +3 -0
  3. package/dist/constants.d.ts +37 -0
  4. package/dist/index.browser.d.ts +47 -12
  5. package/dist/index.browser.js +1 -1
  6. package/dist/index.server.d.ts +65 -43
  7. package/dist/index.server.js +1 -3
  8. package/dist/interactive/index.d.ts +2 -28
  9. package/dist/interactive/interactive-manager.d.ts +108 -0
  10. package/dist/interactive/interactive-stream-hook.d.ts +68 -0
  11. package/dist/object-tree.d.ts +65 -7
  12. package/dist/packem_shared/{JsonReporter-BqWsVkHP.js → JsonReporter-C0AXk99i.js} +0 -2
  13. package/dist/packem_shared/{pail.browser-CPDOE_d1.js → pail.browser-CPjQrsyy.js} +3 -3
  14. package/dist/pail.browser.d.ts +412 -0
  15. package/dist/pail.server.d.ts +233 -0
  16. package/dist/processor/caller/caller-processor.d.ts +40 -7
  17. package/dist/processor/caller/get-caller-filename.d.ts +23 -0
  18. package/dist/processor/message-formatter-processor.d.ts +44 -9
  19. package/dist/processor/message-formatter-processor.js +1 -1
  20. package/dist/processor/opentelemetry-processor.d.ts +61 -10
  21. package/dist/processor/redact-processor.d.ts +39 -8
  22. package/dist/progress-bar.d.ts +75 -15
  23. package/dist/reporter/file/json-file-reporter.d.ts +39 -20
  24. package/dist/reporter/file/utils/rotating-file-stream.d.ts +48 -0
  25. package/dist/reporter/http/abstract-http-reporter.d.ts +125 -12
  26. package/dist/reporter/http/http-reporter.d.ts +36 -10
  27. package/dist/reporter/http/http-reporter.edge-light.d.ts +37 -165
  28. package/dist/reporter/http/utils/compression.d.ts +7 -0
  29. package/dist/reporter/http/utils/log-size-error.d.ts +30 -0
  30. package/dist/reporter/http/utils/retry.d.ts +27 -0
  31. package/dist/reporter/json/abstract-json-reporter.d.ts +61 -0
  32. package/dist/reporter/json/index.browser.d.ts +3 -13
  33. package/dist/reporter/json/index.d.ts +3 -16
  34. package/dist/reporter/json/index.js +1 -1
  35. package/dist/reporter/json/json-reporter.browser.d.ts +40 -0
  36. package/dist/reporter/json/json-reporter.server.d.ts +50 -0
  37. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +83 -0
  38. package/dist/reporter/pretty/index.browser.d.ts +2 -13
  39. package/dist/reporter/pretty/index.d.ts +2 -25
  40. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +36 -0
  41. package/dist/reporter/pretty/pretty-reporter.server.d.ts +70 -0
  42. package/dist/reporter/raw/raw-reporter.browser.d.ts +5 -0
  43. package/dist/reporter/raw/raw-reporter.server.d.ts +13 -0
  44. package/dist/reporter/simple/simple-reporter.server.d.ts +10 -14
  45. package/dist/reporter/utils/default-inspector-config.d.ts +3 -0
  46. package/dist/reporter/utils/format-label.d.ts +3 -0
  47. package/dist/spinner.d.ts +170 -104
  48. package/dist/spinner.js +89 -89
  49. package/dist/types.d.ts +241 -0
  50. package/dist/utils/ansi-escapes.d.ts +4 -0
  51. package/dist/utils/arrayify.d.ts +2 -0
  52. package/dist/utils/get-longest-badge.d.ts +4 -0
  53. package/dist/utils/get-longest-label.d.ts +4 -0
  54. package/dist/utils/merge-types.d.ts +4 -0
  55. package/dist/utils/stream/safe-stream-handler.d.ts +21 -0
  56. package/dist/utils/write-console-log-based-on-level.d.ts +4 -0
  57. package/dist/utils/write-stream.d.ts +2 -0
  58. package/package.json +3 -4
  59. package/dist/packem_shared/abstract-json-reporter-DiyVyU0j.d.ts +0 -22
  60. package/dist/packem_shared/abstract-pretty-reporter-BbOWXMCs.d.ts +0 -28
  61. package/dist/packem_shared/index.d-BR1GjZri.d.ts +0 -53
  62. package/dist/packem_shared/index.d-oxZvg_y7.d.ts +0 -20
  63. package/dist/packem_shared/pail.browser-By9KjOH7.d.ts +0 -69
  64. package/dist/packem_shared/types-D3ycu8-x.d.ts +0 -95
@@ -0,0 +1,241 @@
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 | undefined;
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 | undefined;
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: typeof JSON.stringify) => 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[] | undefined;
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
+ }
@@ -0,0 +1,4 @@
1
+ export declare const clearTerminal: string;
2
+ export declare const cursorHide: string;
3
+ export declare const cursorShow: string;
4
+ export declare const eraseLines: (count: number) => string;
@@ -0,0 +1,2 @@
1
+ declare const arrayify: <T>(x: T | T[]) => T[];
2
+ export default arrayify;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,21 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,2 @@
1
+ declare const writeStream: (data: string, stream: NodeJS.WriteStream) => boolean;
2
+ export default writeStream;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/pail",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "Highly configurable Logger for Node.js, Edge and Browser.",
5
5
  "keywords": [
6
6
  "ansi",
@@ -203,12 +203,11 @@
203
203
  "LICENSE.md"
204
204
  ],
205
205
  "dependencies": {
206
- "@visulima/colorize": "1.4.27",
207
- "type-fest": "^5.2.0"
206
+ "@visulima/colorize": "1.4.29"
208
207
  },
209
208
  "peerDependencies": {
210
209
  "@opentelemetry/api": "^1.9",
211
- "@visulima/redact": "2.0.3",
210
+ "@visulima/redact": "2.0.5",
212
211
  "rotating-file-stream": "^3.2.7"
213
212
  },
214
213
  "peerDependenciesMeta": {
@@ -1,22 +0,0 @@
1
- import { s as stringify } from './index.d-oxZvg_y7.js';
2
- import { LiteralUnion } from 'type-fest';
3
- import { f as StringifyAwareReporter, e as ReadonlyMeta, E as ExtendedRfc5424LogLevels } from './types-D3ycu8-x.js';
4
-
5
- type AbstractJsonReporterOptions = {
6
- error: Partial<{
7
- exclude?: string[];
8
- maxDepth?: number;
9
- useToJSON?: boolean;
10
- }>;
11
- };
12
- declare abstract class AbstractJsonReporter<L extends string = string> implements StringifyAwareReporter<L> {
13
- protected stringify: typeof stringify | undefined;
14
- protected errorOptions: AbstractJsonReporterOptions["error"];
15
- constructor(options?: Partial<AbstractJsonReporterOptions>);
16
- setStringify(function_: any): void;
17
- log(meta: ReadonlyMeta<L>): void;
18
- protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
19
- }
20
-
21
- export { AbstractJsonReporter as A };
22
- export type { AbstractJsonReporterOptions as a };
@@ -1,28 +0,0 @@
1
- import { LiteralUnion } from 'type-fest';
2
- import { c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes, e as ReadonlyMeta } from './types-D3ycu8-x.js';
3
-
4
- declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
5
- protected readonly styles: PrettyStyleOptions;
6
- protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
7
- protected constructor(options: Partial<PrettyStyleOptions>);
8
- setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
9
- abstract log(meta: ReadonlyMeta<L>): void;
10
- }
11
- type PrettyStyleOptions = {
12
- bold: {
13
- label: boolean;
14
- };
15
- dateFormatter: (date: Date) => string;
16
- messageLength: number | undefined;
17
- underline: {
18
- label: boolean;
19
- prefix: boolean;
20
- suffix: boolean;
21
- };
22
- uppercase: {
23
- label: boolean;
24
- };
25
- };
26
-
27
- export { AbstractPrettyReporter as A };
28
- export type { PrettyStyleOptions as P };
@@ -1,53 +0,0 @@
1
- import { LiteralUnion } from 'type-fest';
2
-
3
- type ColorizeMethod = (value: string) => string;
4
- type CodeFrameOptions = {
5
- color?: {
6
- gutter?: ColorizeMethod;
7
- marker?: ColorizeMethod;
8
- message?: ColorizeMethod;
9
- };
10
- linesAbove?: number;
11
- linesBelow?: number;
12
- message?: string;
13
- prefix?: string;
14
- showGutter?: boolean;
15
- showLineNumbers?: boolean;
16
- tabWidth?: number | false;
17
- };
18
-
19
- type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
20
- color: CodeFrameOptions["color"] & {
21
- fileLine: ColorizeMethod;
22
- hint: ColorizeMethod;
23
- method: ColorizeMethod;
24
- title: ColorizeMethod;
25
- };
26
- cwd: string;
27
- displayShortPath: boolean;
28
- filterStacktrace: ((line: string) => boolean) | undefined;
29
- framesMaxLimit: number;
30
- hideErrorCauseCodeView: boolean;
31
- hideErrorCodeView: boolean;
32
- hideErrorErrorsCodeView: boolean;
33
- hideErrorTitle: boolean;
34
- hideMessage: boolean;
35
- indentation: number | "\t";
36
- prefix: string;
37
- };
38
-
39
- interface Options {
40
- breakLength: number;
41
- customInspect: boolean;
42
- depth: number;
43
- indent: number | "\t" | undefined;
44
- maxArrayLength: number;
45
- numericSeparator: boolean;
46
- quoteStyle: "double" | "single";
47
- showHidden: boolean;
48
- showProxy: boolean;
49
- stylize: <S extends string>(value: S, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
50
- truncate: number;
51
- }
52
-
53
- export type { Options$1 as O, Options as a };
@@ -1,20 +0,0 @@
1
- type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object)
2
-
3
- interface StringifyOptions {
4
- bigint?: boolean,
5
- circularValue?: string | null | TypeErrorConstructor | ErrorConstructor,
6
- deterministic?: boolean | ((a: string, b: string) => number),
7
- maximumBreadth?: number,
8
- maximumDepth?: number,
9
- strict?: boolean,
10
- }
11
-
12
- declare function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined
13
- declare function stringify(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer, space?: string | number): string
14
- declare function stringify(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined
15
-
16
- declare namespace stringify {
17
- export function configure(options: StringifyOptions): typeof stringify
18
- }
19
-
20
- export { stringify as s };
@@ -1,69 +0,0 @@
1
- import { s as stringify } from './index.d-oxZvg_y7.js';
2
- import { LiteralUnion } from 'type-fest';
3
- import { C as ConstructorOptions, M as Meta, a as DefaultLogTypes, d as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, R as Reporter, b as LoggerFunction } from './types-D3ycu8-x.js';
4
-
5
- declare class PailBrowserImpl<T extends string = string, L extends string = string> {
6
- #private;
7
- protected timersMap: Map<string, number>;
8
- protected countMap: Map<string, number>;
9
- protected seqTimers: Set<string>;
10
- protected readonly lastLog: {
11
- count?: number;
12
- object?: Meta<L>;
13
- time?: Date;
14
- timeout?: ReturnType<typeof setTimeout>;
15
- };
16
- protected readonly logLevels: Record<string, number>;
17
- protected disabled: boolean;
18
- protected paused: boolean;
19
- protected messageQueue: {
20
- messageObject: any[];
21
- raw: boolean;
22
- type: LiteralUnion<DefaultLogTypes, T>;
23
- }[];
24
- protected scopeName: string[];
25
- protected readonly types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
26
- protected readonly longestLabel: string;
27
- protected readonly processors: Set<Processor<L>>;
28
- protected readonly generalLogLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;
29
- protected reporters: Set<Reporter<L>>;
30
- protected readonly throttle: number;
31
- protected readonly throttleMin: number;
32
- protected readonly stringify: typeof stringify;
33
- protected groups: string[];
34
- protected readonly startTimerMessage: string;
35
- protected readonly endTimerMessage: string;
36
- protected rawReporter: Reporter<L>;
37
- protected force: Record<string, LoggerFunction>;
38
- constructor(options: ConstructorOptions<T, L>);
39
- wrapConsole(): void;
40
- restoreConsole(): void;
41
- wrapException(): void;
42
- disable(): void;
43
- enable(): void;
44
- isEnabled(): boolean;
45
- pause(): void;
46
- resume(): void;
47
- scope<N extends string = T>(...name: string[]): PailBrowserType<N, L>;
48
- unscope(): void;
49
- child<N extends string = T, LC extends string = L>(options?: Partial<ConstructorOptions<N, LC>>): PailBrowserType<N, LC>;
50
- time(label?: string): void;
51
- timeLog(label?: string, ...data: unknown[]): void;
52
- timeEnd(label?: string): void;
53
- group(label?: string): void;
54
- groupEnd(): void;
55
- count(label?: string): void;
56
- countReset(label?: string): void;
57
- clear(): void;
58
- raw(message: string, ...arguments_: unknown[]): void;
59
- protected extendReporter(reporter: Reporter<L>): Reporter<L>;
60
- protected registerReporters(reporters: Reporter<L>[]): void;
61
- protected registerProcessors(processors: Processor<L>[]): void;
62
- protected logger(type: LiteralUnion<DefaultLogTypes, T>, raw: boolean, force: boolean, ...messageObject: any[]): void;
63
- }
64
- type PailBrowserType<T extends string = string, L extends string = string> = Console & (new <TC extends string = string, LC extends string = string>(options?: ConstructorOptions<TC, LC>) => PailBrowserType<TC, LC>) & PailBrowserImpl<T, L> & Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction> & {
65
- force: Record<DefaultLogTypes, LoggerFunction> & Record<T, LoggerFunction>;
66
- };
67
-
68
- export { PailBrowserImpl as a };
69
- export type { PailBrowserType as P };
@@ -1,95 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { LiteralUnion, Primitive } from 'type-fest';
3
- import { InteractiveManager } from '../interactive/index.js';
4
-
5
- declare global {
6
- namespace VisulimaPail {
7
- interface CustomMeta<L> {
8
- }
9
- }
10
- }
11
- interface Meta<L> extends VisulimaPail.CustomMeta<L> {
12
- badge: string | undefined;
13
- context: any[] | undefined;
14
- date: Date | string;
15
- error: Error | undefined;
16
- groups: string[];
17
- label: string | undefined;
18
- message: Primitive | ReadonlyArray<unknown> | Record<PropertyKey, unknown>;
19
- prefix: string | undefined;
20
- repeated?: number | undefined;
21
- scope: string[] | undefined;
22
- suffix: string | undefined;
23
- traceError: Error | undefined;
24
- type: {
25
- level: ExtendedRfc5424LogLevels | L;
26
- name: string;
27
- };
28
- }
29
- type ExtendedRfc5424LogLevels = "alert" | "critical" | "debug" | "emergency" | "error" | "informational" | "notice" | "trace" | "warning";
30
- type DefaultLogTypes = "alert" | "await" | "complete" | "critical" | "debug" | "emergency" | "error" | "info" | "log" | "notice" | "pending" | "start" | "stop" | "success" | "trace" | "wait" | "warn" | "warning" | "watch";
31
- interface LoggerFunction {
32
- (message: Message): void;
33
- (...message: any[]): void;
34
- }
35
- interface LoggerConfiguration<L extends string> {
36
- badge?: string;
37
- color?: AnsiColors | undefined;
38
- label: string;
39
- logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;
40
- }
41
- type LoggerTypesConfig<T extends string, L extends string> = Record<T, Partial<LoggerConfiguration<L>>>;
42
- type DefaultLoggerTypes<L extends string = string> = Record<DefaultLogTypes, LoggerConfiguration<L>>;
43
- type ReadonlyMeta<L extends string> = Readonly<Meta<L>>;
44
- interface Reporter<L extends string> {
45
- log: (meta: ReadonlyMeta<L>) => void;
46
- }
47
- interface StreamAwareReporter<L extends string> extends Reporter<L> {
48
- setStderr: (stderr: NodeJS.WriteStream) => void;
49
- setStdout: (stdout: NodeJS.WriteStream) => void;
50
- }
51
- interface LoggerTypesAwareReporter<T extends string, L extends string> extends Reporter<L> {
52
- setLoggerTypes: (types: LoggerTypesConfig<T, L> & Partial<LoggerTypesConfig<DefaultLogTypes, L>>) => void;
53
- }
54
- interface StringifyAwareReporter<L extends string> extends Reporter<L> {
55
- setStringify: (stringify: typeof JSON.stringify) => void;
56
- }
57
- interface InteractiveStreamReporter<L extends string> extends StreamAwareReporter<L> {
58
- setInteractiveManager: (manager?: InteractiveManager) => void;
59
- setIsInteractive: (interactive: boolean) => void;
60
- }
61
- interface Processor<L extends string> {
62
- process: (meta: Meta<L>) => Meta<L>;
63
- }
64
- interface StringifyAwareProcessor<L extends string> extends Processor<L> {
65
- setStringify: (stringify: typeof JSON.stringify) => void;
66
- }
67
- interface ConstructorOptions<T extends string, L extends string> {
68
- disabled?: boolean;
69
- logLevel?: LiteralUnion<ExtendedRfc5424LogLevels, L>;
70
- logLevels?: Partial<Record<ExtendedRfc5424LogLevels, number>> & Record<L, number>;
71
- messages?: {
72
- timerEnd?: string;
73
- timerStart?: string;
74
- };
75
- processors?: Processor<L>[];
76
- rawReporter?: Reporter<L>;
77
- reporters?: Reporter<L>[];
78
- scope?: string[] | string;
79
- throttle?: number;
80
- throttleMin?: number;
81
- types?: LoggerTypesConfig<T, L> & Partial<LoggerTypesConfig<DefaultLogTypes, L>>;
82
- }
83
- interface ServerConstructorOptions<T extends string, L extends string> extends ConstructorOptions<T, L> {
84
- interactive?: boolean;
85
- stderr: NodeJS.WriteStream;
86
- stdout: NodeJS.WriteStream;
87
- }
88
- type Message = {
89
- context?: any[] | undefined;
90
- message: any;
91
- prefix?: string;
92
- suffix?: string;
93
- };
94
-
95
- export type { ConstructorOptions as C, DefaultLoggerTypes as D, ExtendedRfc5424LogLevels as E, InteractiveStreamReporter as I, LoggerConfiguration as L, Meta as M, Processor as P, Reporter as R, StreamAwareReporter as S, DefaultLogTypes as a, LoggerFunction as b, LoggerTypesAwareReporter as c, LoggerTypesConfig as d, ReadonlyMeta as e, StringifyAwareReporter as f, ServerConstructorOptions as g, StringifyAwareProcessor as h };