@visulima/pail 4.0.0-alpha.11 → 4.0.0-alpha.13
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 +33 -0
- package/LICENSE.md +131 -900
- package/dist/error.d.ts +95 -96
- package/dist/error.js +5 -76
- package/dist/index.browser.d.ts +557 -47
- package/dist/index.browser.js +19 -1499
- package/dist/index.server.d.ts +722 -61
- package/dist/index.server.js +31 -2803
- package/dist/middleware/elysia.d.ts +65 -63
- package/dist/middleware/elysia.js +1 -70
- package/dist/middleware/express.d.ts +73 -71
- package/dist/middleware/express.js +1 -29
- package/dist/middleware/fastify.d.ts +69 -67
- package/dist/middleware/fastify.js +1 -46
- package/dist/middleware/hono.d.ts +74 -72
- package/dist/middleware/hono.js +1 -33
- package/dist/middleware/next/handler.d.ts +101 -34
- package/dist/middleware/next/handler.js +1 -53
- package/dist/middleware/sveltekit.d.ts +100 -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-BawNFYxI.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-Dt5-5x2R.js +1 -0
- package/dist/packem_shared/JsonReporter-15ln04rX.js +2 -0
- package/dist/packem_shared/JsonReporter-CerNvhg-.js +1 -0
- package/dist/packem_shared/PrettyReporter-Br5njEEy.js +5 -0
- package/dist/packem_shared/PrettyReporter-CgXnwIip.js +44 -0
- package/dist/packem_shared/abstract-json-reporter.d-Bz3lZEDi.d.ts +61 -0
- package/dist/packem_shared/abstract-pretty-reporter-BiHgKxG_.js +33 -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-DeNLii5l.d.ts +47 -0
- package/dist/packem_shared/createPailError-53jAfQ-T.js +5 -0
- package/dist/packem_shared/headers-S8WyX-2m.js +1 -0
- package/dist/packem_shared/index-Bzp4LnJ5.js +1 -0
- package/dist/packem_shared/pailMiddleware-CWOJRmJq.js +1 -0
- package/dist/packem_shared/storage-DHM1EP2P.js +1 -0
- package/dist/packem_shared/types.d-ByY2ZuYG.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/useLogger-qyZrjy4D.js +1 -0
- package/dist/packem_shared/wide-event.d-Ke44zirU.d.ts +704 -0
- package/dist/packem_shared/write-console-log-based-on-level-DfD64owL.js +1 -0
- package/dist/packem_shared/write-stream-Dd4_PTcm.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +49 -47
- package/dist/processor/caller/caller-processor.js +1 -59
- package/dist/processor/environment-processor.d.ts +113 -113
- package/dist/processor/environment-processor.js +1 -89
- package/dist/processor/message-formatter-processor.d.ts +51 -49
- package/dist/processor/message-formatter-processor.js +1 -715
- package/dist/processor/opentelemetry-processor.d.ts +69 -66
- package/dist/processor/opentelemetry-processor.js +1 -52
- package/dist/processor/redact-processor.d.ts +60 -41
- package/dist/processor/redact-processor.js +1 -31
- package/dist/processor/sampling-processor.d.ts +102 -101
- package/dist/processor/sampling-processor.js +1 -59
- package/dist/reporter/file/json-file-reporter.d.ts +91 -42
- package/dist/reporter/file/json-file-reporter.js +2 -136
- package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
- package/dist/reporter/http/abstract-http-reporter.js +2 -432
- 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 +2 -728
- package/dist/reporter/http/http-reporter.js +1 -13
- package/dist/reporter/json/index.browser.d.ts +99 -3
- package/dist/reporter/json/index.browser.js +1 -2
- package/dist/reporter/json/index.d.ts +51 -3
- package/dist/reporter/json/index.js +1 -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 +186 -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 +8 -182
- package/dist/wide-event.d.ts +5 -300
- package/dist/wide-event.js +1 -284
- package/package.json +29 -30
- package/dist/constants.d.ts +0 -37
- 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-BO8Calb4.js +0 -284
- package/dist/packem_shared/AbstractJsonReporter-nOj0Ft1F.js +0 -284
- package/dist/packem_shared/JsonReporter-CCmj7oYL.js +0 -28
- package/dist/packem_shared/JsonReporter-Ck2PIAEw.js +0 -58
- package/dist/packem_shared/PrettyReporter-BCvyNzXO.js +0 -2720
- package/dist/packem_shared/PrettyReporter-BtTr13Ha.js +0 -213
- package/dist/packem_shared/abstract-pretty-reporter-CXAKYCb8.js +0 -2635
- package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
- package/dist/packem_shared/constants-omsTHUWB.js +0 -119
- package/dist/packem_shared/createPailError-B_sgL0nF.js +0 -76
- package/dist/packem_shared/headers-BxHWM6KI.js +0 -127
- package/dist/packem_shared/index-Bx3-C0j9.js +0 -658
- 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-ree2lDPw.js +0 -15
- package/dist/packem_shared/write-stream-MDqyXmc_.js +0 -6
- package/dist/pail.browser.d.ts +0 -412
- package/dist/pail.server.d.ts +0 -158
- package/dist/processor/caller/get-caller-filename.d.ts +0 -23
- 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/types.d.ts +0 -241
- 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
|
-
|
|
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
|
+
var a=Object.defineProperty;var r=(e,t)=>a(e,"name",{value:t,configurable:!0});import{AbstractHttpReporter as s}from"./abstract-http-reporter.js";var o=Object.defineProperty,p=r((e,t)=>o(e,"name",{value:t,configurable:!0}),"e");class i extends s{static{r(this,"s")}static{p(this,"HttpReporter")}constructor(t){super(t)}}export{i as default};
|
|
@@ -1,3 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { stringify } from 'safe-stable-stringify';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, S as StringifyAwareReporter } from "../../packem_shared/types.d-C51XNfQz.js";
|
|
4
|
+
import '@visulima/colorize';
|
|
5
|
+
import '@visulima/interactive-manager';
|
|
6
|
+
/**
|
|
7
|
+
* Options for configuring JSON reporters.
|
|
8
|
+
*/
|
|
9
|
+
type AbstractJsonReporterOptions = {
|
|
10
|
+
/** Error serialization options */
|
|
11
|
+
error: Partial<{
|
|
12
|
+
/** Properties to exclude from error serialization */
|
|
13
|
+
exclude?: string[];
|
|
14
|
+
/** Maximum depth for error object serialization */
|
|
15
|
+
maxDepth?: number;
|
|
16
|
+
/** Whether to use toJSON methods during serialization */
|
|
17
|
+
useToJSON?: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Abstract JSON Reporter.
|
|
22
|
+
*
|
|
23
|
+
* Base class for JSON-based reporters that provides common functionality
|
|
24
|
+
* for serializing log metadata to JSON format. Handles error serialization,
|
|
25
|
+
* context processing, and provides a template method for actual output.
|
|
26
|
+
* @template L - The log level type
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* class CustomJsonReporter extends AbstractJsonReporter {
|
|
30
|
+
* protected _log(message: string): void {
|
|
31
|
+
* console.log(message);
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare abstract class AbstractJsonReporter<L extends string = string> implements StringifyAwareReporter<L> {
|
|
37
|
+
/** Custom stringify function for object serialization */
|
|
38
|
+
protected stringify: typeof stringify | undefined;
|
|
39
|
+
/** Error serialization options */
|
|
40
|
+
protected errorOptions: AbstractJsonReporterOptions["error"];
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new AbstractJsonReporter instance.
|
|
43
|
+
* @param options Configuration options for JSON formatting and error handling
|
|
44
|
+
*/
|
|
45
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
46
|
+
/**
|
|
47
|
+
* Sets a custom stringify function for object serialization.
|
|
48
|
+
* @param function_ The stringify function to use for serialization
|
|
49
|
+
*/
|
|
50
|
+
setStringify(function_: typeof stringify): void;
|
|
51
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Template method for outputting the JSON log message.
|
|
54
|
+
*
|
|
55
|
+
* Subclasses must implement this method to define how the JSON message
|
|
56
|
+
* is actually written (to console, file, network, etc.).
|
|
57
|
+
* @param message The JSON-formatted log message
|
|
58
|
+
* @param logLevel The log level of the message
|
|
59
|
+
* @protected
|
|
60
|
+
* @abstract
|
|
61
|
+
*/
|
|
62
|
+
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Browser JSON Reporter.
|
|
66
|
+
*
|
|
67
|
+
* A JSON reporter for browser environments that outputs structured log data
|
|
68
|
+
* to the browser console. Uses appropriate console methods based on log level.
|
|
69
|
+
* @template L - The log level type
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { createPail } from "@visulima/pail";
|
|
73
|
+
*
|
|
74
|
+
* const logger = createPail({
|
|
75
|
+
* reporters: [new JsonReporter()]
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* logger.info("Application started", { version: "1.0.0" });
|
|
79
|
+
* // Outputs: {"level":"info","message":"Application started","context":[{"version":"1.0.0"}],...}
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> {
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new Browser JSON Reporter instance.
|
|
85
|
+
* @param options Configuration options for JSON formatting
|
|
86
|
+
*/
|
|
87
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
88
|
+
/**
|
|
89
|
+
* Outputs the JSON message to the browser console.
|
|
90
|
+
*
|
|
91
|
+
* Uses the appropriate console method based on the log level
|
|
92
|
+
* (console.log, console.error, console.warn, etc.).
|
|
93
|
+
* @param message The JSON-formatted log message
|
|
94
|
+
* @param logLevel The log level determining which console method to use
|
|
95
|
+
* @protected
|
|
96
|
+
*/
|
|
97
|
+
protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
98
|
+
}
|
|
99
|
+
export { AbstractJsonReporter, type AbstractJsonReporterOptions, JsonReporter };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as JsonReporter } from '../../packem_shared/JsonReporter-CCmj7oYL.js';
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-Dt5-5x2R.js";import{default as p}from"../../packem_shared/JsonReporter-CerNvhg-.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-Bz3lZEDi.js";
|
|
2
|
+
import { E as ExtendedRfc5424LogLevels, L as LiteralUnion, a as StreamAwareReporter } from "../../packem_shared/types.d-ByY2ZuYG.js";
|
|
3
|
+
import 'safe-stable-stringify';
|
|
4
|
+
import '@visulima/colorize';
|
|
5
|
+
import '@visulima/interactive-manager';
|
|
6
|
+
/**
|
|
7
|
+
* Server JSON Reporter.
|
|
8
|
+
*
|
|
9
|
+
* A JSON reporter for Node.js server environments that outputs structured log data
|
|
10
|
+
* to stdout/stderr streams. Routes error-level logs to stderr and others to stdout.
|
|
11
|
+
* @template L - The log level type
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createPail } from "@visulima/pail";
|
|
15
|
+
*
|
|
16
|
+
* const logger = createPail({
|
|
17
|
+
* reporters: [new JsonReporter()]
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* logger.info("Server started", { port: 3000 });
|
|
21
|
+
* logger.error("Database connection failed", error);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> implements StreamAwareReporter<L> {
|
|
25
|
+
#private;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new Server JSON Reporter instance.
|
|
28
|
+
* @param options Configuration options for JSON formatting
|
|
29
|
+
*/
|
|
30
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
31
|
+
/**
|
|
32
|
+
* Sets the stdout stream for the reporter.
|
|
33
|
+
* @param stdout_ The writable stream to use for stdout output
|
|
34
|
+
*/
|
|
35
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the stderr stream for the reporter.
|
|
38
|
+
* @param stderr_ The writable stream to use for stderr output
|
|
39
|
+
*/
|
|
40
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
41
|
+
/**
|
|
42
|
+
* Outputs the JSON message to the appropriate stream.
|
|
43
|
+
*
|
|
44
|
+
* Routes error and warning level messages to stderr, others to stdout.
|
|
45
|
+
* @param message The JSON-formatted log message
|
|
46
|
+
* @param logLevel The log level determining which stream to use
|
|
47
|
+
* @protected
|
|
48
|
+
*/
|
|
49
|
+
protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
50
|
+
}
|
|
51
|
+
export { AbstractJsonReporter, type AbstractJsonReporterOptions, JsonReporter };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as JsonReporter } from '../../packem_shared/JsonReporter-Ck2PIAEw.js';
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-BawNFYxI.js";import{default as p}from"../../packem_shared/JsonReporter-15ln04rX.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,2 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import { D as DefaultLogTypes, L as LoggerTypesConfig, R as ReadonlyMeta, a as LoggerTypesAwareReporter } from "../../packem_shared/types.d-C51XNfQz.js";
|
|
3
|
+
import '@visulima/colorize';
|
|
4
|
+
import '@visulima/interactive-manager';
|
|
5
|
+
/**
|
|
6
|
+
* Abstract Pretty Reporter.
|
|
7
|
+
*
|
|
8
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
9
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
10
|
+
* and logger type configuration.
|
|
11
|
+
* @template T - Custom logger type names
|
|
12
|
+
* @template L - Log level types
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
16
|
+
* public log(meta: ReadonlyMeta) {
|
|
17
|
+
* const formatted = this.formatMessage(meta);
|
|
18
|
+
* console.log(formatted);
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
24
|
+
/** Styling options for pretty formatting */
|
|
25
|
+
protected readonly styles: PrettyStyleOptions;
|
|
26
|
+
/** Logger type configurations for styling */
|
|
27
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
30
|
+
* @param options Styling options for pretty formatting
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
33
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
34
|
+
/**
|
|
35
|
+
* Sets the logger types configuration for styling.
|
|
36
|
+
* @param types Logger type configurations with colors and labels
|
|
37
|
+
*/
|
|
38
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Logs a message with pretty formatting.
|
|
41
|
+
* @param meta The log metadata to format and output
|
|
42
|
+
* @abstract
|
|
43
|
+
*/
|
|
44
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for configuring pretty reporter styling.
|
|
48
|
+
*/
|
|
49
|
+
type PrettyStyleOptions = {
|
|
50
|
+
/** Bold styling options */
|
|
51
|
+
bold: {
|
|
52
|
+
/** Whether to bold the label text */
|
|
53
|
+
label: boolean;
|
|
54
|
+
};
|
|
55
|
+
/** Function to format dates in log output */
|
|
56
|
+
dateFormatter: (date: Date) => string;
|
|
57
|
+
/** Maximum length of message before line break (optional) */
|
|
58
|
+
messageLength: number | undefined;
|
|
59
|
+
/** Underline styling options */
|
|
60
|
+
underline: {
|
|
61
|
+
/** Whether to underline the label */
|
|
62
|
+
label: boolean;
|
|
63
|
+
/** Whether to underline prefixes */
|
|
64
|
+
prefix: boolean;
|
|
65
|
+
/** Whether to underline suffixes */
|
|
66
|
+
suffix: boolean;
|
|
67
|
+
};
|
|
68
|
+
/** Uppercase styling options */
|
|
69
|
+
uppercase: {
|
|
70
|
+
/** Whether to uppercase the label text */
|
|
71
|
+
label: boolean;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Browser Pretty Reporter.
|
|
76
|
+
*
|
|
77
|
+
* A pretty-printing reporter for browser environments that formats log messages
|
|
78
|
+
* with colors and structured layout for console output. Uses browser-compatible
|
|
79
|
+
* color formatting and console APIs.
|
|
80
|
+
* @template T - Custom logger type names
|
|
81
|
+
* @template L - Log level types
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { createPail } from "@visulima/pail";
|
|
85
|
+
*
|
|
86
|
+
* const logger = createPail({
|
|
87
|
+
* reporters: [new PrettyReporter({
|
|
88
|
+
* bold: { label: true },
|
|
89
|
+
* uppercase: { label: true }
|
|
90
|
+
* })]
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* logger.info("Application started");
|
|
94
|
+
* logger.error("Something went wrong", error);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> {
|
|
98
|
+
#private;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a new Browser Pretty Reporter instance.
|
|
101
|
+
* @param options Styling options for pretty formatting
|
|
102
|
+
*/
|
|
103
|
+
constructor(options?: Partial<PrettyStyleOptions>);
|
|
104
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
105
|
+
}
|
|
106
|
+
export { PrettyReporter, type PrettyStyleOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{default as t}from"../../packem_shared/PrettyReporter-Br5njEEy.js";export{t as PrettyReporter};
|
|
@@ -1,2 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { RenderErrorOptions } from '@visulima/error/error';
|
|
2
|
+
import { InteractiveManager } from '@visulima/interactive-manager';
|
|
3
|
+
import { D as DefaultLogTypes, L as LiteralUnion$1, b as LoggerTypesConfig, R as ReadonlyMeta, f as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-ByY2ZuYG.js";
|
|
4
|
+
import '@visulima/colorize';
|
|
5
|
+
/**
|
|
6
|
+
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
7
|
+
|
|
8
|
+
@category Type
|
|
9
|
+
*/
|
|
10
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
11
|
+
/**
|
|
12
|
+
Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
13
|
+
|
|
14
|
+
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
15
|
+
|
|
16
|
+
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
17
|
+
|
|
18
|
+
@example
|
|
19
|
+
```
|
|
20
|
+
import type {LiteralUnion} from 'type-fest';
|
|
21
|
+
|
|
22
|
+
// Before
|
|
23
|
+
|
|
24
|
+
type Pet = 'dog' | 'cat' | string;
|
|
25
|
+
|
|
26
|
+
const petWithoutAutocomplete: Pet = '';
|
|
27
|
+
// Start typing in your TypeScript-enabled IDE.
|
|
28
|
+
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
29
|
+
|
|
30
|
+
// After
|
|
31
|
+
|
|
32
|
+
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
33
|
+
|
|
34
|
+
const petWithAutoComplete: Pet2 = '';
|
|
35
|
+
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
@category Type
|
|
39
|
+
*/
|
|
40
|
+
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
41
|
+
interface Options {
|
|
42
|
+
breakLength: number;
|
|
43
|
+
customInspect: boolean;
|
|
44
|
+
depth: number;
|
|
45
|
+
indent: number | " " | undefined;
|
|
46
|
+
maxArrayLength: number;
|
|
47
|
+
numericSeparator: boolean;
|
|
48
|
+
quoteStyle: "double" | "single";
|
|
49
|
+
showHidden: boolean;
|
|
50
|
+
showProxy: boolean;
|
|
51
|
+
stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
|
|
52
|
+
truncate: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Abstract Pretty Reporter.
|
|
56
|
+
*
|
|
57
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
58
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
59
|
+
* and logger type configuration.
|
|
60
|
+
* @template T - Custom logger type names
|
|
61
|
+
* @template L - Log level types
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
65
|
+
* public log(meta: ReadonlyMeta) {
|
|
66
|
+
* const formatted = this.formatMessage(meta);
|
|
67
|
+
* console.log(formatted);
|
|
68
|
+
* }
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
73
|
+
/** Styling options for pretty formatting */
|
|
74
|
+
protected readonly styles: PrettyStyleOptions;
|
|
75
|
+
/** Logger type configurations for styling */
|
|
76
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
79
|
+
* @param options Styling options for pretty formatting
|
|
80
|
+
* @protected
|
|
81
|
+
*/
|
|
82
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
83
|
+
/**
|
|
84
|
+
* Sets the logger types configuration for styling.
|
|
85
|
+
* @param types Logger type configurations with colors and labels
|
|
86
|
+
*/
|
|
87
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>): void;
|
|
88
|
+
/**
|
|
89
|
+
* Logs a message with pretty formatting.
|
|
90
|
+
* @param meta The log metadata to format and output
|
|
91
|
+
* @abstract
|
|
92
|
+
*/
|
|
93
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Options for configuring pretty reporter styling.
|
|
97
|
+
*/
|
|
98
|
+
type PrettyStyleOptions = {
|
|
99
|
+
/** Bold styling options */
|
|
100
|
+
bold: {
|
|
101
|
+
/** Whether to bold the label text */
|
|
102
|
+
label: boolean;
|
|
103
|
+
};
|
|
104
|
+
/** Function to format dates in log output */
|
|
105
|
+
dateFormatter: (date: Date) => string;
|
|
106
|
+
/** Maximum length of message before line break (optional) */
|
|
107
|
+
messageLength: number | undefined;
|
|
108
|
+
/** Underline styling options */
|
|
109
|
+
underline: {
|
|
110
|
+
/** Whether to underline the label */
|
|
111
|
+
label: boolean;
|
|
112
|
+
/** Whether to underline prefixes */
|
|
113
|
+
prefix: boolean;
|
|
114
|
+
/** Whether to underline suffixes */
|
|
115
|
+
suffix: boolean;
|
|
116
|
+
};
|
|
117
|
+
/** Uppercase styling options */
|
|
118
|
+
uppercase: {
|
|
119
|
+
/** Whether to uppercase the label text */
|
|
120
|
+
label: boolean;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Options for configuring the Server Pretty Reporter.
|
|
125
|
+
*/
|
|
126
|
+
type PrettyReporterOptions = PrettyStyleOptions & {
|
|
127
|
+
/** Error rendering options */
|
|
128
|
+
error: Partial<Omit<RenderErrorOptions, "color" | "prefix" | "indentation">>;
|
|
129
|
+
/** Object inspection options */
|
|
130
|
+
inspect: Partial<Options>;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Server Pretty Reporter.
|
|
134
|
+
*
|
|
135
|
+
* A comprehensive pretty-printing reporter for Node.js server environments that
|
|
136
|
+
* formats log messages with colors, structured layout, and advanced features like
|
|
137
|
+
* error rendering, object inspection, and interactive terminal support.
|
|
138
|
+
* @template T - Custom logger type names
|
|
139
|
+
* @template L - Log level types
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* import { createPail } from "@visulima/pail";
|
|
143
|
+
*
|
|
144
|
+
* const logger = createPail({
|
|
145
|
+
* reporters: [new PrettyReporter({
|
|
146
|
+
* bold: { label: true },
|
|
147
|
+
* error: { color: { title: 'red' } }
|
|
148
|
+
* })]
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* logger.info("Server started on port 3000");
|
|
152
|
+
* logger.error("Database error", dbError);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
156
|
+
#private;
|
|
157
|
+
/**
|
|
158
|
+
* Creates a new Server Pretty Reporter instance.
|
|
159
|
+
* @param options Configuration options for styling, error rendering, and object inspection
|
|
160
|
+
*/
|
|
161
|
+
constructor(options?: Partial<PrettyReporterOptions>);
|
|
162
|
+
/**
|
|
163
|
+
* Sets the stdout stream for the reporter.
|
|
164
|
+
* @param stdout_ The writable stream to use for standard output
|
|
165
|
+
*/
|
|
166
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
167
|
+
/**
|
|
168
|
+
* Sets the stderr stream for the reporter.
|
|
169
|
+
* @param stderr_ The writable stream to use for error output
|
|
170
|
+
*/
|
|
171
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
172
|
+
/**
|
|
173
|
+
* Sets the interactive manager for handling interactive output.
|
|
174
|
+
* @param manager The interactive manager instance, or undefined to disable
|
|
175
|
+
*/
|
|
176
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
177
|
+
/**
|
|
178
|
+
* Enables or disables interactive mode.
|
|
179
|
+
* @param interactive Whether to enable interactive terminal features
|
|
180
|
+
*/
|
|
181
|
+
setIsInteractive(interactive: boolean): void;
|
|
182
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
183
|
+
protected _formatMessage(data: ReadonlyMeta<L>): string;
|
|
184
|
+
protected _log(message: string, logLevel: LiteralUnion$1<ExtendedRfc5424LogLevels, L>): void;
|
|
185
|
+
}
|
|
186
|
+
export { PrettyReporter, type PrettyReporterOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-CgXnwIip.js";export{t as PrettyReporter};
|
|
@@ -1,20 +1,170 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { InteractiveManager } from '@visulima/interactive-manager';
|
|
2
|
+
import { D as DefaultLogTypes, L as LiteralUnion$1, a as LoggerTypesConfig, g as ReadonlyMeta, e as LoggerTypesAwareReporter, I as InteractiveStreamReporter } from "../../packem_shared/types.d-CM5ie2qm.js";
|
|
3
|
+
import '@visulima/colorize';
|
|
4
|
+
type ColorizeMethod = (value: string) => string;
|
|
5
|
+
type CodeFrameOptions = {
|
|
6
|
+
color?: {
|
|
7
|
+
gutter?: ColorizeMethod;
|
|
8
|
+
marker?: ColorizeMethod;
|
|
9
|
+
message?: ColorizeMethod;
|
|
10
|
+
};
|
|
11
|
+
linesAbove?: number;
|
|
12
|
+
linesBelow?: number;
|
|
13
|
+
message?: string;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
showGutter?: boolean;
|
|
16
|
+
showLineNumbers?: boolean;
|
|
17
|
+
tabWidth?: number | false;
|
|
10
18
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
40
|
+
|
|
41
|
+
@category Type
|
|
42
|
+
*/
|
|
43
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
44
|
+
/**
|
|
45
|
+
Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
46
|
+
|
|
47
|
+
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
48
|
+
|
|
49
|
+
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
50
|
+
|
|
51
|
+
@example
|
|
52
|
+
```
|
|
53
|
+
import type {LiteralUnion} from 'type-fest';
|
|
54
|
+
|
|
55
|
+
// Before
|
|
56
|
+
|
|
57
|
+
type Pet = 'dog' | 'cat' | string;
|
|
58
|
+
|
|
59
|
+
const petWithoutAutocomplete: Pet = '';
|
|
60
|
+
// Start typing in your TypeScript-enabled IDE.
|
|
61
|
+
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
62
|
+
|
|
63
|
+
// After
|
|
64
|
+
|
|
65
|
+
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
66
|
+
|
|
67
|
+
const petWithAutoComplete: Pet2 = '';
|
|
68
|
+
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
@category Type
|
|
72
|
+
*/
|
|
73
|
+
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
74
|
+
interface Options {
|
|
75
|
+
breakLength: number;
|
|
76
|
+
customInspect: boolean;
|
|
77
|
+
depth: number;
|
|
78
|
+
indent: number | " " | undefined;
|
|
79
|
+
maxArrayLength: number;
|
|
80
|
+
numericSeparator: boolean;
|
|
81
|
+
quoteStyle: "double" | "single";
|
|
82
|
+
showHidden: boolean;
|
|
83
|
+
showProxy: boolean;
|
|
84
|
+
stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
|
|
85
|
+
truncate: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Abstract Pretty Reporter.
|
|
89
|
+
*
|
|
90
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
91
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
92
|
+
* and logger type configuration.
|
|
93
|
+
* @template T - Custom logger type names
|
|
94
|
+
* @template L - Log level types
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
98
|
+
* public log(meta: ReadonlyMeta) {
|
|
99
|
+
* const formatted = this.formatMessage(meta);
|
|
100
|
+
* console.log(formatted);
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
106
|
+
/** Styling options for pretty formatting */
|
|
107
|
+
protected readonly styles: PrettyStyleOptions;
|
|
108
|
+
/** Logger type configurations for styling */
|
|
109
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>;
|
|
110
|
+
/**
|
|
111
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
112
|
+
* @param options Styling options for pretty formatting
|
|
113
|
+
* @protected
|
|
114
|
+
*/
|
|
115
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
116
|
+
/**
|
|
117
|
+
* Sets the logger types configuration for styling.
|
|
118
|
+
* @param types Logger type configurations with colors and labels
|
|
119
|
+
*/
|
|
120
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>): void;
|
|
121
|
+
/**
|
|
122
|
+
* Logs a message with pretty formatting.
|
|
123
|
+
* @param meta The log metadata to format and output
|
|
124
|
+
* @abstract
|
|
125
|
+
*/
|
|
126
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Options for configuring pretty reporter styling.
|
|
130
|
+
*/
|
|
131
|
+
type PrettyStyleOptions = {
|
|
132
|
+
/** Bold styling options */
|
|
133
|
+
bold: {
|
|
134
|
+
/** Whether to bold the label text */
|
|
135
|
+
label: boolean;
|
|
136
|
+
};
|
|
137
|
+
/** Function to format dates in log output */
|
|
138
|
+
dateFormatter: (date: Date) => string;
|
|
139
|
+
/** Maximum length of message before line break (optional) */
|
|
140
|
+
messageLength: number | undefined;
|
|
141
|
+
/** Underline styling options */
|
|
142
|
+
underline: {
|
|
143
|
+
/** Whether to underline the label */
|
|
144
|
+
label: boolean;
|
|
145
|
+
/** Whether to underline prefixes */
|
|
146
|
+
prefix: boolean;
|
|
147
|
+
/** Whether to underline suffixes */
|
|
148
|
+
suffix: boolean;
|
|
149
|
+
};
|
|
150
|
+
/** Uppercase styling options */
|
|
151
|
+
uppercase: {
|
|
152
|
+
/** Whether to uppercase the label text */
|
|
153
|
+
label: boolean;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
type SimpleReporterOptions = PrettyStyleOptions & {
|
|
157
|
+
error: Partial<Omit<Options$1, "color | prefix | indentation">>;
|
|
158
|
+
inspect: Partial<Options>;
|
|
159
|
+
};
|
|
160
|
+
declare class SimpleReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
161
|
+
#private;
|
|
162
|
+
constructor(options?: Partial<SimpleReporterOptions>);
|
|
163
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
164
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
165
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
166
|
+
setIsInteractive(interactive: boolean): void;
|
|
167
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
168
|
+
protected formatMessage(data: ReadonlyMeta<L>): string;
|
|
20
169
|
}
|
|
170
|
+
export { SimpleReporter, SimpleReporterOptions };
|