@visulima/pail 4.0.0-alpha.10 → 4.0.0-alpha.12
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 +57 -0
- package/LICENSE.md +143 -931
- package/dist/error.d.ts +95 -96
- package/dist/index.browser.d.ts +557 -47
- package/dist/index.browser.js +2 -2
- package/dist/index.server.d.ts +722 -65
- package/dist/index.server.js +27 -410
- package/dist/middleware/elysia.d.ts +65 -63
- package/dist/middleware/elysia.js +2 -2
- package/dist/middleware/express.d.ts +73 -71
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +69 -67
- package/dist/middleware/fastify.js +2 -2
- package/dist/middleware/hono.d.ts +74 -72
- package/dist/middleware/next/handler.d.ts +101 -34
- package/dist/middleware/sveltekit.d.ts +100 -98
- package/dist/object-tree.d.ts +67 -70
- package/dist/packem_shared/{AbstractJsonReporter-DlugSJpY.js → AbstractJsonReporter-BO8Calb4.js} +1 -5
- package/dist/packem_shared/{AbstractJsonReporter-CjtVgHbU.js → AbstractJsonReporter-nOj0Ft1F.js} +1 -5
- package/dist/packem_shared/{JsonReporter-Dbw82ewj.js → JsonReporter-CCmj7oYL.js} +1 -1
- package/dist/packem_shared/{JsonReporter-BgPvIyC2.js → JsonReporter-Ck2PIAEw.js} +2 -2
- package/dist/packem_shared/{PrettyReporter-C2dCzIaf.js → PrettyReporter-CIbrmjUV.js} +2 -4
- package/dist/packem_shared/{PrettyReporter-gMqa7j_m.js → PrettyReporter-CNJEO9g7.js} +1250 -15
- package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
- package/dist/packem_shared/{abstract-pretty-reporter-szQO-IgK.js → abstract-pretty-reporter-CkqCt5hg.js} +2300 -2298
- package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
- package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
- package/dist/packem_shared/types.d-BeLumqgD.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/wide-event.d-B-t8ZnhI.d.ts +704 -0
- package/dist/packem_shared/{write-stream-BuFtjATz.js → write-stream-MDqyXmc_.js} +1 -1
- package/dist/processor/caller/caller-processor.d.ts +49 -47
- package/dist/processor/caller/caller-processor.js +1 -1
- package/dist/processor/environment-processor.d.ts +113 -113
- package/dist/processor/message-formatter-processor.d.ts +51 -49
- package/dist/processor/message-formatter-processor.js +2 -2
- package/dist/processor/opentelemetry-processor.d.ts +69 -66
- package/dist/processor/redact-processor.d.ts +60 -41
- package/dist/processor/sampling-processor.d.ts +102 -101
- package/dist/reporter/file/json-file-reporter.d.ts +91 -42
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
- package/dist/reporter/http/abstract-http-reporter.js +1 -1
- 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 +1 -5
- package/dist/reporter/json/index.browser.d.ts +99 -3
- package/dist/reporter/json/index.browser.js +2 -2
- package/dist/reporter/json/index.d.ts +51 -3
- package/dist/reporter/json/index.js +2 -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 +219 -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 +3 -2
- package/dist/wide-event.d.ts +5 -300
- package/dist/wide-event.js +3 -2
- package/package.json +9 -21
- package/dist/constants.d.ts +0 -37
- package/dist/interactive/index.d.ts +0 -2
- package/dist/interactive/index.js +0 -2
- package/dist/interactive/interactive-manager.d.ts +0 -108
- package/dist/interactive/interactive-stream-hook.d.ts +0 -68
- package/dist/middleware/next/middleware.d.ts +0 -59
- package/dist/middleware/next/storage.d.ts +0 -14
- package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
- package/dist/middleware/shared/headers.d.ts +0 -14
- package/dist/middleware/shared/routes.d.ts +0 -30
- package/dist/middleware/shared/storage.d.ts +0 -29
- package/dist/packem_shared/InteractiveManager-CowYA3Hx.js +0 -178
- package/dist/packem_shared/InteractiveStreamHook-BypRlYTX.js +0 -133
- package/dist/packem_shared/Spinner-Cokext9b.js +0 -2183
- package/dist/packem_shared/getBarChar-D7JfmdTr.js +0 -459
- package/dist/packem_shared/index-BEfVUy9P.js +0 -1256
- package/dist/pail.browser.d.ts +0 -412
- package/dist/pail.server.d.ts +0 -233
- package/dist/processor/caller/get-caller-filename.d.ts +0 -23
- package/dist/progress-bar.d.ts +0 -145
- package/dist/progress-bar.js +0 -459
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
- package/dist/reporter/http/utils/compression.d.ts +0 -7
- package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
- package/dist/reporter/http/utils/retry.d.ts +0 -27
- package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
- package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
- package/dist/reporter/json/json-reporter.server.d.ts +0 -50
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
- package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
- package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
- package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
- package/dist/reporter/utils/format-label.d.ts +0 -3
- package/dist/spinner.d.ts +0 -220
- package/dist/spinner.js +0 -2183
- package/dist/types.d.ts +0 -241
- package/dist/utils/ansi-escapes.d.ts +0 -4
- package/dist/utils/arrayify.d.ts +0 -2
- package/dist/utils/get-longest-badge.d.ts +0 -4
- package/dist/utils/get-longest-label.d.ts +0 -4
- package/dist/utils/merge-types.d.ts +0 -4
- package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
- package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
- package/dist/utils/write-stream.d.ts +0 -2
|
@@ -1,44 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { M as Meta, P as Processor } from "../packem_shared/types.d-BeLumqgD.js";
|
|
2
|
+
import '@visulima/colorize';
|
|
3
|
+
import '@visulima/interactive-manager';
|
|
4
|
+
type StringAnonymize = {
|
|
5
|
+
key: string;
|
|
6
|
+
pattern: RegExp | string;
|
|
7
|
+
replacement?: string;
|
|
8
|
+
};
|
|
9
|
+
type Anonymize = {
|
|
10
|
+
deep?: boolean;
|
|
11
|
+
key: string;
|
|
12
|
+
pattern?: RegExp | string;
|
|
13
|
+
replacement?: unknown;
|
|
14
|
+
};
|
|
15
|
+
type Rules = (Anonymize | StringAnonymize | number | string)[];
|
|
16
|
+
type RedactOptions = {
|
|
17
|
+
exclude?: (number | string)[];
|
|
18
|
+
logger?: {
|
|
19
|
+
debug: (message?: unknown, ...optionalParameters: unknown[]) => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
3
22
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
* Redact Processor.
|
|
24
|
+
*
|
|
25
|
+
* A processor that redacts sensitive information from log messages and metadata.
|
|
26
|
+
* Uses the {@link https://visulima.com/packages/redact/|@visulima/redact} library to identify and mask sensitive data like
|
|
27
|
+
* passwords, API keys, credit card numbers, and other PII.
|
|
28
|
+
* @template L - The log level type
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createPail } from "@visulima/pail";
|
|
32
|
+
* import RedactProcessor from "@visulima/pail/processor/redact";
|
|
33
|
+
*
|
|
34
|
+
* const logger = createPail({
|
|
35
|
+
* processors: [new RedactProcessor()]
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* logger.info("User login", {
|
|
39
|
+
* username: "john",
|
|
40
|
+
* password: "secret123", // Will be redacted
|
|
41
|
+
* apiKey: "sk-123456" // Will be redacted
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
26
45
|
declare class RedactProcessor<L extends string = string> implements Processor<L> {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
#private;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new RedactProcessor instance.
|
|
49
|
+
* @param rules Custom redaction rules (uses standardRules if not provided)
|
|
50
|
+
* @param options Additional redaction options
|
|
51
|
+
*/
|
|
52
|
+
constructor(rules?: Rules, options?: RedactOptions);
|
|
53
|
+
/**
|
|
54
|
+
* Processes log metadata to redact sensitive information.
|
|
55
|
+
*
|
|
56
|
+
* Applies redaction rules to the message, context, and error properties
|
|
57
|
+
* in the log metadata to prevent sensitive data from being logged.
|
|
58
|
+
* @param meta The log metadata to process
|
|
59
|
+
* @returns The processed metadata with sensitive data redacted
|
|
60
|
+
*/
|
|
61
|
+
process(meta: Meta<L>): Meta<L>;
|
|
43
62
|
}
|
|
44
|
-
export default
|
|
63
|
+
export { RedactProcessor as default };
|
|
@@ -1,111 +1,112 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { M as Meta, P as Processor } from "../packem_shared/types.d-BeLumqgD.js";
|
|
2
|
+
import '@visulima/colorize';
|
|
3
|
+
import '@visulima/interactive-manager';
|
|
2
4
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
* Head sampling configuration.
|
|
6
|
+
*
|
|
7
|
+
* Controls random sampling rates per log level. Each key is a log level name
|
|
8
|
+
* and the value is the percentage (0-100) of logs at that level to keep.
|
|
9
|
+
* Levels not listed default to 100 (keep all).
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const headSampling: HeadSamplingConfig = {
|
|
13
|
+
* debug: 0, // Drop all debug logs
|
|
14
|
+
* informational: 10, // Keep 10% of info logs
|
|
15
|
+
* warning: 50, // Keep 50% of warning logs
|
|
16
|
+
* error: 100, // Keep all error logs
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
18
20
|
type HeadSamplingConfig = Partial<Record<string, number>>;
|
|
19
21
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
* Tail sampling condition function.
|
|
23
|
+
*
|
|
24
|
+
* A function that receives the log metadata and returns true if the log
|
|
25
|
+
* should be force-kept regardless of head sampling. This allows keeping
|
|
26
|
+
* important logs based on their content (e.g., errors, slow operations).
|
|
27
|
+
* @template L - The log level type
|
|
28
|
+
*/
|
|
27
29
|
type TailSamplingCondition<L extends string = string> = (meta: Readonly<Meta<L>>) => boolean;
|
|
28
30
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
* Sampling processor configuration options.
|
|
32
|
+
*/
|
|
31
33
|
interface SamplingProcessorOptions<L extends string = string> {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Head sampling rates per log level.
|
|
36
|
+
*
|
|
37
|
+
* A map of log level to sampling percentage (0-100).
|
|
38
|
+
* Levels not specified default to 100 (keep all).
|
|
39
|
+
* Set to 0 to drop all logs at that level.
|
|
40
|
+
*/
|
|
41
|
+
head?: HeadSamplingConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Tail sampling conditions.
|
|
44
|
+
*
|
|
45
|
+
* An array of condition functions that can force-keep a log entry
|
|
46
|
+
* even if it was dropped by head sampling. If any condition returns true,
|
|
47
|
+
* the log is kept.
|
|
48
|
+
*/
|
|
49
|
+
tail?: TailSamplingCondition<L>[];
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
52
|
+
* Sampling Processor.
|
|
53
|
+
*
|
|
54
|
+
* Inspired by evlog's production sampling strategy, this processor implements
|
|
55
|
+
* both head sampling (random per-level) and tail sampling (force-keep based
|
|
56
|
+
* on conditions) to control log volume in production environments.
|
|
57
|
+
*
|
|
58
|
+
* **Head sampling** randomly drops a percentage of logs per level. This is
|
|
59
|
+
* evaluated first and provides broad volume control.
|
|
60
|
+
*
|
|
61
|
+
* **Tail sampling** can override head sampling to force-keep important logs
|
|
62
|
+
* based on their content. For example, you might drop 90% of info logs but
|
|
63
|
+
* force-keep any that contain error information or relate to slow operations.
|
|
64
|
+
*
|
|
65
|
+
* When a log is dropped by sampling, the processor sets a `__dropped: true`
|
|
66
|
+
* boolean flag on the meta object. Reporters should check for this flag and
|
|
67
|
+
* skip entries where `__dropped` is `true`.
|
|
68
|
+
* @template L - The log level type
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* import { createPail } from "@visulima/pail";
|
|
72
|
+
* import SamplingProcessor from "@visulima/pail/processor/sampling";
|
|
73
|
+
*
|
|
74
|
+
* const logger = createPail({
|
|
75
|
+
* processors: [
|
|
76
|
+
* new SamplingProcessor({
|
|
77
|
+
* head: {
|
|
78
|
+
* debug: 0, // Drop all debug logs
|
|
79
|
+
* informational: 10, // Keep 10% of info logs
|
|
80
|
+
* warning: 50, // Keep 50% of warnings
|
|
81
|
+
* error: 100, // Keep all errors
|
|
82
|
+
* },
|
|
83
|
+
* tail: [
|
|
84
|
+
* // Force-keep logs with errors regardless of head sampling
|
|
85
|
+
* (meta) => meta.error !== undefined,
|
|
86
|
+
* // Force-keep logs from critical scopes
|
|
87
|
+
* (meta) => meta.scope?.includes("payment") ?? false,
|
|
88
|
+
* ],
|
|
89
|
+
* }),
|
|
90
|
+
* ],
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
92
94
|
declare class SamplingProcessor<L extends string = string> implements Processor<L> {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
95
|
+
#private;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a new SamplingProcessor instance.
|
|
98
|
+
* @param options Sampling configuration options
|
|
99
|
+
*/
|
|
100
|
+
constructor(options?: SamplingProcessorOptions<L>);
|
|
101
|
+
/**
|
|
102
|
+
* Processes log metadata to apply sampling rules.
|
|
103
|
+
*
|
|
104
|
+
* First evaluates head sampling (random per-level), then checks tail
|
|
105
|
+
* sampling conditions. If a log is dropped, the meta is marked with
|
|
106
|
+
* `__dropped: true` so reporters can skip it.
|
|
107
|
+
* @param meta The log metadata to process
|
|
108
|
+
* @returns The processed metadata, potentially marked as dropped
|
|
109
|
+
*/
|
|
110
|
+
process(meta: Meta<L>): Meta<L>;
|
|
109
111
|
}
|
|
110
|
-
export default
|
|
111
|
-
export type { HeadSamplingConfig, SamplingProcessorOptions, TailSamplingCondition };
|
|
112
|
+
export { type HeadSamplingConfig, type SamplingProcessorOptions, type TailSamplingCondition, SamplingProcessor as default };
|
|
@@ -1,46 +1,95 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { Options } from 'rotating-file-stream';
|
|
2
|
+
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-BAgznjyU.js";
|
|
3
|
+
import 'safe-stable-stringify';
|
|
4
|
+
import "../../packem_shared/types.d-BeLumqgD.js";
|
|
5
|
+
import '@visulima/colorize';
|
|
6
|
+
import '@visulima/interactive-manager';
|
|
5
7
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
* Rotating File Stream.
|
|
9
|
+
*
|
|
10
|
+
* A wrapper for the `rotating-file-stream` module that provides optional immediate
|
|
11
|
+
* writing to disk by creating and closing a new stream on each write operation.
|
|
12
|
+
* This is useful for ensuring log messages are written immediately rather than buffered.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Buffered writing (default)
|
|
16
|
+
* const bufferedStream = new RotatingFileStream("/var/log/app.log", false, {
|
|
17
|
+
* interval: "1d",
|
|
18
|
+
* size: "10M"
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Immediate writing
|
|
22
|
+
* const immediateStream = new RotatingFileStream("/var/log/app.log", true, {
|
|
23
|
+
* interval: "1d"
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare class RotatingFileStream {
|
|
28
|
+
#private;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new RotatingFileStream instance.
|
|
31
|
+
* @param filePath Path to the log file
|
|
32
|
+
* @param writeImmediately Whether to write immediately or buffer writes
|
|
33
|
+
* @param options Options for the rotating file stream
|
|
34
|
+
* @throws {Error} If the 'rotating-file-stream' package is not installed
|
|
35
|
+
*/
|
|
36
|
+
constructor(filePath: string, writeImmediately?: boolean, options?: Options);
|
|
37
|
+
/**
|
|
38
|
+
* Writes a message to the rotating file stream.
|
|
39
|
+
*
|
|
40
|
+
* If writeImmediately was set to true in the constructor, a new stream
|
|
41
|
+
* is created for each write operation. Otherwise, uses the buffered stream.
|
|
42
|
+
* @param message The message to write to the file
|
|
43
|
+
*/
|
|
44
|
+
write(message: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Ends the rotating file stream.
|
|
47
|
+
*
|
|
48
|
+
* Closes the underlying stream. When `writeImmediately` is not `true`,
|
|
49
|
+
* calling `write` after calling this method will throw an error.
|
|
50
|
+
*/
|
|
51
|
+
end(): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for configuring the JsonFileReporter.
|
|
55
|
+
*/
|
|
56
|
+
type FileReporterOptions = AbstractJsonReporterOptions & Options & {
|
|
57
|
+
/** Path to the log file */
|
|
58
|
+
filePath: string;
|
|
59
|
+
/** Whether to write immediately to disk instead of buffering */
|
|
60
|
+
writeImmediately?: boolean;
|
|
13
61
|
};
|
|
14
62
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
63
|
+
* JSON File Reporter.
|
|
64
|
+
*
|
|
65
|
+
* A reporter that writes structured JSON log entries to rotating files on disk.
|
|
66
|
+
* Supports automatic file rotation based on size, time intervals, and compression.
|
|
67
|
+
* @template L - The log level type
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const reporter = new JsonFileReporter({
|
|
71
|
+
* filePath: "/var/log/app.log",
|
|
72
|
+
* interval: "1d", // Rotate daily
|
|
73
|
+
* size: "10M", // Rotate when file reaches 10MB
|
|
74
|
+
* compress: "gzip"
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* logger.registerReporters([reporter]);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare class JsonFileReporter<L extends string = string> extends AbstractJsonReporter<L> {
|
|
81
|
+
/** The rotating file stream instance */
|
|
82
|
+
protected stream: RotatingFileStream;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new JsonFileReporter instance.
|
|
85
|
+
* @param options Configuration options for file rotation and JSON formatting
|
|
86
|
+
*/
|
|
87
|
+
constructor(options: FileReporterOptions);
|
|
88
|
+
/**
|
|
89
|
+
* Writes a JSON message to the rotating file stream.
|
|
90
|
+
* @param message The JSON-formatted log message to write
|
|
91
|
+
* @protected
|
|
92
|
+
*/
|
|
93
|
+
protected override _log(message: string): void;
|
|
46
94
|
}
|
|
95
|
+
export { FileReporterOptions, JsonFileReporter };
|