@visulima/pail 4.0.0-alpha.9 → 4.0.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.
- package/CHANGELOG.md +511 -0
- package/LICENSE.md +270 -166
- package/README.md +53 -24
- package/dist/error.d.ts +95 -96
- package/dist/error.js +5 -76
- package/dist/index.browser.d.ts +568 -47
- package/dist/index.browser.js +19 -1499
- package/dist/index.server.d.ts +749 -65
- package/dist/index.server.js +32 -3179
- package/dist/middleware/elysia.d.ts +66 -63
- package/dist/middleware/elysia.js +1 -70
- package/dist/middleware/express.d.ts +74 -71
- package/dist/middleware/express.js +1 -29
- package/dist/middleware/fastify.d.ts +70 -67
- package/dist/middleware/fastify.js +1 -46
- package/dist/middleware/hono.d.ts +75 -72
- package/dist/middleware/hono.js +1 -33
- package/dist/middleware/next/handler.d.ts +102 -34
- package/dist/middleware/next/handler.js +1 -53
- package/dist/middleware/sveltekit.d.ts +101 -98
- package/dist/middleware/sveltekit.js +1 -43
- package/dist/object-tree.d.ts +67 -70
- package/dist/object-tree.js +2 -89
- package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +1 -0
- package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +2 -0
- package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
- package/dist/packem_shared/PailError-CbU1Ogfa.js +5 -0
- package/dist/packem_shared/PrettyReporter-CcDdPQSt.js +44 -0
- package/dist/packem_shared/PrettyReporter-DsHfKOU7.js +5 -0
- package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +62 -0
- package/dist/packem_shared/abstract-pretty-reporter-DrLBJ6ds.js +57 -0
- package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +25 -0
- package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
- package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
- package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +47 -0
- package/dist/packem_shared/headers-DH0H2s8W.js +1 -0
- package/dist/packem_shared/index-Q1764hvO.js +1 -0
- package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
- package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +1 -0
- package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
- package/dist/packem_shared/storage-DaXAlpiO.js +1 -0
- package/dist/packem_shared/types.d-Cz9S7jZh.d.ts +201 -0
- package/dist/packem_shared/types.d-bWnqHJKL.d.ts +211 -0
- package/dist/packem_shared/types.d-xxE3FOD3.d.ts +229 -0
- package/dist/packem_shared/useLogger-DB34CuU5.js +1 -0
- package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +717 -0
- package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +1 -0
- package/dist/packem_shared/write-stream-C7jxLxIT.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +50 -47
- package/dist/processor/caller/caller-processor.js +1 -59
- package/dist/processor/environment-processor.d.ts +114 -113
- package/dist/processor/environment-processor.js +1 -78
- package/dist/processor/message-formatter-processor.d.ts +59 -49
- package/dist/processor/message-formatter-processor.js +1 -713
- package/dist/processor/opentelemetry-processor.d.ts +70 -66
- package/dist/processor/opentelemetry-processor.js +1 -52
- package/dist/processor/redact-processor.d.ts +99 -41
- package/dist/processor/redact-processor.js +1 -30
- package/dist/processor/sampling-processor.d.ts +103 -101
- package/dist/processor/sampling-processor.js +1 -59
- package/dist/reporter/file/json-file-reporter.d.ts +109 -42
- package/dist/reporter/file/json-file-reporter.js +2 -136
- package/dist/reporter/http/abstract-http-reporter.d.ts +256 -211
- package/dist/reporter/http/abstract-http-reporter.js +2 -435
- package/dist/reporter/http/http-reporter.d.ts +41 -36
- package/dist/reporter/http/http-reporter.edge-light.d.ts +487 -39
- package/dist/reporter/http/http-reporter.edge-light.js +2 -733
- package/dist/reporter/http/http-reporter.js +1 -13
- package/dist/reporter/json/index.browser.d.ts +98 -3
- package/dist/reporter/json/index.browser.js +1 -2
- package/dist/reporter/json/index.d.ts +53 -3
- package/dist/reporter/json/index.js +1 -2
- package/dist/reporter/pretty/index.browser.d.ts +105 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +270 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +215 -18
- package/dist/reporter/simple/simple-reporter.server.js +8 -182
- package/dist/wide-event.d.ts +6 -300
- package/dist/wide-event.js +1 -281
- package/package.json +22 -37
- 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/AbstractJsonReporter-CGKHS8_M.js +0 -286
- package/dist/packem_shared/AbstractJsonReporter-DDjDkciI.js +0 -286
- package/dist/packem_shared/InteractiveManager-Cd6A14ZK.js +0 -172
- package/dist/packem_shared/InteractiveStreamHook-ePIURL_U.js +0 -133
- package/dist/packem_shared/JsonReporter-B3XX8GHN.js +0 -58
- package/dist/packem_shared/JsonReporter-p_BXg6Sj.js +0 -28
- package/dist/packem_shared/PrettyReporter-BYL3NrdA.js +0 -214
- package/dist/packem_shared/PrettyReporter-CvBn-hxP.js +0 -1459
- package/dist/packem_shared/Spinner-DIdVcfWq.js +0 -2183
- package/dist/packem_shared/abstract-pretty-reporter-jU8WL_6c.js +0 -2602
- package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
- package/dist/packem_shared/constants-omsTHUWB.js +0 -119
- package/dist/packem_shared/createPailError-B11aRfrT.js +0 -76
- package/dist/packem_shared/getBarChar-BWj1UrH3.js +0 -404
- package/dist/packem_shared/headers-Cp4uLtr4.js +0 -123
- package/dist/packem_shared/index-DnkF86LQ.js +0 -658
- package/dist/packem_shared/index-frijFf5m.js +0 -1252
- package/dist/packem_shared/pailMiddleware-Ci88geIF.js +0 -24
- package/dist/packem_shared/storage-D0vqz8OX.js +0 -36
- package/dist/packem_shared/useLogger-D0rU3lcX.js +0 -33
- package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +0 -14
- package/dist/packem_shared/write-stream-BG8fhcs3.js +0 -6
- 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 -136
- package/dist/progress-bar.js +0 -404
- 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
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
class HttpReporter extends AbstractHttpReporter {
|
|
4
|
-
/**
|
|
5
|
-
* Creates a new HTTP Reporter instance.
|
|
6
|
-
* @param options Configuration options for HTTP reporting
|
|
7
|
-
*/
|
|
8
|
-
constructor(options) {
|
|
9
|
-
super(options);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { HttpReporter as default };
|
|
1
|
+
import{AbstractHttpReporter as r}from"./abstract-http-reporter.js";class o extends r{constructor(t){super(t)}}export{o as default};
|
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { s as stringify } from "../../packem_shared/index.d-T71KjNAr.js";
|
|
2
|
+
import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, L as LiteralUnion, S as StringifyAwareReporter } from "../../packem_shared/types.d-xxE3FOD3.js";
|
|
3
|
+
import '@visulima/colorize';
|
|
4
|
+
import '@visulima/interactive-manager';
|
|
5
|
+
/**
|
|
6
|
+
* Options for configuring JSON reporters.
|
|
7
|
+
*/
|
|
8
|
+
type AbstractJsonReporterOptions = {
|
|
9
|
+
/** Error serialization options */
|
|
10
|
+
error: Partial<{
|
|
11
|
+
/** Properties to exclude from error serialization */
|
|
12
|
+
exclude?: string[];
|
|
13
|
+
/** Maximum depth for error object serialization */
|
|
14
|
+
maxDepth?: number;
|
|
15
|
+
/** Whether to use toJSON methods during serialization */
|
|
16
|
+
useToJSON?: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Abstract JSON Reporter.
|
|
21
|
+
*
|
|
22
|
+
* Base class for JSON-based reporters that provides common functionality
|
|
23
|
+
* for serializing log metadata to JSON format. Handles error serialization,
|
|
24
|
+
* context processing, and provides a template method for actual output.
|
|
25
|
+
* @template L - The log level type
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* class CustomJsonReporter extends AbstractJsonReporter {
|
|
29
|
+
* protected _log(message: string): void {
|
|
30
|
+
* console.log(message);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare abstract class AbstractJsonReporter<L extends string = string> implements StringifyAwareReporter<L> {
|
|
36
|
+
/** Custom stringify function for object serialization */
|
|
37
|
+
protected stringify: typeof stringify | undefined;
|
|
38
|
+
/** Error serialization options */
|
|
39
|
+
protected errorOptions: AbstractJsonReporterOptions["error"];
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new AbstractJsonReporter instance.
|
|
42
|
+
* @param options Configuration options for JSON formatting and error handling
|
|
43
|
+
*/
|
|
44
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
45
|
+
/**
|
|
46
|
+
* Sets a custom stringify function for object serialization.
|
|
47
|
+
* @param function_ The stringify function to use for serialization
|
|
48
|
+
*/
|
|
49
|
+
setStringify(function_: typeof stringify): void;
|
|
50
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Template method for outputting the JSON log message.
|
|
53
|
+
*
|
|
54
|
+
* Subclasses must implement this method to define how the JSON message
|
|
55
|
+
* is actually written (to console, file, network, etc.).
|
|
56
|
+
* @param message The JSON-formatted log message
|
|
57
|
+
* @param logLevel The log level of the message
|
|
58
|
+
* @protected
|
|
59
|
+
* @abstract
|
|
60
|
+
*/
|
|
61
|
+
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Browser JSON Reporter.
|
|
65
|
+
*
|
|
66
|
+
* A JSON reporter for browser environments that outputs structured log data
|
|
67
|
+
* to the browser console. Uses appropriate console methods based on log level.
|
|
68
|
+
* @template L - The log level type
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* import { createPail } from "@visulima/pail";
|
|
72
|
+
*
|
|
73
|
+
* const logger = createPail({
|
|
74
|
+
* reporters: [new JsonReporter()]
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* logger.info("Application started", { version: "1.0.0" });
|
|
78
|
+
* // Outputs: {"level":"info","message":"Application started","context":[{"version":"1.0.0"}],...}
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> {
|
|
82
|
+
/**
|
|
83
|
+
* Creates a new Browser JSON Reporter instance.
|
|
84
|
+
* @param options Configuration options for JSON formatting
|
|
85
|
+
*/
|
|
86
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
87
|
+
/**
|
|
88
|
+
* Outputs the JSON message to the browser console.
|
|
89
|
+
*
|
|
90
|
+
* Uses the appropriate console method based on the log level
|
|
91
|
+
* (console.log, console.error, console.warn, etc.).
|
|
92
|
+
* @param message The JSON-formatted log message
|
|
93
|
+
* @param logLevel The log level determining which console method to use
|
|
94
|
+
* @protected
|
|
95
|
+
*/
|
|
96
|
+
protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
97
|
+
}
|
|
98
|
+
export { AbstractJsonReporter, type AbstractJsonReporterOptions, JsonReporter };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as JsonReporter } from '../../packem_shared/JsonReporter-p_BXg6Sj.js';
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-Bp_JCrMQ.js";import{default as p}from"../../packem_shared/JsonReporter-bmem9lcg.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { E as ExtendedRfc5424LogLevels, a as StreamAwareReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
4
|
+
import "../../packem_shared/index.d-T71KjNAr.js";
|
|
5
|
+
import '@visulima/colorize';
|
|
6
|
+
import '@visulima/interactive-manager';
|
|
7
|
+
/**
|
|
8
|
+
* Server JSON Reporter.
|
|
9
|
+
*
|
|
10
|
+
* A JSON reporter for Node.js server environments that outputs structured log data
|
|
11
|
+
* to stdout/stderr streams. Routes error-level logs to stderr and others to stdout.
|
|
12
|
+
* @template L - The log level type
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createPail } from "@visulima/pail";
|
|
16
|
+
*
|
|
17
|
+
* const logger = createPail({
|
|
18
|
+
* reporters: [new JsonReporter()]
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* logger.info("Server started", { port: 3000 });
|
|
22
|
+
* logger.error("Database connection failed", error);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> implements StreamAwareReporter<L> {
|
|
26
|
+
#private;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new Server JSON Reporter instance.
|
|
29
|
+
* @param options Configuration options for JSON formatting
|
|
30
|
+
*/
|
|
31
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
32
|
+
/**
|
|
33
|
+
* Sets the stdout stream for the reporter.
|
|
34
|
+
* @param stdout_ The writable stream to use for stdout output
|
|
35
|
+
*/
|
|
36
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
37
|
+
/**
|
|
38
|
+
* Sets the stderr stream for the reporter.
|
|
39
|
+
* @param stderr_ The writable stream to use for stderr output
|
|
40
|
+
*/
|
|
41
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
42
|
+
/**
|
|
43
|
+
* Outputs the JSON message to the appropriate stream.
|
|
44
|
+
*
|
|
45
|
+
* Routes high-severity RFC 5424 levels (warning/error/critical/alert/emergency/trace)
|
|
46
|
+
* to stderr, others to stdout.
|
|
47
|
+
* @param message The JSON-formatted log message
|
|
48
|
+
* @param logLevel The log level determining which stream to use
|
|
49
|
+
* @protected
|
|
50
|
+
*/
|
|
51
|
+
protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
52
|
+
}
|
|
53
|
+
export { AbstractJsonReporter, type AbstractJsonReporterOptions, JsonReporter };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as JsonReporter } from '../../packem_shared/JsonReporter-B3XX8GHN.js';
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-w_bGGiD-.js";import{default as p}from"../../packem_shared/JsonReporter-Sd_lJGS-.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,2 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { D as DefaultLogTypes, L as LiteralUnion, a as LoggerTypesConfig, R as ReadonlyMeta, b as LoggerTypesAwareReporter } from "../../packem_shared/types.d-xxE3FOD3.js";
|
|
2
|
+
import '@visulima/colorize';
|
|
3
|
+
import '@visulima/interactive-manager';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract Pretty Reporter.
|
|
6
|
+
*
|
|
7
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
8
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
9
|
+
* and logger type configuration.
|
|
10
|
+
* @template T - Custom logger type names
|
|
11
|
+
* @template L - Log level types
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
15
|
+
* public log(meta: ReadonlyMeta) {
|
|
16
|
+
* const formatted = this.formatMessage(meta);
|
|
17
|
+
* console.log(formatted);
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
23
|
+
/** Styling options for pretty formatting */
|
|
24
|
+
protected readonly styles: PrettyStyleOptions;
|
|
25
|
+
/** Logger type configurations for styling */
|
|
26
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
29
|
+
* @param options Styling options for pretty formatting
|
|
30
|
+
* @protected
|
|
31
|
+
*/
|
|
32
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
33
|
+
/**
|
|
34
|
+
* Sets the logger types configuration for styling.
|
|
35
|
+
* @param types Logger type configurations with colors and labels
|
|
36
|
+
*/
|
|
37
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Logs a message with pretty formatting.
|
|
40
|
+
* @param meta The log metadata to format and output
|
|
41
|
+
* @abstract
|
|
42
|
+
*/
|
|
43
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options for configuring pretty reporter styling.
|
|
47
|
+
*/
|
|
48
|
+
type PrettyStyleOptions = {
|
|
49
|
+
/** Bold styling options */
|
|
50
|
+
bold: {
|
|
51
|
+
/** Whether to bold the label text */
|
|
52
|
+
label: boolean;
|
|
53
|
+
};
|
|
54
|
+
/** Function to format dates in log output */
|
|
55
|
+
dateFormatter: (date: Date) => string;
|
|
56
|
+
/** Maximum length of message before line break (optional) */
|
|
57
|
+
messageLength: number | undefined;
|
|
58
|
+
/** Underline styling options */
|
|
59
|
+
underline: {
|
|
60
|
+
/** Whether to underline the label */
|
|
61
|
+
label: boolean;
|
|
62
|
+
/** Whether to underline prefixes */
|
|
63
|
+
prefix: boolean;
|
|
64
|
+
/** Whether to underline suffixes */
|
|
65
|
+
suffix: boolean;
|
|
66
|
+
};
|
|
67
|
+
/** Uppercase styling options */
|
|
68
|
+
uppercase: {
|
|
69
|
+
/** Whether to uppercase the label text */
|
|
70
|
+
label: boolean;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Browser Pretty Reporter.
|
|
75
|
+
*
|
|
76
|
+
* A pretty-printing reporter for browser environments that formats log messages
|
|
77
|
+
* with colors and structured layout for console output. Uses browser-compatible
|
|
78
|
+
* color formatting and console APIs.
|
|
79
|
+
* @template T - Custom logger type names
|
|
80
|
+
* @template L - Log level types
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import { createPail } from "@visulima/pail";
|
|
84
|
+
*
|
|
85
|
+
* const logger = createPail({
|
|
86
|
+
* reporters: [new PrettyReporter({
|
|
87
|
+
* bold: { label: true },
|
|
88
|
+
* uppercase: { label: true }
|
|
89
|
+
* })]
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* logger.info("Application started");
|
|
93
|
+
* logger.error("Something went wrong", error);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> {
|
|
97
|
+
#private;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new Browser Pretty Reporter instance.
|
|
100
|
+
* @param options Styling options for pretty formatting
|
|
101
|
+
*/
|
|
102
|
+
constructor(options?: Partial<PrettyStyleOptions>);
|
|
103
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
104
|
+
}
|
|
105
|
+
export { PrettyReporter, type PrettyStyleOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{default as t}from"../../packem_shared/PrettyReporter-DsHfKOU7.js";export{t as PrettyReporter};
|
|
@@ -1,2 +1,270 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import { InteractiveManager } from '@visulima/interactive-manager';
|
|
3
|
+
import { D as DefaultLogTypes, c as LoggerTypesConfig, R as ReadonlyMeta, e as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
4
|
+
import '@visulima/colorize';
|
|
5
|
+
type ColorizeMethod = (value: string) => string;
|
|
6
|
+
type CodeFrameOptions = {
|
|
7
|
+
color?: {
|
|
8
|
+
gutter?: ColorizeMethod;
|
|
9
|
+
marker?: ColorizeMethod;
|
|
10
|
+
message?: ColorizeMethod;
|
|
11
|
+
};
|
|
12
|
+
linesAbove?: number;
|
|
13
|
+
linesBelow?: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
showGutter?: boolean;
|
|
17
|
+
showLineNumbers?: boolean;
|
|
18
|
+
tabWidth?: number | false;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The compiled position of a stack frame handed to a {@link SourceMapResolver}.
|
|
22
|
+
*/
|
|
23
|
+
interface SourceMapLocation {
|
|
24
|
+
column?: number;
|
|
25
|
+
file: string;
|
|
26
|
+
line: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The resolved original position returned by a {@link SourceMapResolver}. Any omitted field falls
|
|
30
|
+
* back to the compiled value. `source`, when provided, is used directly as the code-frame content
|
|
31
|
+
* (e.g. from an inlined `sourcesContent`) instead of reading the resolved file from disk.
|
|
32
|
+
*/
|
|
33
|
+
interface ResolvedSourceLocation {
|
|
34
|
+
column?: number;
|
|
35
|
+
file?: string;
|
|
36
|
+
line?: number;
|
|
37
|
+
source?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pluggable hook that maps a compiled `*.js:line:col` position back to its original source position
|
|
41
|
+
* (e.g. TS/JSX). Return `undefined` (or throw) to leave the frame untouched. Synchronous so it can
|
|
42
|
+
* be used by the synchronous `renderError`; resolve/inline your maps ahead of time.
|
|
43
|
+
*/
|
|
44
|
+
type SourceMapResolver = (location: SourceMapLocation) => ResolvedSourceLocation | undefined;
|
|
45
|
+
type Options$1 = {
|
|
46
|
+
/**
|
|
47
|
+
* Read source files for code frames from anywhere on disk, including absolute paths outside
|
|
48
|
+
* `cwd`. Defaults to `false`, in which case only files resolving inside `cwd` are read — this
|
|
49
|
+
* prevents local file disclosure when rendering errors whose stack came from untrusted input
|
|
50
|
+
* (e.g. a deserialized error). Enable only for trusted, locally-thrown errors.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
allowAllFilePaths: boolean;
|
|
54
|
+
color: CodeFrameOptions["color"] & {
|
|
55
|
+
fileLine: ColorizeMethod;
|
|
56
|
+
hint: ColorizeMethod;
|
|
57
|
+
method: ColorizeMethod;
|
|
58
|
+
title: ColorizeMethod;
|
|
59
|
+
};
|
|
60
|
+
cwd: string;
|
|
61
|
+
displayShortPath: boolean;
|
|
62
|
+
filterStacktrace: ((line: string) => boolean) | undefined;
|
|
63
|
+
framesMaxLimit: number;
|
|
64
|
+
hideErrorCauseCodeView: boolean;
|
|
65
|
+
hideErrorCodeView: boolean;
|
|
66
|
+
hideErrorErrorsCodeView: boolean;
|
|
67
|
+
hideErrorTitle: boolean;
|
|
68
|
+
hideMessage: boolean;
|
|
69
|
+
indentation: number | " ";
|
|
70
|
+
prefix: string; /** Optional source-map resolver to map compiled frame positions back to original source. */
|
|
71
|
+
sourceMap?: SourceMapResolver;
|
|
72
|
+
} & Omit<CodeFrameOptions, "message | prefix">;
|
|
73
|
+
interface Options {
|
|
74
|
+
/**
|
|
75
|
+
* When `true`, honour custom inspectors: a value's
|
|
76
|
+
* `Symbol.for("nodejs.util.inspect.custom")` method (Node only),
|
|
77
|
+
* `Symbol.for("chai/inspect")` method, an `.inspect()` method, or a handler
|
|
78
|
+
* registered via `registerConstructor` / `registerStringTag`.
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
customInspect: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The maximum nesting depth to traverse before collapsing a nested value to
|
|
84
|
+
* `[Object]` / `[Array]`. A value `<= 0` disables the limit.
|
|
85
|
+
* @default 5
|
|
86
|
+
*/
|
|
87
|
+
depth: number;
|
|
88
|
+
/**
|
|
89
|
+
* Pretty-print with indentation. `"\t"` indents with tabs, a positive integer
|
|
90
|
+
* indents with that many spaces, and `undefined` keeps everything on one line.
|
|
91
|
+
* @default undefined
|
|
92
|
+
*/
|
|
93
|
+
indent: number | " " | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* The maximum number of array / typed-array / iterable elements to render
|
|
96
|
+
* before the remainder is replaced with an `… (N more)` marker. Use
|
|
97
|
+
* `Number.POSITIVE_INFINITY` to show every element.
|
|
98
|
+
* @default Number.POSITIVE_INFINITY
|
|
99
|
+
*/
|
|
100
|
+
maxArrayLength: number;
|
|
101
|
+
/**
|
|
102
|
+
* When `true`, render large numbers and bigints with `_` digit-group
|
|
103
|
+
* separators (e.g. `1_000_000`).
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
numericSeparator: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The quote character used when rendering string values and complex object
|
|
109
|
+
* keys.
|
|
110
|
+
* @default "single"
|
|
111
|
+
*/
|
|
112
|
+
quoteStyle: "double" | "single";
|
|
113
|
+
/**
|
|
114
|
+
* When `true`, also render non-enumerable own properties of plain objects
|
|
115
|
+
* (mirrors `util.inspect`'s `showHidden`).
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
showHidden: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Colourize / decorate a rendered fragment. Receives the raw fragment and a
|
|
121
|
+
* style hint and must return the (optionally wrapped) string. Defaults to the
|
|
122
|
+
* identity function.
|
|
123
|
+
*/
|
|
124
|
+
stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
|
|
125
|
+
/**
|
|
126
|
+
* The maximum length (in characters) of a single rendered value before it is
|
|
127
|
+
* truncated with an ellipsis. Use `Number.POSITIVE_INFINITY` to disable
|
|
128
|
+
* truncation.
|
|
129
|
+
* @default Number.POSITIVE_INFINITY
|
|
130
|
+
*/
|
|
131
|
+
truncate: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Abstract Pretty Reporter.
|
|
135
|
+
*
|
|
136
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
137
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
138
|
+
* and logger type configuration.
|
|
139
|
+
* @template T - Custom logger type names
|
|
140
|
+
* @template L - Log level types
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
144
|
+
* public log(meta: ReadonlyMeta) {
|
|
145
|
+
* const formatted = this.formatMessage(meta);
|
|
146
|
+
* console.log(formatted);
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
152
|
+
/** Styling options for pretty formatting */
|
|
153
|
+
protected readonly styles: PrettyStyleOptions;
|
|
154
|
+
/** Logger type configurations for styling */
|
|
155
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
156
|
+
/**
|
|
157
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
158
|
+
* @param options Styling options for pretty formatting
|
|
159
|
+
* @protected
|
|
160
|
+
*/
|
|
161
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
162
|
+
/**
|
|
163
|
+
* Sets the logger types configuration for styling.
|
|
164
|
+
* @param types Logger type configurations with colors and labels
|
|
165
|
+
*/
|
|
166
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
167
|
+
/**
|
|
168
|
+
* Logs a message with pretty formatting.
|
|
169
|
+
* @param meta The log metadata to format and output
|
|
170
|
+
* @abstract
|
|
171
|
+
*/
|
|
172
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Options for configuring pretty reporter styling.
|
|
176
|
+
*/
|
|
177
|
+
type PrettyStyleOptions = {
|
|
178
|
+
/** Bold styling options */
|
|
179
|
+
bold: {
|
|
180
|
+
/** Whether to bold the label text */
|
|
181
|
+
label: boolean;
|
|
182
|
+
};
|
|
183
|
+
/** Function to format dates in log output */
|
|
184
|
+
dateFormatter: (date: Date) => string;
|
|
185
|
+
/** Maximum length of message before line break (optional) */
|
|
186
|
+
messageLength: number | undefined;
|
|
187
|
+
/** Underline styling options */
|
|
188
|
+
underline: {
|
|
189
|
+
/** Whether to underline the label */
|
|
190
|
+
label: boolean;
|
|
191
|
+
/** Whether to underline prefixes */
|
|
192
|
+
prefix: boolean;
|
|
193
|
+
/** Whether to underline suffixes */
|
|
194
|
+
suffix: boolean;
|
|
195
|
+
};
|
|
196
|
+
/** Uppercase styling options */
|
|
197
|
+
uppercase: {
|
|
198
|
+
/** Whether to uppercase the label text */
|
|
199
|
+
label: boolean;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Options for configuring the Server Pretty Reporter.
|
|
204
|
+
*/
|
|
205
|
+
type PrettyReporterOptions = PrettyStyleOptions & {
|
|
206
|
+
/** Error rendering options */
|
|
207
|
+
error: Partial<Omit<Options$1, "color" | "prefix" | "indentation">>;
|
|
208
|
+
/** Object inspection options */
|
|
209
|
+
inspect: Partial<Options>;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Server Pretty Reporter.
|
|
213
|
+
*
|
|
214
|
+
* A comprehensive pretty-printing reporter for Node.js server environments that
|
|
215
|
+
* formats log messages with colors, structured layout, and advanced features like
|
|
216
|
+
* error rendering, object inspection, and interactive terminal support.
|
|
217
|
+
* @template T - Custom logger type names
|
|
218
|
+
* @template L - Log level types
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* import { createPail } from "@visulima/pail";
|
|
222
|
+
*
|
|
223
|
+
* const logger = createPail({
|
|
224
|
+
* reporters: [new PrettyReporter({
|
|
225
|
+
* bold: { label: true },
|
|
226
|
+
* error: { color: { title: 'red' } }
|
|
227
|
+
* })]
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* logger.info("Server started on port 3000");
|
|
231
|
+
* logger.error("Database error", dbError);
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
235
|
+
#private;
|
|
236
|
+
/**
|
|
237
|
+
* Creates a new Server Pretty Reporter instance.
|
|
238
|
+
* @param options Configuration options for styling, error rendering, and object inspection
|
|
239
|
+
*/
|
|
240
|
+
constructor(options?: Partial<PrettyReporterOptions>);
|
|
241
|
+
/**
|
|
242
|
+
* Sets the logger types configuration and refreshes cached badge/label widths.
|
|
243
|
+
* @param types Logger type configurations with colors and labels
|
|
244
|
+
*/
|
|
245
|
+
override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
246
|
+
/**
|
|
247
|
+
* Sets the stdout stream for the reporter.
|
|
248
|
+
* @param stdout_ The writable stream to use for standard output
|
|
249
|
+
*/
|
|
250
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
251
|
+
/**
|
|
252
|
+
* Sets the stderr stream for the reporter.
|
|
253
|
+
* @param stderr_ The writable stream to use for error output
|
|
254
|
+
*/
|
|
255
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
256
|
+
/**
|
|
257
|
+
* Sets the interactive manager for handling interactive output.
|
|
258
|
+
* @param manager The interactive manager instance, or undefined to disable
|
|
259
|
+
*/
|
|
260
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
261
|
+
/**
|
|
262
|
+
* Enables or disables interactive mode.
|
|
263
|
+
* @param interactive Whether to enable interactive terminal features
|
|
264
|
+
*/
|
|
265
|
+
setIsInteractive(interactive: boolean): void;
|
|
266
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
267
|
+
protected _formatMessage(data: ReadonlyMeta<L>): string;
|
|
268
|
+
protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
269
|
+
}
|
|
270
|
+
export { PrettyReporter, type PrettyReporterOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-CcDdPQSt.js";export{t as PrettyReporter};
|