@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.
Files changed (127) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE.md +131 -900
  3. package/dist/error.d.ts +95 -96
  4. package/dist/error.js +5 -76
  5. package/dist/index.browser.d.ts +557 -47
  6. package/dist/index.browser.js +19 -1499
  7. package/dist/index.server.d.ts +722 -61
  8. package/dist/index.server.js +31 -2803
  9. package/dist/middleware/elysia.d.ts +65 -63
  10. package/dist/middleware/elysia.js +1 -70
  11. package/dist/middleware/express.d.ts +73 -71
  12. package/dist/middleware/express.js +1 -29
  13. package/dist/middleware/fastify.d.ts +69 -67
  14. package/dist/middleware/fastify.js +1 -46
  15. package/dist/middleware/hono.d.ts +74 -72
  16. package/dist/middleware/hono.js +1 -33
  17. package/dist/middleware/next/handler.d.ts +101 -34
  18. package/dist/middleware/next/handler.js +1 -53
  19. package/dist/middleware/sveltekit.d.ts +100 -98
  20. package/dist/middleware/sveltekit.js +1 -43
  21. package/dist/object-tree.d.ts +67 -70
  22. package/dist/object-tree.js +2 -89
  23. package/dist/packem_shared/AbstractJsonReporter-BawNFYxI.js +1 -0
  24. package/dist/packem_shared/AbstractJsonReporter-Dt5-5x2R.js +1 -0
  25. package/dist/packem_shared/JsonReporter-15ln04rX.js +2 -0
  26. package/dist/packem_shared/JsonReporter-CerNvhg-.js +1 -0
  27. package/dist/packem_shared/PrettyReporter-Br5njEEy.js +5 -0
  28. package/dist/packem_shared/PrettyReporter-CgXnwIip.js +44 -0
  29. package/dist/packem_shared/abstract-json-reporter.d-Bz3lZEDi.d.ts +61 -0
  30. package/dist/packem_shared/abstract-pretty-reporter-BiHgKxG_.js +33 -0
  31. package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
  32. package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
  33. package/dist/packem_shared/create-middleware-logger.d-DeNLii5l.d.ts +47 -0
  34. package/dist/packem_shared/createPailError-53jAfQ-T.js +5 -0
  35. package/dist/packem_shared/headers-S8WyX-2m.js +1 -0
  36. package/dist/packem_shared/index-Bzp4LnJ5.js +1 -0
  37. package/dist/packem_shared/pailMiddleware-CWOJRmJq.js +1 -0
  38. package/dist/packem_shared/storage-DHM1EP2P.js +1 -0
  39. package/dist/packem_shared/types.d-ByY2ZuYG.d.ts +246 -0
  40. package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
  41. package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
  42. package/dist/packem_shared/useLogger-qyZrjy4D.js +1 -0
  43. package/dist/packem_shared/wide-event.d-Ke44zirU.d.ts +704 -0
  44. package/dist/packem_shared/write-console-log-based-on-level-DfD64owL.js +1 -0
  45. package/dist/packem_shared/write-stream-Dd4_PTcm.js +1 -0
  46. package/dist/processor/caller/caller-processor.d.ts +49 -47
  47. package/dist/processor/caller/caller-processor.js +1 -59
  48. package/dist/processor/environment-processor.d.ts +113 -113
  49. package/dist/processor/environment-processor.js +1 -89
  50. package/dist/processor/message-formatter-processor.d.ts +51 -49
  51. package/dist/processor/message-formatter-processor.js +1 -715
  52. package/dist/processor/opentelemetry-processor.d.ts +69 -66
  53. package/dist/processor/opentelemetry-processor.js +1 -52
  54. package/dist/processor/redact-processor.d.ts +60 -41
  55. package/dist/processor/redact-processor.js +1 -31
  56. package/dist/processor/sampling-processor.d.ts +102 -101
  57. package/dist/processor/sampling-processor.js +1 -59
  58. package/dist/reporter/file/json-file-reporter.d.ts +91 -42
  59. package/dist/reporter/file/json-file-reporter.js +2 -136
  60. package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
  61. package/dist/reporter/http/abstract-http-reporter.js +2 -432
  62. package/dist/reporter/http/http-reporter.d.ts +40 -36
  63. package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
  64. package/dist/reporter/http/http-reporter.edge-light.js +2 -728
  65. package/dist/reporter/http/http-reporter.js +1 -13
  66. package/dist/reporter/json/index.browser.d.ts +99 -3
  67. package/dist/reporter/json/index.browser.js +1 -2
  68. package/dist/reporter/json/index.d.ts +51 -3
  69. package/dist/reporter/json/index.js +1 -2
  70. package/dist/reporter/pretty/index.browser.d.ts +106 -2
  71. package/dist/reporter/pretty/index.browser.js +1 -1
  72. package/dist/reporter/pretty/index.d.ts +186 -2
  73. package/dist/reporter/pretty/index.js +1 -1
  74. package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
  75. package/dist/reporter/simple/simple-reporter.server.js +8 -182
  76. package/dist/wide-event.d.ts +5 -300
  77. package/dist/wide-event.js +1 -284
  78. package/package.json +29 -30
  79. package/dist/constants.d.ts +0 -37
  80. package/dist/middleware/next/middleware.d.ts +0 -59
  81. package/dist/middleware/next/storage.d.ts +0 -14
  82. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  83. package/dist/middleware/shared/headers.d.ts +0 -14
  84. package/dist/middleware/shared/routes.d.ts +0 -30
  85. package/dist/middleware/shared/storage.d.ts +0 -29
  86. package/dist/packem_shared/AbstractJsonReporter-BO8Calb4.js +0 -284
  87. package/dist/packem_shared/AbstractJsonReporter-nOj0Ft1F.js +0 -284
  88. package/dist/packem_shared/JsonReporter-CCmj7oYL.js +0 -28
  89. package/dist/packem_shared/JsonReporter-Ck2PIAEw.js +0 -58
  90. package/dist/packem_shared/PrettyReporter-BCvyNzXO.js +0 -2720
  91. package/dist/packem_shared/PrettyReporter-BtTr13Ha.js +0 -213
  92. package/dist/packem_shared/abstract-pretty-reporter-CXAKYCb8.js +0 -2635
  93. package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
  94. package/dist/packem_shared/constants-omsTHUWB.js +0 -119
  95. package/dist/packem_shared/createPailError-B_sgL0nF.js +0 -76
  96. package/dist/packem_shared/headers-BxHWM6KI.js +0 -127
  97. package/dist/packem_shared/index-Bx3-C0j9.js +0 -658
  98. package/dist/packem_shared/pailMiddleware-Ci88geIF.js +0 -24
  99. package/dist/packem_shared/storage-D0vqz8OX.js +0 -36
  100. package/dist/packem_shared/useLogger-D0rU3lcX.js +0 -33
  101. package/dist/packem_shared/write-console-log-based-on-level-ree2lDPw.js +0 -15
  102. package/dist/packem_shared/write-stream-MDqyXmc_.js +0 -6
  103. package/dist/pail.browser.d.ts +0 -412
  104. package/dist/pail.server.d.ts +0 -158
  105. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  106. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  107. package/dist/reporter/http/utils/compression.d.ts +0 -7
  108. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  109. package/dist/reporter/http/utils/retry.d.ts +0 -27
  110. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  111. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  112. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  113. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  114. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  115. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  116. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  117. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  118. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  119. package/dist/reporter/utils/format-label.d.ts +0 -3
  120. package/dist/types.d.ts +0 -241
  121. package/dist/utils/arrayify.d.ts +0 -2
  122. package/dist/utils/get-longest-badge.d.ts +0 -4
  123. package/dist/utils/get-longest-label.d.ts +0 -4
  124. package/dist/utils/merge-types.d.ts +0 -4
  125. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  126. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  127. package/dist/utils/write-stream.d.ts +0 -2
@@ -1,48 +0,0 @@
1
- import type { Options as RfsOptions } from "rotating-file-stream";
2
- /**
3
- * Rotating File Stream.
4
- *
5
- * A wrapper for the `rotating-file-stream` module that provides optional immediate
6
- * writing to disk by creating and closing a new stream on each write operation.
7
- * This is useful for ensuring log messages are written immediately rather than buffered.
8
- * @example
9
- * ```typescript
10
- * // Buffered writing (default)
11
- * const bufferedStream = new RotatingFileStream("/var/log/app.log", false, {
12
- * interval: "1d",
13
- * size: "10M"
14
- * });
15
- *
16
- * // Immediate writing
17
- * const immediateStream = new RotatingFileStream("/var/log/app.log", true, {
18
- * interval: "1d"
19
- * });
20
- * ```
21
- */
22
- declare class RotatingFileStream {
23
- #private;
24
- /**
25
- * Creates a new RotatingFileStream instance.
26
- * @param filePath Path to the log file
27
- * @param writeImmediately Whether to write immediately or buffer writes
28
- * @param options Options for the rotating file stream
29
- * @throws {Error} If the 'rotating-file-stream' package is not installed
30
- */
31
- constructor(filePath: string, writeImmediately?: boolean, options?: RfsOptions);
32
- /**
33
- * Writes a message to the rotating file stream.
34
- *
35
- * If writeImmediately was set to true in the constructor, a new stream
36
- * is created for each write operation. Otherwise, uses the buffered stream.
37
- * @param message The message to write to the file
38
- */
39
- write(message: string): void;
40
- /**
41
- * Ends the rotating file stream.
42
- *
43
- * Closes the underlying stream. When `writeImmediately` is not `true`,
44
- * calling `write` after calling this method will throw an error.
45
- */
46
- end(): void;
47
- }
48
- export default RotatingFileStream;
@@ -1,7 +0,0 @@
1
- /**
2
- * Compresses data using gzip compression.
3
- * @param data The data to compress as a string
4
- * @returns A Promise that resolves to the compressed data as Uint8Array
5
- */
6
- declare const compressData: (data: string) => Promise<Uint8Array>;
7
- export default compressData;
@@ -1,30 +0,0 @@
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;
@@ -1,27 +0,0 @@
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;
@@ -1,61 +0,0 @@
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_: typeof stringify): 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,40 +0,0 @@
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;
@@ -1,50 +0,0 @@
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;
@@ -1,83 +0,0 @@
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,36 +0,0 @@
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;
@@ -1,70 +0,0 @@
1
- import type { RenderErrorOptions } from "@visulima/error/error";
2
- import type { Options as InspectorOptions } from "@visulima/inspector";
3
- import type { InteractiveManager } from "@visulima/interactive-manager";
4
- import type { LiteralUnion } from "type-fest";
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
- }
@@ -1,5 +0,0 @@
1
- import type { ReadonlyMeta, Reporter } from "../../types.d.ts";
2
- declare class RawReporter<L extends string = string> implements Reporter<L> {
3
- log(meta: ReadonlyMeta<L>): void;
4
- }
5
- export default RawReporter;
@@ -1,13 +0,0 @@
1
- import type { Options as InspectorOptions } from "@visulima/inspector";
2
- import type { InteractiveManager } from "@visulima/interactive-manager";
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,3 +0,0 @@
1
- import type { Options } from "@visulima/inspector";
2
- declare const defaultInspectorConfig: Partial<Options>;
3
- export default defaultInspectorConfig;
@@ -1,3 +0,0 @@
1
- import type { PrettyStyleOptions } from "../pretty/abstract-pretty-reporter.d.ts";
2
- declare const formatLabel: (label: string, styles: PrettyStyleOptions) => string;
3
- export default formatLabel;