@visulima/pail 3.2.0 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE.md +3 -0
  3. package/dist/constants.d.ts +37 -0
  4. package/dist/index.browser.d.ts +47 -12
  5. package/dist/index.browser.js +1 -1
  6. package/dist/index.server.d.ts +65 -43
  7. package/dist/index.server.js +1 -3
  8. package/dist/interactive/index.d.ts +2 -28
  9. package/dist/interactive/interactive-manager.d.ts +108 -0
  10. package/dist/interactive/interactive-stream-hook.d.ts +68 -0
  11. package/dist/object-tree.d.ts +65 -7
  12. package/dist/packem_shared/{JsonReporter-BqWsVkHP.js → JsonReporter-C0AXk99i.js} +0 -2
  13. package/dist/packem_shared/{pail.browser-CPDOE_d1.js → pail.browser-CPjQrsyy.js} +3 -3
  14. package/dist/pail.browser.d.ts +412 -0
  15. package/dist/pail.server.d.ts +233 -0
  16. package/dist/processor/caller/caller-processor.d.ts +40 -7
  17. package/dist/processor/caller/get-caller-filename.d.ts +23 -0
  18. package/dist/processor/message-formatter-processor.d.ts +44 -9
  19. package/dist/processor/message-formatter-processor.js +1 -1
  20. package/dist/processor/opentelemetry-processor.d.ts +61 -10
  21. package/dist/processor/redact-processor.d.ts +39 -8
  22. package/dist/progress-bar.d.ts +75 -15
  23. package/dist/reporter/file/json-file-reporter.d.ts +39 -20
  24. package/dist/reporter/file/utils/rotating-file-stream.d.ts +48 -0
  25. package/dist/reporter/http/abstract-http-reporter.d.ts +125 -12
  26. package/dist/reporter/http/http-reporter.d.ts +36 -10
  27. package/dist/reporter/http/http-reporter.edge-light.d.ts +37 -165
  28. package/dist/reporter/http/utils/compression.d.ts +7 -0
  29. package/dist/reporter/http/utils/log-size-error.d.ts +30 -0
  30. package/dist/reporter/http/utils/retry.d.ts +27 -0
  31. package/dist/reporter/json/abstract-json-reporter.d.ts +61 -0
  32. package/dist/reporter/json/index.browser.d.ts +3 -13
  33. package/dist/reporter/json/index.d.ts +3 -16
  34. package/dist/reporter/json/index.js +1 -1
  35. package/dist/reporter/json/json-reporter.browser.d.ts +40 -0
  36. package/dist/reporter/json/json-reporter.server.d.ts +50 -0
  37. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +83 -0
  38. package/dist/reporter/pretty/index.browser.d.ts +2 -13
  39. package/dist/reporter/pretty/index.d.ts +2 -25
  40. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +36 -0
  41. package/dist/reporter/pretty/pretty-reporter.server.d.ts +70 -0
  42. package/dist/reporter/raw/raw-reporter.browser.d.ts +5 -0
  43. package/dist/reporter/raw/raw-reporter.server.d.ts +13 -0
  44. package/dist/reporter/simple/simple-reporter.server.d.ts +10 -14
  45. package/dist/reporter/utils/default-inspector-config.d.ts +3 -0
  46. package/dist/reporter/utils/format-label.d.ts +3 -0
  47. package/dist/spinner.d.ts +170 -104
  48. package/dist/spinner.js +89 -89
  49. package/dist/types.d.ts +241 -0
  50. package/dist/utils/ansi-escapes.d.ts +4 -0
  51. package/dist/utils/arrayify.d.ts +2 -0
  52. package/dist/utils/get-longest-badge.d.ts +4 -0
  53. package/dist/utils/get-longest-label.d.ts +4 -0
  54. package/dist/utils/merge-types.d.ts +4 -0
  55. package/dist/utils/stream/safe-stream-handler.d.ts +21 -0
  56. package/dist/utils/write-console-log-based-on-level.d.ts +4 -0
  57. package/dist/utils/write-stream.d.ts +2 -0
  58. package/package.json +3 -4
  59. package/dist/packem_shared/abstract-json-reporter-DiyVyU0j.d.ts +0 -22
  60. package/dist/packem_shared/abstract-pretty-reporter-BbOWXMCs.d.ts +0 -28
  61. package/dist/packem_shared/index.d-BR1GjZri.d.ts +0 -53
  62. package/dist/packem_shared/index.d-oxZvg_y7.d.ts +0 -20
  63. package/dist/packem_shared/pail.browser-By9KjOH7.d.ts +0 -69
  64. package/dist/packem_shared/types-D3ycu8-x.d.ts +0 -95
@@ -1,21 +1,54 @@
1
- import { P as Processor, M as Meta } from '../../packem_shared/types-D3ycu8-x.js';
2
- import '@visulima/colorize';
3
- import 'type-fest';
4
- import '../../interactive/index.js';
5
-
1
+ import type { Meta, Processor } from "../../types.d.ts";
2
+ /**
3
+ * Global namespace extension for caller file metadata.
4
+ *
5
+ * Extends the VisulimaPail.CustomMeta interface to include file information
6
+ * that will be added by the CallerProcessor.
7
+ */
6
8
  declare global {
7
9
  namespace VisulimaPail {
8
10
  interface CustomMeta<L> {
11
+ /** File information where the log was called from */
9
12
  file: {
13
+ /** Column number in the source file */
10
14
  column: number | undefined;
15
+ /** Line number in the source file */
11
16
  line: number | undefined;
17
+ /** Name/path of the source file */
12
18
  name: string | undefined;
13
19
  } | undefined;
14
20
  }
15
21
  }
16
22
  }
23
+ /**
24
+ * Caller Processor.
25
+ *
26
+ * A processor that adds file location information to log metadata.
27
+ * Uses stack trace analysis to determine the file, line, and column
28
+ * where the log call originated from.
29
+ * @template L - The log level type
30
+ * @example
31
+ * ```typescript
32
+ * import { createPail } from "@visulima/pail";
33
+ * import CallerProcessor from "@visulima/pail/processor/caller";
34
+ *
35
+ * const logger = createPail({
36
+ * processors: [new CallerProcessor()]
37
+ * });
38
+ *
39
+ * logger.info("This log will include file location info");
40
+ * // Result includes: file: { name: "...", line: 123, column: 45 }
41
+ * ```
42
+ */
17
43
  declare class CallerProcessor<L extends string = string> implements Processor<L> {
44
+ /**
45
+ * Processes log metadata to add caller file information.
46
+ *
47
+ * Analyzes the call stack to determine the file location where the log
48
+ * was called from and adds this information to the metadata.
49
+ * @param meta The log metadata to process
50
+ * @returns The processed metadata with file location information added
51
+ */
18
52
  process(meta: Meta<L>): Meta<L>;
19
53
  }
20
-
21
- export { CallerProcessor as default };
54
+ export default CallerProcessor;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Gets the file location information of the caller.
3
+ *
4
+ * Uses Node.js stack trace API to analyze the call stack and determine
5
+ * the file, line, and column where this function was called from.
6
+ * Filters out internal pail files and native code.
7
+ * @returns Object containing file location information
8
+ * @example
9
+ * ```typescript
10
+ * const location = getCallerFilename();
11
+ * console.log(location);
12
+ * // { fileName: "/path/to/file.js", lineNumber: 42, columnNumber: 10 }
13
+ * ```
14
+ */
15
+ declare const getCallerFilename: () => {
16
+ /** Column number where the call originated */
17
+ columnNumber?: number;
18
+ /** File name/path where the call originated */
19
+ fileName: string | undefined;
20
+ /** Line number where the call originated */
21
+ lineNumber?: number;
22
+ };
23
+ export default getCallerFilename;
@@ -1,17 +1,52 @@
1
- import { h as StringifyAwareProcessor, M as Meta } from '../packem_shared/types-D3ycu8-x.js';
2
- import '@visulima/colorize';
3
- import 'type-fest';
4
- import '../interactive/index.js';
5
-
6
- type FormatterFunction = (argument: any) => string;
7
-
1
+ import type { FormatterFunction } from "@visulima/fmt";
2
+ import type { Meta, StringifyAwareProcessor } from "../types.d.ts";
3
+ /**
4
+ * Message Formatter Processor.
5
+ *
6
+ * A processor that formats log messages using the {@link https://www.visulima.com/docs/package/fmt|@visulima/fmt} library.
7
+ * Supports custom formatters, string interpolation, and complex object formatting.
8
+ * Processes both the main message and contextual data.
9
+ * @template L - The log level type
10
+ * @example
11
+ * ```typescript
12
+ * import { createPail } from "@visulima/pail";
13
+ * import MessageFormatterProcessor from "@visulima/pail/processor/message-formatter";
14
+ *
15
+ * const logger = createPail({
16
+ * processors: [new MessageFormatterProcessor({
17
+ * formatters: {
18
+ * user: (value) => `[USER:${value.id}]`
19
+ * }
20
+ * })]
21
+ * });
22
+ *
23
+ * logger.info("User {user} logged in", { user: { id: 123 } });
24
+ * // Output: "User [USER:123] logged in"
25
+ * ```
26
+ */
8
27
  declare class MessageFormatterProcessor<L extends string = string> implements StringifyAwareProcessor<L> {
9
28
  #private;
29
+ /**
30
+ * Creates a new MessageFormatterProcessor instance.
31
+ * @param options Configuration options
32
+ * @param options.formatters Custom formatters for message interpolation
33
+ */
10
34
  constructor(options?: {
11
35
  formatters?: Record<string, FormatterFunction>;
12
36
  });
37
+ /**
38
+ * Sets the stringify function for object serialization.
39
+ * @param function_ The stringify function to use for serializing objects
40
+ */
13
41
  setStringify(function_: any): void;
42
+ /**
43
+ * Processes log metadata to format messages.
44
+ *
45
+ * Applies string interpolation and custom formatters to the message
46
+ * and contextual data in the log metadata.
47
+ * @param meta The log metadata to process
48
+ * @returns The processed metadata with formatted messages
49
+ */
14
50
  process(meta: Meta<L>): Meta<L>;
15
51
  }
16
-
17
- export { MessageFormatterProcessor as default };
52
+ export default MessageFormatterProcessor;
@@ -17,7 +17,7 @@ class MessageFormatterProcessor {
17
17
  * Sets the stringify function for object serialization.
18
18
  * @param function_ The stringify function to use for serializing objects
19
19
  */
20
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
20
+ // eslint-disable-next-line , @typescript-eslint/no-explicit-any
21
21
  setStringify(function_) {
22
22
  this.#stringify = function_;
23
23
  }
@@ -1,19 +1,70 @@
1
- import { P as Processor, M as Meta } from '../packem_shared/types-D3ycu8-x.js';
2
- import '@visulima/colorize';
3
- import 'type-fest';
4
- import '../interactive/index.js';
5
-
6
- interface OpenTelemetryProcessorOptions {
1
+ import type { Meta, Processor } from "../types.d.ts";
2
+ /**
3
+ * Configuration options for the OpenTelemetry processor.
4
+ */
5
+ export interface OpenTelemetryProcessorOptions {
6
+ /**
7
+ * Field name for the span ID. Defaults to 'span_id'
8
+ */
7
9
  spanIdFieldName?: string;
10
+ /**
11
+ * If specified, all trace fields will be nested under this key
12
+ */
8
13
  traceFieldName?: string;
14
+ /**
15
+ * Field name for the trace flags. Defaults to 'trace_flags'
16
+ */
9
17
  traceFlagsFieldName?: string;
18
+ /**
19
+ * Field name for the trace ID. Defaults to 'trace_id'
20
+ */
10
21
  traceIdFieldName?: string;
11
22
  }
12
- declare class OpenTelemetryProcessor<L extends string = string> implements Processor<L> {
23
+ /**
24
+ * OpenTelemetry Processor.
25
+ *
26
+ * A processor that adds OpenTelemetry trace context to log metadata.
27
+ * Extracts trace ID, span ID, and trace flags from the active OpenTelemetry span
28
+ * and adds them to the log context for distributed tracing correlation.
29
+ * @template L - The log level type
30
+ * @example
31
+ * ```typescript
32
+ * import { createPail } from "@visulima/pail";
33
+ * import { OpenTelemetryProcessor } from "@visulima/pail/processor/opentelemetry";
34
+ *
35
+ * const logger = createPail({
36
+ * processors: [new OpenTelemetryProcessor()]
37
+ * });
38
+ *
39
+ * logger.info("Processing request");
40
+ * // Context includes: { trace_id: "...", span_id: "...", trace_flags: "01" }
41
+ * ```
42
+ * @example
43
+ * ```typescript
44
+ * // With custom field names
45
+ * const logger = createPail({
46
+ * processors: [new OpenTelemetryProcessor({
47
+ * traceFieldName: "trace",
48
+ * traceIdFieldName: "traceId",
49
+ * spanIdFieldName: "spanId"
50
+ * })]
51
+ * });
52
+ * ```
53
+ */
54
+ export declare class OpenTelemetryProcessor<L extends string = string> implements Processor<L> {
13
55
  #private;
56
+ /**
57
+ * Creates a new OpenTelemetryProcessor instance.
58
+ * @param options Configuration options for field names and nesting
59
+ */
14
60
  constructor(options?: OpenTelemetryProcessorOptions);
61
+ /**
62
+ * Processes log metadata to add OpenTelemetry trace context.
63
+ *
64
+ * Extracts trace information from the active OpenTelemetry span and adds it
65
+ * to the log context. If no valid span is found, the metadata is returned unchanged.
66
+ * @param meta The log metadata to process
67
+ * @returns The processed metadata with trace context added
68
+ */
15
69
  process(meta: Meta<L>): Meta<L>;
16
70
  }
17
-
18
- export { OpenTelemetryProcessor };
19
- export type { OpenTelemetryProcessorOptions };
@@ -1,13 +1,44 @@
1
- import { Rules, RedactOptions } from '@visulima/redact';
2
- import { P as Processor, M as Meta } from '../packem_shared/types-D3ycu8-x.js';
3
- import '@visulima/colorize';
4
- import 'type-fest';
5
- import '../interactive/index.js';
6
-
1
+ import type { RedactOptions, Rules } from "@visulima/redact";
2
+ import type { Meta, Processor } from "../types.d.ts";
3
+ /**
4
+ * Redact Processor.
5
+ *
6
+ * A processor that redacts sensitive information from log messages and metadata.
7
+ * Uses the {@link https://www.visulima.com/docs/package/redact|@visulima/redact} library to identify and mask sensitive data like
8
+ * passwords, API keys, credit card numbers, and other PII.
9
+ * @template L - The log level type
10
+ * @example
11
+ * ```typescript
12
+ * import { createPail } from "@visulima/pail";
13
+ * import RedactProcessor from "@visulima/pail/processor/redact";
14
+ *
15
+ * const logger = createPail({
16
+ * processors: [new RedactProcessor()]
17
+ * });
18
+ *
19
+ * logger.info("User login", {
20
+ * username: "john",
21
+ * password: "secret123", // Will be redacted
22
+ * apiKey: "sk-123456" // Will be redacted
23
+ * });
24
+ * ```
25
+ */
7
26
  declare class RedactProcessor<L extends string = string> implements Processor<L> {
8
27
  #private;
28
+ /**
29
+ * Creates a new RedactProcessor instance.
30
+ * @param rules Custom redaction rules (uses standardRules if not provided)
31
+ * @param options Additional redaction options
32
+ */
9
33
  constructor(rules?: Rules, options?: RedactOptions);
34
+ /**
35
+ * Processes log metadata to redact sensitive information.
36
+ *
37
+ * Applies redaction rules to the message, context, and error properties
38
+ * in the log metadata to prevent sensitive data from being logged.
39
+ * @param meta The log metadata to process
40
+ * @returns The processed metadata with sensitive data redacted
41
+ */
10
42
  process(meta: Meta<L>): Meta<L>;
11
43
  }
12
-
13
- export { RedactProcessor as default };
44
+ export default RedactProcessor;
@@ -1,7 +1,6 @@
1
- import { InteractiveManager } from './interactive/index.js';
2
-
3
- type ProgressBarStyle = "shades_classic" | "shades_grey" | "rect" | "filled" | "solid" | "ascii" | "custom";
4
- interface ProgressBarOptions {
1
+ import type InteractiveManager from "./interactive/interactive-manager.d.ts";
2
+ export type ProgressBarStyle = "shades_classic" | "shades_grey" | "rect" | "filled" | "solid" | "ascii" | "custom";
3
+ export interface ProgressBarOptions {
5
4
  barCompleteChar?: string | string[];
6
5
  barGlue?: string;
7
6
  barIncompleteChar?: string | string[];
@@ -12,10 +11,10 @@ interface ProgressBarOptions {
12
11
  total: number;
13
12
  width?: number;
14
13
  }
15
- interface SingleBarOptions extends ProgressBarOptions {
14
+ export interface SingleBarOptions extends ProgressBarOptions {
16
15
  format?: string;
17
16
  }
18
- interface MultiBarOptions {
17
+ export interface MultiBarOptions {
19
18
  barCompleteChar?: string | string[];
20
19
  barGlue?: string;
21
20
  barIncompleteChar?: string | string[];
@@ -24,27 +23,63 @@ interface MultiBarOptions {
24
23
  fps?: number;
25
24
  style?: ProgressBarStyle;
26
25
  }
27
- interface ProgressBarPayload {
26
+ export interface ProgressBarPayload {
28
27
  [key: string]: string | number | boolean;
29
28
  }
30
- declare const getBarChar: (char: string | undefined, style: ProgressBarStyle, complete?: boolean) => string;
31
- declare const applyStyleToOptions: <T extends ProgressBarOptions | MultiBarOptions>(options: T) => T;
32
- declare class ProgressBar {
29
+ /**
30
+ * Gets the appropriate bar character based on style and completion state.
31
+ * @param char Custom character override
32
+ * @param style Progress bar style to use
33
+ * @param complete Whether to get completed or incomplete character
34
+ * @returns The appropriate character for the given style
35
+ */
36
+ export declare const getBarChar: (char: string | undefined, style: ProgressBarStyle, complete?: boolean) => string;
37
+ export declare const applyStyleToOptions: <T extends ProgressBarOptions | MultiBarOptions>(options: T) => T;
38
+ export declare class ProgressBar {
33
39
  protected options: ProgressBarOptions;
34
40
  protected current: number;
35
41
  private startTime;
36
42
  private interactiveManager?;
37
43
  private isActive;
38
44
  private payload?;
45
+ /**
46
+ * Creates a new progress bar instance.
47
+ * @param options Configuration options for the progress bar
48
+ * @param interactiveManager Optional interactive manager for rendering
49
+ * @param payload Optional initial payload data for format placeholders
50
+ */
39
51
  constructor(options: ProgressBarOptions, interactiveManager?: InteractiveManager, payload?: ProgressBarPayload);
52
+ /**
53
+ * Updates the progress bar to a new value.
54
+ * @param current The current progress value
55
+ * @param payload Optional payload data to merge with existing data
56
+ */
40
57
  update(current: number, payload?: ProgressBarPayload): void;
58
+ /**
59
+ * Increments the progress bar by a specified step.
60
+ * @param step Amount to increment (default: 1)
61
+ * @param payload Optional payload data to merge with existing data
62
+ */
41
63
  increment(step?: number, payload?: ProgressBarPayload): void;
64
+ /**
65
+ * Renders the progress bar as a formatted string.
66
+ * @returns Formatted progress bar string with all placeholders replaced
67
+ */
42
68
  render(): string;
69
+ /**
70
+ * Starts the progress bar.
71
+ * @param total Optional total value to set
72
+ * @param startValue Optional starting value
73
+ * @param payload Optional initial payload data
74
+ */
43
75
  start(total?: number, startValue?: number, payload?: ProgressBarPayload): void;
76
+ /**
77
+ * Stops the progress bar and cleanup.
78
+ */
44
79
  stop(): void;
45
80
  private calculateETA;
46
81
  }
47
- declare class MultiBarInstance extends ProgressBar {
82
+ export declare class MultiBarInstance extends ProgressBar {
48
83
  private multiBar;
49
84
  constructor(multiBar: MultiProgressBar, options: ProgressBarOptions, payload?: ProgressBarPayload);
50
85
  update(current: number, payload?: ProgressBarPayload): void;
@@ -54,7 +89,7 @@ declare class MultiBarInstance extends ProgressBar {
54
89
  total: number;
55
90
  };
56
91
  }
57
- declare class MultiProgressBar {
92
+ export declare class MultiProgressBar {
58
93
  private bars;
59
94
  private options;
60
95
  private interactiveManager?;
@@ -62,15 +97,40 @@ declare class MultiProgressBar {
62
97
  private nextBarId;
63
98
  private composite;
64
99
  private barColors;
100
+ /**
101
+ * Creates a new multi progress bar manager.
102
+ * @param options Configuration options for the progress bars
103
+ * @param interactiveManager Optional interactive manager for rendering
104
+ */
65
105
  constructor(options?: MultiBarOptions, interactiveManager?: InteractiveManager);
106
+ /**
107
+ * Creates a new progress bar within this multi-bar manager.
108
+ * @param total Total value for the progress bar
109
+ * @param current Starting current value (default: 0)
110
+ * @param payload Optional initial payload data for format placeholders
111
+ * @returns The created progress bar instance
112
+ */
66
113
  create(total: number, current?: number, payload?: ProgressBarPayload): ProgressBar;
114
+ /**
115
+ * Removes a progress bar from the manager.
116
+ * @param bar The progress bar instance to remove
117
+ * @returns True if the bar was removed, false if not found
118
+ */
67
119
  remove(bar: ProgressBar): boolean;
120
+ /**
121
+ * Renders all progress bars.
122
+ */
68
123
  renderAll(): void;
124
+ /**
125
+ * Sets or removes a color function for a specific bar.
126
+ * @param bar The progress bar instance to color (must be from this MultiProgressBar)
127
+ * @param color Color function or undefined to remove color
128
+ */
69
129
  setBarColor(bar: MultiBarInstance, color: ((text: string) => string) | undefined): void;
130
+ /**
131
+ * Stops all progress bars and cleanup.
132
+ */
70
133
  stop(): void;
71
134
  private renderComposite;
72
135
  private getCompositeChar;
73
136
  }
74
-
75
- export { MultiBarInstance, MultiProgressBar, ProgressBar, applyStyleToOptions, getBarChar };
76
- export type { MultiBarOptions, ProgressBarOptions, ProgressBarPayload, ProgressBarStyle, SingleBarOptions };
@@ -1,27 +1,46 @@
1
- import { Options } from 'rotating-file-stream';
2
- import { a as AbstractJsonReporterOptions, A as AbstractJsonReporter } from '../../packem_shared/abstract-json-reporter-DiyVyU0j.js';
3
- import '../../packem_shared/index.d-oxZvg_y7.js';
4
- import 'type-fest';
5
- import '../../packem_shared/types-D3ycu8-x.js';
6
- import '@visulima/colorize';
7
- import '../../interactive/index.js';
8
-
9
- declare class RotatingFileStream {
10
- #private;
11
- constructor(filePath: string, writeImmediately?: boolean, options?: Options);
12
- write(message: string): void;
13
- end(): void;
14
- }
15
-
16
- type FileReporterOptions = AbstractJsonReporterOptions & Options & {
1
+ import type { Options as RfsOptions } from "rotating-file-stream";
2
+ import type { AbstractJsonReporterOptions } from "../json/abstract-json-reporter.d.ts";
3
+ import { AbstractJsonReporter } from "../json/abstract-json-reporter.d.ts";
4
+ import RotatingFileStream from "./utils/rotating-file-stream.d.ts";
5
+ /**
6
+ * Options for configuring the JsonFileReporter.
7
+ */
8
+ export type FileReporterOptions = AbstractJsonReporterOptions & RfsOptions & {
9
+ /** Path to the log file */
17
10
  filePath: string;
11
+ /** Whether to write immediately to disk instead of buffering */
18
12
  writeImmediately?: boolean;
19
13
  };
20
- declare class JsonFileReporter<L extends string = string> extends AbstractJsonReporter<L> {
14
+ /**
15
+ * JSON File Reporter.
16
+ *
17
+ * A reporter that writes structured JSON log entries to rotating files on disk.
18
+ * Supports automatic file rotation based on size, time intervals, and compression.
19
+ * @template L - The log level type
20
+ * @example
21
+ * ```typescript
22
+ * const reporter = new JsonFileReporter({
23
+ * filePath: "/var/log/app.log",
24
+ * interval: "1d", // Rotate daily
25
+ * size: "10M", // Rotate when file reaches 10MB
26
+ * compress: "gzip"
27
+ * });
28
+ *
29
+ * logger.registerReporters([reporter]);
30
+ * ```
31
+ */
32
+ export declare class JsonFileReporter<L extends string = string> extends AbstractJsonReporter<L> {
33
+ /** The rotating file stream instance */
21
34
  protected stream: RotatingFileStream;
35
+ /**
36
+ * Creates a new JsonFileReporter instance.
37
+ * @param options Configuration options for file rotation and JSON formatting
38
+ */
22
39
  constructor(options: FileReporterOptions);
40
+ /**
41
+ * Writes a JSON message to the rotating file stream.
42
+ * @param message The JSON-formatted log message to write
43
+ * @protected
44
+ */
23
45
  protected _log(message: string): void;
24
46
  }
25
-
26
- export { JsonFileReporter };
27
- export type { FileReporterOptions };
@@ -0,0 +1,48 @@
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;