@visulima/pail 3.1.0 → 3.2.1
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 +59 -0
- package/LICENSE.md +3 -407
- package/README.md +298 -0
- package/dist/constants.d.ts +37 -0
- package/dist/index.browser.d.ts +47 -12
- package/dist/index.browser.js +12 -1
- package/dist/index.server.d.ts +65 -40
- package/dist/index.server.js +533 -2
- package/dist/interactive/index.d.ts +2 -28
- package/dist/interactive/index.js +2 -1
- package/dist/interactive/interactive-manager.d.ts +108 -0
- package/dist/interactive/interactive-stream-hook.d.ts +68 -0
- package/dist/object-tree.d.ts +65 -7
- package/dist/object-tree.js +89 -2
- package/dist/packem_shared/AbstractJsonReporter-intFdT_A.js +204 -0
- package/dist/packem_shared/InteractiveManager-CZ85hGNW.js +172 -0
- package/dist/packem_shared/InteractiveStreamHook-DiSubbJ1.js +21 -0
- package/dist/packem_shared/JsonReporter-C0AXk99i.js +58 -0
- package/dist/packem_shared/JsonReporter-DcM2LBX9.js +28 -0
- package/dist/packem_shared/PrettyReporter-BFWaYP_J.js +222 -0
- package/dist/packem_shared/PrettyReporter-CuLLKr6-.js +169 -0
- package/dist/packem_shared/abstract-pretty-reporter-DMPDCslJ.js +50 -0
- package/dist/packem_shared/constants-DfDr4MHC.js +119 -0
- package/dist/packem_shared/format-label-Btft2KGP.js +1194 -0
- package/dist/packem_shared/get-longest-label-C9PWeyKq.js +9 -0
- package/dist/packem_shared/index-BomQ3E6J.js +650 -0
- package/dist/packem_shared/index-DqKWykfa.js +1146 -0
- package/dist/packem_shared/interactive-stream-hook-DG4BtN12.js +141 -0
- package/dist/packem_shared/pail.browser-CPjQrsyy.js +1427 -0
- package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +14 -0
- package/dist/packem_shared/write-stream-BG8fhcs3.js +6 -0
- package/dist/pail.browser.d.ts +412 -0
- package/dist/pail.server.d.ts +233 -0
- package/dist/processor/caller/caller-processor.d.ts +40 -7
- package/dist/processor/caller/caller-processor.js +59 -1
- package/dist/processor/caller/get-caller-filename.d.ts +23 -0
- package/dist/processor/message-formatter-processor.d.ts +44 -9
- package/dist/processor/message-formatter-processor.js +67 -1
- package/dist/processor/opentelemetry-processor.d.ts +70 -0
- package/dist/processor/opentelemetry-processor.js +52 -0
- package/dist/processor/redact-processor.d.ts +39 -8
- package/dist/processor/redact-processor.js +30 -1
- package/dist/progress-bar.d.ts +75 -15
- package/dist/progress-bar.js +404 -1
- package/dist/reporter/file/json-file-reporter.d.ts +39 -20
- package/dist/reporter/file/json-file-reporter.js +136 -4
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +48 -0
- package/dist/reporter/http/abstract-http-reporter.d.ts +215 -0
- package/dist/reporter/http/abstract-http-reporter.js +435 -0
- package/dist/reporter/http/http-reporter.d.ts +39 -0
- package/dist/reporter/http/http-reporter.edge-light.d.ts +40 -0
- package/dist/reporter/http/http-reporter.edge-light.js +651 -0
- package/dist/reporter/http/http-reporter.js +13 -0
- package/dist/reporter/http/utils/compression.d.ts +7 -0
- package/dist/reporter/http/utils/log-size-error.d.ts +30 -0
- package/dist/reporter/http/utils/retry.d.ts +27 -0
- package/dist/reporter/json/abstract-json-reporter.d.ts +61 -0
- package/dist/reporter/json/index.browser.d.ts +3 -13
- package/dist/reporter/json/index.browser.js +2 -1
- package/dist/reporter/json/index.d.ts +3 -16
- package/dist/reporter/json/index.js +2 -1
- package/dist/reporter/json/json-reporter.browser.d.ts +40 -0
- package/dist/reporter/json/json-reporter.server.d.ts +50 -0
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +83 -0
- package/dist/reporter/pretty/index.browser.d.ts +2 -13
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +2 -25
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +36 -0
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +70 -0
- package/dist/reporter/raw/raw-reporter.browser.d.ts +5 -0
- package/dist/reporter/raw/raw-reporter.server.d.ts +13 -0
- package/dist/reporter/simple/simple-reporter.server.d.ts +10 -14
- package/dist/reporter/simple/simple-reporter.server.js +186 -8
- package/dist/reporter/utils/default-inspector-config.d.ts +3 -0
- package/dist/reporter/utils/format-label.d.ts +3 -0
- package/dist/spinner.d.ts +170 -104
- package/dist/spinner.js +2150 -1
- package/dist/types.d.ts +241 -0
- package/dist/utils/ansi-escapes.d.ts +4 -0
- package/dist/utils/arrayify.d.ts +2 -0
- package/dist/utils/get-longest-badge.d.ts +4 -0
- package/dist/utils/get-longest-label.d.ts +4 -0
- package/dist/utils/merge-types.d.ts +4 -0
- package/dist/utils/stream/safe-stream-handler.d.ts +21 -0
- package/dist/utils/write-console-log-based-on-level.d.ts +4 -0
- package/dist/utils/write-stream.d.ts +2 -0
- package/package.json +53 -4
- package/dist/packem_shared/AbstractJsonReporter-UftN6CIL.js +0 -1
- package/dist/packem_shared/InteractiveManager-CgmJyW9x.js +0 -3
- package/dist/packem_shared/InteractiveStreamHook-NtJu71aN.js +0 -1
- package/dist/packem_shared/JsonReporter-DTBtHNaD.js +0 -2
- package/dist/packem_shared/JsonReporter-Dl4m0xZe.js +0 -1
- package/dist/packem_shared/PrettyReporter-Bns0ZWLy.js +0 -12
- package/dist/packem_shared/PrettyReporter-CGKSTI7X.js +0 -5
- package/dist/packem_shared/abstract-json-reporter-CPsNkpz8.d.ts +0 -22
- package/dist/packem_shared/abstract-pretty-reporter-CUtSm20r.js +0 -1
- package/dist/packem_shared/abstract-pretty-reporter-DB2G-qlI.d.ts +0 -28
- package/dist/packem_shared/constants-DKfCaSUR.js +0 -1
- package/dist/packem_shared/format-label-CpyyTBom.js +0 -26
- package/dist/packem_shared/get-longest-label-B0NrI-o2.js +0 -1
- package/dist/packem_shared/index-CysYvHXs.js +0 -8
- package/dist/packem_shared/index-D9hWq9ka.js +0 -1
- package/dist/packem_shared/index.d-BR1GjZri.d.ts +0 -53
- package/dist/packem_shared/index.d-oxZvg_y7.d.ts +0 -20
- package/dist/packem_shared/interactive-stream-hook-CeVo4Kth.js +0 -2
- package/dist/packem_shared/pail.browser-BmHoDvEA.js +0 -19
- package/dist/packem_shared/pail.browser-CmWcqnn9.d.ts +0 -64
- package/dist/packem_shared/types-DVzG8TWL.d.ts +0 -95
- package/dist/packem_shared/write-console-log-based-on-level-BP95fgQZ.js +0 -1
- package/dist/packem_shared/write-stream-CD8XFv1L.js +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a log entry exceeds the maximum allowed size.
|
|
3
|
+
*/
|
|
4
|
+
declare class LogSizeError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* The log entry data that caused the error
|
|
7
|
+
*/
|
|
8
|
+
readonly logData: Record<string, unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* The actual size of the log entry in bytes
|
|
11
|
+
*/
|
|
12
|
+
readonly actualSize: number;
|
|
13
|
+
/**
|
|
14
|
+
* The maximum allowed size in bytes
|
|
15
|
+
*/
|
|
16
|
+
readonly maxSize: number;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new LogSizeError instance.
|
|
19
|
+
* @param message Descriptive error message explaining the size violation
|
|
20
|
+
* @param logData The log entry data that caused the error
|
|
21
|
+
* @param actualSize Size of the log entry in bytes
|
|
22
|
+
* @param maxSize Maximum allowed size in bytes
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* throw new LogSizeError("Log too large", logData, 2000000, 1000000);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
constructor(message: string, logData: Record<string, unknown>, actualSize: number, maxSize: number);
|
|
29
|
+
}
|
|
30
|
+
export default LogSizeError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends an HTTP request with retry logic and rate limiting support.
|
|
3
|
+
* @param url The URL to send the request to
|
|
4
|
+
* @param method The HTTP method to use
|
|
5
|
+
* @param headers Request headers
|
|
6
|
+
* @param body The request body (string or Uint8Array)
|
|
7
|
+
* @param maxRetries Maximum number of retry attempts
|
|
8
|
+
* @param retryDelay Base delay between retries in milliseconds
|
|
9
|
+
* @param respectRateLimit Whether to respect rate limiting (429 responses)
|
|
10
|
+
* @param onDebugRequestResponse Optional callback for debugging requests/responses
|
|
11
|
+
* @param onError Optional callback for error handling
|
|
12
|
+
*/
|
|
13
|
+
declare const sendWithRetry: (url: string, method: string, headers: Record<string, string>, body: string | Uint8Array, maxRetries: number, retryDelay: number, respectRateLimit: boolean, onDebugRequestResponse?: (requestResponse: {
|
|
14
|
+
req: {
|
|
15
|
+
body: string | Uint8Array;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
method: string;
|
|
18
|
+
url: string;
|
|
19
|
+
};
|
|
20
|
+
res: {
|
|
21
|
+
body: string;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
status: number;
|
|
24
|
+
statusText: string;
|
|
25
|
+
};
|
|
26
|
+
}) => void, onError?: (error: Error) => void) => Promise<void>;
|
|
27
|
+
export default sendWithRetry;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { stringify } from "safe-stable-stringify";
|
|
2
|
+
import type { LiteralUnion } from "type-fest";
|
|
3
|
+
import type { ExtendedRfc5424LogLevels, ReadonlyMeta, StringifyAwareReporter } from "../../types.d.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring JSON reporters.
|
|
6
|
+
*/
|
|
7
|
+
export type AbstractJsonReporterOptions = {
|
|
8
|
+
/** Error serialization options */
|
|
9
|
+
error: Partial<{
|
|
10
|
+
/** Properties to exclude from error serialization */
|
|
11
|
+
exclude?: string[];
|
|
12
|
+
/** Maximum depth for error object serialization */
|
|
13
|
+
maxDepth?: number;
|
|
14
|
+
/** Whether to use toJSON methods during serialization */
|
|
15
|
+
useToJSON?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Abstract JSON Reporter.
|
|
20
|
+
*
|
|
21
|
+
* Base class for JSON-based reporters that provides common functionality
|
|
22
|
+
* for serializing log metadata to JSON format. Handles error serialization,
|
|
23
|
+
* context processing, and provides a template method for actual output.
|
|
24
|
+
* @template L - The log level type
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* class CustomJsonReporter extends AbstractJsonReporter {
|
|
28
|
+
* protected _log(message: string): void {
|
|
29
|
+
* console.log(message);
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare abstract class AbstractJsonReporter<L extends string = string> implements StringifyAwareReporter<L> {
|
|
35
|
+
/** Custom stringify function for object serialization */
|
|
36
|
+
protected stringify: typeof stringify | undefined;
|
|
37
|
+
/** Error serialization options */
|
|
38
|
+
protected errorOptions: AbstractJsonReporterOptions["error"];
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new AbstractJsonReporter instance.
|
|
41
|
+
* @param options Configuration options for JSON formatting and error handling
|
|
42
|
+
*/
|
|
43
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
44
|
+
/**
|
|
45
|
+
* Sets a custom stringify function for object serialization.
|
|
46
|
+
* @param function_ The stringify function to use for serialization
|
|
47
|
+
*/
|
|
48
|
+
setStringify(function_: any): void;
|
|
49
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Template method for outputting the JSON log message.
|
|
52
|
+
*
|
|
53
|
+
* Subclasses must implement this method to define how the JSON message
|
|
54
|
+
* is actually written (to console, file, network, etc.).
|
|
55
|
+
* @param message The JSON-formatted log message
|
|
56
|
+
* @param logLevel The log level of the message
|
|
57
|
+
* @protected
|
|
58
|
+
* @abstract
|
|
59
|
+
*/
|
|
60
|
+
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
61
|
+
}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '../../packem_shared/index.d-oxZvg_y7.js';
|
|
5
|
-
import '@visulima/colorize';
|
|
6
|
-
import '../../interactive/index.js';
|
|
7
|
-
|
|
8
|
-
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> {
|
|
9
|
-
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
10
|
-
protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { AbstractJsonReporter, AbstractJsonReporterOptions, JsonReporter };
|
|
1
|
+
export type { AbstractJsonReporterOptions } from "./abstract-json-reporter.d.ts";
|
|
2
|
+
export { AbstractJsonReporter } from "./abstract-json-reporter.d.ts";
|
|
3
|
+
export { default as JsonReporter } from "./json-reporter.d.ts";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-intFdT_A.js';
|
|
2
|
+
export { default as JsonReporter } from '../../packem_shared/JsonReporter-DcM2LBX9.js';
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '../../packem_shared/index.d-oxZvg_y7.js';
|
|
5
|
-
import '@visulima/colorize';
|
|
6
|
-
import '../../interactive/index.js';
|
|
7
|
-
|
|
8
|
-
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> implements StreamAwareReporter<L> {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
11
|
-
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
12
|
-
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
13
|
-
protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { AbstractJsonReporter, AbstractJsonReporterOptions, JsonReporter };
|
|
1
|
+
export type { AbstractJsonReporterOptions } from "./abstract-json-reporter.d.ts";
|
|
2
|
+
export { AbstractJsonReporter } from "./abstract-json-reporter.d.ts";
|
|
3
|
+
export { default as JsonReporter } from "./json-reporter.d.ts";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { AbstractJsonReporter } from '../../packem_shared/AbstractJsonReporter-intFdT_A.js';
|
|
2
|
+
export { default as JsonReporter } from '../../packem_shared/JsonReporter-C0AXk99i.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LiteralUnion } from "type-fest";
|
|
2
|
+
import type { ExtendedRfc5424LogLevels } from "../../types.d.ts";
|
|
3
|
+
import type { AbstractJsonReporterOptions } from "./abstract-json-reporter.d.ts";
|
|
4
|
+
import { AbstractJsonReporter } from "./abstract-json-reporter.d.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Browser JSON Reporter.
|
|
7
|
+
*
|
|
8
|
+
* A JSON reporter for browser environments that outputs structured log data
|
|
9
|
+
* to the browser console. Uses appropriate console methods based on log level.
|
|
10
|
+
* @template L - The log level type
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createPail } from "@visulima/pail";
|
|
14
|
+
*
|
|
15
|
+
* const logger = createPail({
|
|
16
|
+
* reporters: [new JsonReporter()]
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* logger.info("Application started", { version: "1.0.0" });
|
|
20
|
+
* // Outputs: {"level":"info","message":"Application started","context":[{"version":"1.0.0"}],...}
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new Browser JSON Reporter instance.
|
|
26
|
+
* @param options Configuration options for JSON formatting
|
|
27
|
+
*/
|
|
28
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
29
|
+
/**
|
|
30
|
+
* Outputs the JSON message to the browser console.
|
|
31
|
+
*
|
|
32
|
+
* Uses the appropriate console method based on the log level
|
|
33
|
+
* (console.log, console.error, console.warn, etc.).
|
|
34
|
+
* @param message The JSON-formatted log message
|
|
35
|
+
* @param logLevel The log level determining which console method to use
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
38
|
+
protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
39
|
+
}
|
|
40
|
+
export default JsonReporter;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { LiteralUnion } from "type-fest";
|
|
2
|
+
import type { ExtendedRfc5424LogLevels, StreamAwareReporter } from "../../types.d.ts";
|
|
3
|
+
import type { AbstractJsonReporterOptions } from "./abstract-json-reporter.d.ts";
|
|
4
|
+
import { AbstractJsonReporter } from "./abstract-json-reporter.d.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Server JSON Reporter.
|
|
7
|
+
*
|
|
8
|
+
* A JSON reporter for Node.js server environments that outputs structured log data
|
|
9
|
+
* to stdout/stderr streams. Routes error-level logs to stderr and others to stdout.
|
|
10
|
+
* @template L - The log level type
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createPail } from "@visulima/pail";
|
|
14
|
+
*
|
|
15
|
+
* const logger = createPail({
|
|
16
|
+
* reporters: [new JsonReporter()]
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* logger.info("Server started", { port: 3000 });
|
|
20
|
+
* logger.error("Database connection failed", error);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> implements StreamAwareReporter<L> {
|
|
24
|
+
#private;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new Server JSON Reporter instance.
|
|
27
|
+
* @param options Configuration options for JSON formatting
|
|
28
|
+
*/
|
|
29
|
+
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
30
|
+
/**
|
|
31
|
+
* Sets the stdout stream for the reporter.
|
|
32
|
+
* @param stdout_ The writable stream to use for stdout output
|
|
33
|
+
*/
|
|
34
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the stderr stream for the reporter.
|
|
37
|
+
* @param stderr_ The writable stream to use for stderr output
|
|
38
|
+
*/
|
|
39
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
40
|
+
/**
|
|
41
|
+
* Outputs the JSON message to the appropriate stream.
|
|
42
|
+
*
|
|
43
|
+
* Routes error and warning level messages to stderr, others to stdout.
|
|
44
|
+
* @param message The JSON-formatted log message
|
|
45
|
+
* @param logLevel The log level determining which stream to use
|
|
46
|
+
* @protected
|
|
47
|
+
*/
|
|
48
|
+
protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
49
|
+
}
|
|
50
|
+
export default JsonReporter;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { LiteralUnion } from "type-fest";
|
|
2
|
+
import type { DefaultLogTypes, LoggerTypesAwareReporter, LoggerTypesConfig, ReadonlyMeta } from "../../types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Default date formatter for pretty reporters.
|
|
5
|
+
*
|
|
6
|
+
* Formats a Date object as HH:MM:SS (24-hour format).
|
|
7
|
+
* @param date The date to format
|
|
8
|
+
* @returns Formatted time string
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* dateFormatter(new Date()); // "14:30:25"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const dateFormatter: (date: Date) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Abstract Pretty Reporter.
|
|
17
|
+
*
|
|
18
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
19
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
20
|
+
* and logger type configuration.
|
|
21
|
+
* @template T - Custom logger type names
|
|
22
|
+
* @template L - Log level types
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
26
|
+
* public log(meta: ReadonlyMeta) {
|
|
27
|
+
* const formatted = this.formatMessage(meta);
|
|
28
|
+
* console.log(formatted);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
34
|
+
/** Styling options for pretty formatting */
|
|
35
|
+
protected readonly styles: PrettyStyleOptions;
|
|
36
|
+
/** Logger type configurations for styling */
|
|
37
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
40
|
+
* @param options Styling options for pretty formatting
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
43
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
44
|
+
/**
|
|
45
|
+
* Sets the logger types configuration for styling.
|
|
46
|
+
* @param types Logger type configurations with colors and labels
|
|
47
|
+
*/
|
|
48
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Logs a message with pretty formatting.
|
|
51
|
+
* @param meta The log metadata to format and output
|
|
52
|
+
* @abstract
|
|
53
|
+
*/
|
|
54
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Options for configuring pretty reporter styling.
|
|
58
|
+
*/
|
|
59
|
+
export type PrettyStyleOptions = {
|
|
60
|
+
/** Bold styling options */
|
|
61
|
+
bold: {
|
|
62
|
+
/** Whether to bold the label text */
|
|
63
|
+
label: boolean;
|
|
64
|
+
};
|
|
65
|
+
/** Function to format dates in log output */
|
|
66
|
+
dateFormatter: (date: Date) => string;
|
|
67
|
+
/** Maximum length of message before line break (optional) */
|
|
68
|
+
messageLength: number | undefined;
|
|
69
|
+
/** Underline styling options */
|
|
70
|
+
underline: {
|
|
71
|
+
/** Whether to underline the label */
|
|
72
|
+
label: boolean;
|
|
73
|
+
/** Whether to underline prefixes */
|
|
74
|
+
prefix: boolean;
|
|
75
|
+
/** Whether to underline suffixes */
|
|
76
|
+
suffix: boolean;
|
|
77
|
+
};
|
|
78
|
+
/** Uppercase styling options */
|
|
79
|
+
uppercase: {
|
|
80
|
+
/** Whether to uppercase the label text */
|
|
81
|
+
label: boolean;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import 'type-fest';
|
|
4
|
-
import '@visulima/colorize';
|
|
5
|
-
import '../../interactive/index.js';
|
|
6
|
-
|
|
7
|
-
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> {
|
|
8
|
-
#private;
|
|
9
|
-
constructor(options?: Partial<PrettyStyleOptions>);
|
|
10
|
-
log(meta: ReadonlyMeta<L>): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { PrettyReporter, PrettyStyleOptions };
|
|
1
|
+
export type { PrettyStyleOptions } from "./abstract-pretty-reporter.d.ts";
|
|
2
|
+
export { default as PrettyReporter } from "./pretty-reporter.d.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { default as PrettyReporter } from '../../packem_shared/PrettyReporter-CuLLKr6-.js';
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { InteractiveManager } from '../../interactive/index.js';
|
|
4
|
-
import { I as InteractiveStreamReporter, f as ReadonlyMeta, E as ExtendedRfc5424LogLevels } from '../../packem_shared/types-DVzG8TWL.js';
|
|
5
|
-
import { P as PrettyStyleOptions, A as AbstractPrettyReporter } from '../../packem_shared/abstract-pretty-reporter-DB2G-qlI.js';
|
|
6
|
-
import '@visulima/colorize';
|
|
7
|
-
|
|
8
|
-
type PrettyReporterOptions = PrettyStyleOptions & {
|
|
9
|
-
error: Partial<Omit<Options$1, "color" | "prefix" | "indentation">>;
|
|
10
|
-
inspect: Partial<Options>;
|
|
11
|
-
};
|
|
12
|
-
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
13
|
-
#private;
|
|
14
|
-
constructor(options?: Partial<PrettyReporterOptions>);
|
|
15
|
-
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
16
|
-
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
17
|
-
setInteractiveManager(manager?: InteractiveManager): void;
|
|
18
|
-
setIsInteractive(interactive: boolean): void;
|
|
19
|
-
log(meta: ReadonlyMeta<L>): void;
|
|
20
|
-
protected _formatMessage(data: ReadonlyMeta<L>): string;
|
|
21
|
-
protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { PrettyReporter };
|
|
25
|
-
export type { PrettyReporterOptions };
|
|
1
|
+
export type { PrettyReporterOptions } from "./pretty-reporter.d.ts";
|
|
2
|
+
export { PrettyReporter } from "./pretty-reporter.d.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { PrettyReporter } from '../../packem_shared/PrettyReporter-BFWaYP_J.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReadonlyMeta } from "../../types.d.ts";
|
|
2
|
+
import type { PrettyStyleOptions } from "./abstract-pretty-reporter.d.ts";
|
|
3
|
+
import { AbstractPrettyReporter } from "./abstract-pretty-reporter.d.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Browser Pretty Reporter.
|
|
6
|
+
*
|
|
7
|
+
* A pretty-printing reporter for browser environments that formats log messages
|
|
8
|
+
* with colors and structured layout for console output. Uses browser-compatible
|
|
9
|
+
* color formatting and console APIs.
|
|
10
|
+
* @template T - Custom logger type names
|
|
11
|
+
* @template L - Log level types
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createPail } from "@visulima/pail";
|
|
15
|
+
*
|
|
16
|
+
* const logger = createPail({
|
|
17
|
+
* reporters: [new PrettyReporter({
|
|
18
|
+
* bold: { label: true },
|
|
19
|
+
* uppercase: { label: true }
|
|
20
|
+
* })]
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* logger.info("Application started");
|
|
24
|
+
* logger.error("Something went wrong", error);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> {
|
|
28
|
+
#private;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new Browser Pretty Reporter instance.
|
|
31
|
+
* @param options Styling options for pretty formatting
|
|
32
|
+
*/
|
|
33
|
+
constructor(options?: Partial<PrettyStyleOptions>);
|
|
34
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
35
|
+
}
|
|
36
|
+
export default PrettyReporter;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { RenderErrorOptions } from "@visulima/error/error";
|
|
2
|
+
import type { Options as InspectorOptions } from "@visulima/inspector";
|
|
3
|
+
import type { LiteralUnion } from "type-fest";
|
|
4
|
+
import type InteractiveManager from "../../interactive/interactive-manager.d.ts";
|
|
5
|
+
import type { ExtendedRfc5424LogLevels, InteractiveStreamReporter, ReadonlyMeta } from "../../types.d.ts";
|
|
6
|
+
import type { PrettyStyleOptions } from "./abstract-pretty-reporter.d.ts";
|
|
7
|
+
import { AbstractPrettyReporter } from "./abstract-pretty-reporter.d.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Options for configuring the Server Pretty Reporter.
|
|
10
|
+
*/
|
|
11
|
+
export type PrettyReporterOptions = PrettyStyleOptions & {
|
|
12
|
+
/** Error rendering options */
|
|
13
|
+
error: Partial<Omit<RenderErrorOptions, "color" | "prefix" | "indentation">>;
|
|
14
|
+
/** Object inspection options */
|
|
15
|
+
inspect: Partial<InspectorOptions>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Server Pretty Reporter.
|
|
19
|
+
*
|
|
20
|
+
* A comprehensive pretty-printing reporter for Node.js server environments that
|
|
21
|
+
* formats log messages with colors, structured layout, and advanced features like
|
|
22
|
+
* error rendering, object inspection, and interactive terminal support.
|
|
23
|
+
* @template T - Custom logger type names
|
|
24
|
+
* @template L - Log level types
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { createPail } from "@visulima/pail";
|
|
28
|
+
*
|
|
29
|
+
* const logger = createPail({
|
|
30
|
+
* reporters: [new PrettyReporter({
|
|
31
|
+
* bold: { label: true },
|
|
32
|
+
* error: { color: { title: 'red' } }
|
|
33
|
+
* })]
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* logger.info("Server started on port 3000");
|
|
37
|
+
* logger.error("Database error", dbError);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
41
|
+
#private;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new Server Pretty Reporter instance.
|
|
44
|
+
* @param options Configuration options for styling, error rendering, and object inspection
|
|
45
|
+
*/
|
|
46
|
+
constructor(options?: Partial<PrettyReporterOptions>);
|
|
47
|
+
/**
|
|
48
|
+
* Sets the stdout stream for the reporter.
|
|
49
|
+
* @param stdout_ The writable stream to use for standard output
|
|
50
|
+
*/
|
|
51
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
52
|
+
/**
|
|
53
|
+
* Sets the stderr stream for the reporter.
|
|
54
|
+
* @param stderr_ The writable stream to use for error output
|
|
55
|
+
*/
|
|
56
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
57
|
+
/**
|
|
58
|
+
* Sets the interactive manager for handling interactive output.
|
|
59
|
+
* @param manager The interactive manager instance, or undefined to disable
|
|
60
|
+
*/
|
|
61
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
62
|
+
/**
|
|
63
|
+
* Enables or disables interactive mode.
|
|
64
|
+
* @param interactive Whether to enable interactive terminal features
|
|
65
|
+
*/
|
|
66
|
+
setIsInteractive(interactive: boolean): void;
|
|
67
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
68
|
+
protected _formatMessage(data: ReadonlyMeta<L>): string;
|
|
69
|
+
protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Options as InspectorOptions } from "@visulima/inspector";
|
|
2
|
+
import type InteractiveManager from "../../interactive/interactive-manager.d.ts";
|
|
3
|
+
import type { ReadonlyMeta, StreamAwareReporter } from "../../types.d.ts";
|
|
4
|
+
declare class RawReporter<L extends string = string> implements StreamAwareReporter<L> {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(inspectOptions?: Partial<InspectorOptions>);
|
|
7
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
8
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
9
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
10
|
+
setIsInteractive(interactive: boolean): void;
|
|
11
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
12
|
+
}
|
|
13
|
+
export default RawReporter;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
inspect: Partial<Options>;
|
|
1
|
+
import type { RenderErrorOptions } from "@visulima/error";
|
|
2
|
+
import type { Options as InspectorOptions } from "@visulima/inspector";
|
|
3
|
+
import type InteractiveManager from "../../interactive/interactive-manager.d.ts";
|
|
4
|
+
import type { InteractiveStreamReporter, ReadonlyMeta } from "../../types.d.ts";
|
|
5
|
+
import type { PrettyStyleOptions } from "../pretty/abstract-pretty-reporter.d.ts";
|
|
6
|
+
import { AbstractPrettyReporter } from "../pretty/abstract-pretty-reporter.d.ts";
|
|
7
|
+
export type SimpleReporterOptions = PrettyStyleOptions & {
|
|
8
|
+
error: Partial<Omit<RenderErrorOptions, "color | prefix | indentation">>;
|
|
9
|
+
inspect: Partial<InspectorOptions>;
|
|
11
10
|
};
|
|
12
|
-
declare class SimpleReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
11
|
+
export declare class SimpleReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
13
12
|
#private;
|
|
14
13
|
constructor(options?: Partial<SimpleReporterOptions>);
|
|
15
14
|
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
@@ -19,6 +18,3 @@ declare class SimpleReporter<T extends string = string, L extends string = strin
|
|
|
19
18
|
log(meta: ReadonlyMeta<L>): void;
|
|
20
19
|
protected formatMessage(data: ReadonlyMeta<L>): string;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
export { SimpleReporter };
|
|
24
|
-
export type { SimpleReporterOptions };
|