@decaf-ts/logging 0.15.0 → 0.17.0
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/dist/logging.cjs +1 -1
- package/lib/cjs/LoggedClass.cjs +3 -2
- package/lib/cjs/LoggedClass.cjs.map +1 -0
- package/lib/cjs/constants.cjs +5 -20
- package/lib/cjs/constants.cjs.map +1 -0
- package/lib/cjs/decorators.cjs +20 -19
- package/lib/cjs/decorators.cjs.map +1 -0
- package/lib/cjs/environment.cjs +16 -15
- package/lib/cjs/environment.cjs.map +1 -0
- package/lib/cjs/filters/LogFilter.cjs +3 -2
- package/lib/cjs/filters/LogFilter.cjs.map +1 -0
- package/lib/cjs/filters/PatternFilter.cjs +15 -9
- package/lib/cjs/filters/PatternFilter.cjs.map +1 -0
- package/lib/cjs/filters/index.cjs +1 -0
- package/lib/cjs/filters/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +2 -1
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/logParameters.cjs +1 -0
- package/lib/cjs/logParameters.cjs.map +1 -0
- package/lib/cjs/logging.cjs +41 -38
- package/lib/cjs/logging.cjs.map +1 -0
- package/lib/cjs/pino/index.cjs +1 -0
- package/lib/cjs/pino/index.cjs.map +1 -0
- package/lib/cjs/pino/pino.cjs +21 -20
- package/lib/cjs/pino/pino.cjs.map +1 -0
- package/lib/cjs/text.cjs +3 -2
- package/lib/cjs/text.cjs.map +1 -0
- package/lib/cjs/time.cjs +1 -0
- package/lib/cjs/time.cjs.map +1 -0
- package/lib/cjs/types.cjs +1 -0
- package/lib/cjs/types.cjs.map +1 -0
- package/lib/cjs/utils.cjs +1 -0
- package/lib/cjs/utils.cjs.map +1 -0
- package/lib/cjs/web.cjs +1 -0
- package/lib/cjs/web.cjs.map +1 -0
- package/lib/cjs/winston/index.cjs +1 -0
- package/lib/cjs/winston/index.cjs.map +1 -0
- package/lib/cjs/winston/winston.cjs +4 -3
- package/lib/cjs/winston/winston.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/LoggedClass.d.cts +39 -0
- package/lib/types/LoggedClass.d.mts +39 -0
- package/lib/types/constants.d.cts +104 -0
- package/lib/types/constants.d.mts +104 -0
- package/lib/types/decorators.d.cts +109 -0
- package/lib/types/decorators.d.mts +109 -0
- package/lib/types/environment.d.cts +120 -0
- package/lib/types/environment.d.mts +120 -0
- package/lib/types/filters/LogFilter.d.cts +43 -0
- package/lib/types/filters/LogFilter.d.mts +43 -0
- package/lib/types/filters/PatternFilter.d.cts +56 -0
- package/lib/types/filters/PatternFilter.d.mts +56 -0
- package/lib/types/filters/index.d.cts +7 -0
- package/lib/types/filters/index.d.mts +7 -0
- package/lib/types/index.d.cts +34 -0
- package/lib/types/index.d.mts +34 -0
- package/lib/types/logParameters.d.cts +56 -0
- package/lib/types/logParameters.d.mts +56 -0
- package/lib/types/logging.d.cts +373 -0
- package/lib/types/logging.d.mts +373 -0
- package/lib/types/pino/index.d.cts +7 -0
- package/lib/types/pino/index.d.mts +7 -0
- package/lib/types/pino/pino.d.cts +29 -0
- package/lib/types/pino/pino.d.mts +29 -0
- package/lib/types/text.d.cts +118 -0
- package/lib/types/text.d.mts +118 -0
- package/lib/types/time.d.cts +151 -0
- package/lib/types/time.d.mts +151 -0
- package/lib/types/types.d.cts +287 -0
- package/lib/types/types.d.mts +287 -0
- package/lib/types/utils.d.cts +48 -0
- package/lib/types/utils.d.mts +48 -0
- package/lib/types/web.d.cts +8 -0
- package/lib/types/web.d.mts +8 -0
- package/lib/types/winston/index.d.cts +7 -0
- package/lib/types/winston/index.d.mts +7 -0
- package/lib/types/winston/winston.d.cts +47 -0
- package/lib/types/winston/winston.d.mts +47 -0
- package/package.json +4 -4
- package/lib/cjs/LoggedClass.js.map +0 -1
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/decorators.js.map +0 -1
- package/lib/cjs/environment.js.map +0 -1
- package/lib/cjs/filters/LogFilter.js.map +0 -1
- package/lib/cjs/filters/PatternFilter.js.map +0 -1
- package/lib/cjs/filters/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/logParameters.js.map +0 -1
- package/lib/cjs/logging.js.map +0 -1
- package/lib/cjs/pino/index.js.map +0 -1
- package/lib/cjs/pino/pino.js.map +0 -1
- package/lib/cjs/text.js.map +0 -1
- package/lib/cjs/time.js.map +0 -1
- package/lib/cjs/types.js.map +0 -1
- package/lib/cjs/utils.js.map +0 -1
- package/lib/cjs/web.js.map +0 -1
- package/lib/cjs/winston/index.js.map +0 -1
- package/lib/cjs/winston/winston.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Logger, LoggingConfig, LoggingFilter } from "../types.cjs";
|
|
2
|
+
import { LoggedClass } from "../LoggedClass.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* @description A base class for message filters that can be plugged into the logging pipeline.
|
|
5
|
+
* @summary This class extends {@link LoggedClass} to supply a scoped logger, and defines the contract that is required by {@link LoggingFilter} implementers that transform or drop log messages before emission.
|
|
6
|
+
* @class LogFilter
|
|
7
|
+
* @example
|
|
8
|
+
* class RedactSecretsFilter extends LogFilter {
|
|
9
|
+
* filter(config: LoggingConfig, message: string): string {
|
|
10
|
+
* return message.replace(/secret/gi, "***");
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* const filter = new RedactSecretsFilter();
|
|
15
|
+
* filter.filter({ ...DefaultLoggingConfig, verbose: 0 }, "secret token");
|
|
16
|
+
* @mermaid
|
|
17
|
+
* sequenceDiagram
|
|
18
|
+
* participant Logger
|
|
19
|
+
* participant Filter as LogFilter
|
|
20
|
+
* participant Impl as ConcreteFilter
|
|
21
|
+
* participant Output
|
|
22
|
+
* Logger->>Filter: filter(config, message, context)
|
|
23
|
+
* Filter->>Impl: delegate to subclass implementation
|
|
24
|
+
* Impl-->>Filter: transformed message
|
|
25
|
+
* Filter-->>Output: return filtered message
|
|
26
|
+
*/
|
|
27
|
+
export declare abstract class LogFilter extends LoggedClass implements LoggingFilter {
|
|
28
|
+
/**
|
|
29
|
+
* @description A scoped logger that excludes other filters from the chain.
|
|
30
|
+
* @summary This method returns a child logger that is dedicated to the filter, which prevents recursive filter invocation when emitting diagnostic messages.
|
|
31
|
+
* @return {Logger} A context-aware logger for the filter instance.
|
|
32
|
+
*/
|
|
33
|
+
get log(): Logger;
|
|
34
|
+
/**
|
|
35
|
+
* @description Transforms or suppresses a log message.
|
|
36
|
+
* @summary This method inspects the provided message and context to produce the value that will be forwarded to subsequent filters or emitters.
|
|
37
|
+
* @param {LoggingConfig} config - The active logging configuration.
|
|
38
|
+
* @param {string} message - The original log message payload.
|
|
39
|
+
* @param {string[]} context - The context values that are attached to the message.
|
|
40
|
+
* @return {string} The filtered message to pass to downstream processing.
|
|
41
|
+
*/
|
|
42
|
+
abstract filter(config: LoggingConfig, message: string, context: string[]): string;
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Logger, LoggingConfig, LoggingFilter } from "../types.js";
|
|
2
|
+
import { LoggedClass } from "../LoggedClass.js";
|
|
3
|
+
/**
|
|
4
|
+
* @description A base class for message filters that can be plugged into the logging pipeline.
|
|
5
|
+
* @summary This class extends {@link LoggedClass} to supply a scoped logger, and defines the contract that is required by {@link LoggingFilter} implementers that transform or drop log messages before emission.
|
|
6
|
+
* @class LogFilter
|
|
7
|
+
* @example
|
|
8
|
+
* class RedactSecretsFilter extends LogFilter {
|
|
9
|
+
* filter(config: LoggingConfig, message: string): string {
|
|
10
|
+
* return message.replace(/secret/gi, "***");
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* const filter = new RedactSecretsFilter();
|
|
15
|
+
* filter.filter({ ...DefaultLoggingConfig, verbose: 0 }, "secret token");
|
|
16
|
+
* @mermaid
|
|
17
|
+
* sequenceDiagram
|
|
18
|
+
* participant Logger
|
|
19
|
+
* participant Filter as LogFilter
|
|
20
|
+
* participant Impl as ConcreteFilter
|
|
21
|
+
* participant Output
|
|
22
|
+
* Logger->>Filter: filter(config, message, context)
|
|
23
|
+
* Filter->>Impl: delegate to subclass implementation
|
|
24
|
+
* Impl-->>Filter: transformed message
|
|
25
|
+
* Filter-->>Output: return filtered message
|
|
26
|
+
*/
|
|
27
|
+
export declare abstract class LogFilter extends LoggedClass implements LoggingFilter {
|
|
28
|
+
/**
|
|
29
|
+
* @description A scoped logger that excludes other filters from the chain.
|
|
30
|
+
* @summary This method returns a child logger that is dedicated to the filter, which prevents recursive filter invocation when emitting diagnostic messages.
|
|
31
|
+
* @return {Logger} A context-aware logger for the filter instance.
|
|
32
|
+
*/
|
|
33
|
+
get log(): Logger;
|
|
34
|
+
/**
|
|
35
|
+
* @description Transforms or suppresses a log message.
|
|
36
|
+
* @summary This method inspects the provided message and context to produce the value that will be forwarded to subsequent filters or emitters.
|
|
37
|
+
* @param {LoggingConfig} config - The active logging configuration.
|
|
38
|
+
* @param {string} message - The original log message payload.
|
|
39
|
+
* @param {string[]} context - The context values that are attached to the message.
|
|
40
|
+
* @return {string} The filtered message to pass to downstream processing.
|
|
41
|
+
*/
|
|
42
|
+
abstract filter(config: LoggingConfig, message: string, context: string[]): string;
|
|
43
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { LogFilter } from "./LogFilter.cjs";
|
|
2
|
+
import { LoggingConfig } from "../types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* @description A replacement callback that is used to transform RegExp matches.
|
|
5
|
+
* @summary This function receives the matched substring and additional capture arguments, and returns the replacement text that will be injected into the log message.
|
|
6
|
+
* @typedef {function(string, ...any): string} ReplacementFunction
|
|
7
|
+
* @memberOf module:Logging
|
|
8
|
+
*/
|
|
9
|
+
export type ReplacementFunction = (substring: string, ...args: any[]) => string;
|
|
10
|
+
/**
|
|
11
|
+
* @description A filter that patches log messages using regular expressions.
|
|
12
|
+
* @summary This class applies a configured {@link RegExp} and replacement strategy to redact, mask, or restructure log payloads before they are emitted.
|
|
13
|
+
* @param {RegExp} regexp - The expression to use for detecting sensitive or formatted text.
|
|
14
|
+
* @param {(string|ReplacementFunction)} replacement - The replacement string or a callback that is invoked for each match.
|
|
15
|
+
* @class PatternFilter
|
|
16
|
+
* @example
|
|
17
|
+
* const filter = new PatternFilter(/token=[^&]+/g, "token=***");
|
|
18
|
+
* const sanitized = filter.filter(config, "token=123&user=tom", []);
|
|
19
|
+
* // sanitized === "token=***&user=tom"
|
|
20
|
+
* @mermaid
|
|
21
|
+
* sequenceDiagram
|
|
22
|
+
* participant Logger
|
|
23
|
+
* participant Filter as PatternFilter
|
|
24
|
+
* participant RegExp
|
|
25
|
+
* Logger->>Filter: filter(config, message, context)
|
|
26
|
+
* Filter->>RegExp: execute match()
|
|
27
|
+
* alt match found
|
|
28
|
+
* RegExp-->>Filter: captures
|
|
29
|
+
* Filter->>RegExp: replace(message, replacement)
|
|
30
|
+
* RegExp-->>Filter: transformed message
|
|
31
|
+
* else no match
|
|
32
|
+
* RegExp-->>Filter: null
|
|
33
|
+
* end
|
|
34
|
+
* Filter-->>Logger: sanitized message
|
|
35
|
+
*/
|
|
36
|
+
export declare class PatternFilter extends LogFilter {
|
|
37
|
+
protected readonly regexp: RegExp;
|
|
38
|
+
protected readonly replacement: string | ReplacementFunction;
|
|
39
|
+
constructor(regexp: RegExp, replacement: string | ReplacementFunction);
|
|
40
|
+
/**
|
|
41
|
+
* @description Ensures deterministic RegExp matching.
|
|
42
|
+
* @summary This method runs the configured expression, then resets its state so that repeated invocations behave consistently.
|
|
43
|
+
* @param {string} message - The message to test for matches.
|
|
44
|
+
* @return {(RegExpExecArray|null)} The match result, or null if no match is found.
|
|
45
|
+
*/
|
|
46
|
+
protected match(message: string): RegExpExecArray | null;
|
|
47
|
+
/**
|
|
48
|
+
* @description Applies the replacement strategy to the incoming message.
|
|
49
|
+
* @summary This method executes {@link PatternFilter.match} and, when a match is found, replaces every occurrence using the configured replacement handler.
|
|
50
|
+
* @param {LoggingConfig} config - The active logging configuration (unused, but part of the filter contract).
|
|
51
|
+
* @param {string} message - The message to be sanitized.
|
|
52
|
+
* @param {string[]} context - The context entries that are associated with the log event.
|
|
53
|
+
* @return {string} The sanitized log message.
|
|
54
|
+
*/
|
|
55
|
+
filter(config: LoggingConfig, message: string, context: string[]): string;
|
|
56
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { LogFilter } from "./LogFilter.js";
|
|
2
|
+
import { LoggingConfig } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* @description A replacement callback that is used to transform RegExp matches.
|
|
5
|
+
* @summary This function receives the matched substring and additional capture arguments, and returns the replacement text that will be injected into the log message.
|
|
6
|
+
* @typedef {function(string, ...any): string} ReplacementFunction
|
|
7
|
+
* @memberOf module:Logging
|
|
8
|
+
*/
|
|
9
|
+
export type ReplacementFunction = (substring: string, ...args: any[]) => string;
|
|
10
|
+
/**
|
|
11
|
+
* @description A filter that patches log messages using regular expressions.
|
|
12
|
+
* @summary This class applies a configured {@link RegExp} and replacement strategy to redact, mask, or restructure log payloads before they are emitted.
|
|
13
|
+
* @param {RegExp} regexp - The expression to use for detecting sensitive or formatted text.
|
|
14
|
+
* @param {(string|ReplacementFunction)} replacement - The replacement string or a callback that is invoked for each match.
|
|
15
|
+
* @class PatternFilter
|
|
16
|
+
* @example
|
|
17
|
+
* const filter = new PatternFilter(/token=[^&]+/g, "token=***");
|
|
18
|
+
* const sanitized = filter.filter(config, "token=123&user=tom", []);
|
|
19
|
+
* // sanitized === "token=***&user=tom"
|
|
20
|
+
* @mermaid
|
|
21
|
+
* sequenceDiagram
|
|
22
|
+
* participant Logger
|
|
23
|
+
* participant Filter as PatternFilter
|
|
24
|
+
* participant RegExp
|
|
25
|
+
* Logger->>Filter: filter(config, message, context)
|
|
26
|
+
* Filter->>RegExp: execute match()
|
|
27
|
+
* alt match found
|
|
28
|
+
* RegExp-->>Filter: captures
|
|
29
|
+
* Filter->>RegExp: replace(message, replacement)
|
|
30
|
+
* RegExp-->>Filter: transformed message
|
|
31
|
+
* else no match
|
|
32
|
+
* RegExp-->>Filter: null
|
|
33
|
+
* end
|
|
34
|
+
* Filter-->>Logger: sanitized message
|
|
35
|
+
*/
|
|
36
|
+
export declare class PatternFilter extends LogFilter {
|
|
37
|
+
protected readonly regexp: RegExp;
|
|
38
|
+
protected readonly replacement: string | ReplacementFunction;
|
|
39
|
+
constructor(regexp: RegExp, replacement: string | ReplacementFunction);
|
|
40
|
+
/**
|
|
41
|
+
* @description Ensures deterministic RegExp matching.
|
|
42
|
+
* @summary This method runs the configured expression, then resets its state so that repeated invocations behave consistently.
|
|
43
|
+
* @param {string} message - The message to test for matches.
|
|
44
|
+
* @return {(RegExpExecArray|null)} The match result, or null if no match is found.
|
|
45
|
+
*/
|
|
46
|
+
protected match(message: string): RegExpExecArray | null;
|
|
47
|
+
/**
|
|
48
|
+
* @description Applies the replacement strategy to the incoming message.
|
|
49
|
+
* @summary This method executes {@link PatternFilter.match} and, when a match is found, replaces every occurrence using the configured replacement handler.
|
|
50
|
+
* @param {LoggingConfig} config - The active logging configuration (unused, but part of the filter contract).
|
|
51
|
+
* @param {string} message - The message to be sanitized.
|
|
52
|
+
* @param {string[]} context - The context entries that are associated with the log event.
|
|
53
|
+
* @return {string} The sanitized log message.
|
|
54
|
+
*/
|
|
55
|
+
filter(config: LoggingConfig, message: string, context: string[]): string;
|
|
56
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Exports for the filters module.
|
|
3
|
+
* @summary This file exports all the necessary components for the filters functionality, including LogFilter and PatternFilter.
|
|
4
|
+
* @module logging/filters
|
|
5
|
+
*/
|
|
6
|
+
export * from "./LogFilter.cjs";
|
|
7
|
+
export * from "./PatternFilter.cjs";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Exports for the filters module.
|
|
3
|
+
* @summary This file exports all the necessary components for the filters functionality, including LogFilter and PatternFilter.
|
|
4
|
+
* @module logging/filters
|
|
5
|
+
*/
|
|
6
|
+
export * from "./LogFilter.js";
|
|
7
|
+
export * from "./PatternFilter.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Logging
|
|
3
|
+
* @description A comprehensive and versatile logging toolkit for both browser and Node.js environments.
|
|
4
|
+
* @summary This module provides a complete logging solution, exposing {@link Logging} and {@link MiniLogger} for runtime logging. It also includes decorators like {@link log} for method instrumentation, and various utilities such as {@link PatternFilter}, {@link StopWatch}, and {@link LoggedEnvironment} to help build configurable and theme-aware log pipelines.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./filters/index.cjs";
|
|
7
|
+
export * from "./constants.cjs";
|
|
8
|
+
export * from "./decorators.cjs";
|
|
9
|
+
export * from "./environment.cjs";
|
|
10
|
+
export * from "./LoggedClass.cjs";
|
|
11
|
+
export * from "./logging.cjs";
|
|
12
|
+
export * from "./logParameters.cjs";
|
|
13
|
+
export * from "./text.cjs";
|
|
14
|
+
export * from "./time.cjs";
|
|
15
|
+
export * from "./types.cjs";
|
|
16
|
+
export * from "./web.cjs";
|
|
17
|
+
export * from "./utils.cjs";
|
|
18
|
+
export * from "styled-string-builder";
|
|
19
|
+
/**
|
|
20
|
+
* @description Current package version string.
|
|
21
|
+
* @summary Stores the package version for diagnostics and compatibility checks.
|
|
22
|
+
* @const VERSION
|
|
23
|
+
* @type {string}
|
|
24
|
+
* @memberOf module:Logging
|
|
25
|
+
*/
|
|
26
|
+
export declare const VERSION: string;
|
|
27
|
+
/**
|
|
28
|
+
* @description Current package version string.
|
|
29
|
+
* @summary Stores the package version for diagnostics and compatibility checks.
|
|
30
|
+
* @const PACKAGE_NAME
|
|
31
|
+
* @type {string}
|
|
32
|
+
* @memberOf module:Logging
|
|
33
|
+
*/
|
|
34
|
+
export declare const PACKAGE_NAME: string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Logging
|
|
3
|
+
* @description A comprehensive and versatile logging toolkit for both browser and Node.js environments.
|
|
4
|
+
* @summary This module provides a complete logging solution, exposing {@link Logging} and {@link MiniLogger} for runtime logging. It also includes decorators like {@link log} for method instrumentation, and various utilities such as {@link PatternFilter}, {@link StopWatch}, and {@link LoggedEnvironment} to help build configurable and theme-aware log pipelines.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./filters/index.js";
|
|
7
|
+
export * from "./constants.js";
|
|
8
|
+
export * from "./decorators.js";
|
|
9
|
+
export * from "./environment.js";
|
|
10
|
+
export * from "./LoggedClass.js";
|
|
11
|
+
export * from "./logging.js";
|
|
12
|
+
export * from "./logParameters.js";
|
|
13
|
+
export * from "./text.js";
|
|
14
|
+
export * from "./time.js";
|
|
15
|
+
export * from "./types.js";
|
|
16
|
+
export * from "./web.js";
|
|
17
|
+
export * from "./utils.js";
|
|
18
|
+
export * from "styled-string-builder";
|
|
19
|
+
/**
|
|
20
|
+
* @description Current package version string.
|
|
21
|
+
* @summary Stores the package version for diagnostics and compatibility checks.
|
|
22
|
+
* @const VERSION
|
|
23
|
+
* @type {string}
|
|
24
|
+
* @memberOf module:Logging
|
|
25
|
+
*/
|
|
26
|
+
export declare const VERSION: string;
|
|
27
|
+
/**
|
|
28
|
+
* @description Current package version string.
|
|
29
|
+
* @summary Stores the package version for diagnostics and compatibility checks.
|
|
30
|
+
* @const PACKAGE_NAME
|
|
31
|
+
* @type {string}
|
|
32
|
+
* @memberOf module:Logging
|
|
33
|
+
*/
|
|
34
|
+
export declare const PACKAGE_NAME: string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { LogLevel } from "./constants.cjs";
|
|
2
|
+
import { LogMeta, LoggingConfig } from "./types.cjs";
|
|
3
|
+
export type LogParameterPayload = {
|
|
4
|
+
config: LoggingConfig;
|
|
5
|
+
level: LogLevel;
|
|
6
|
+
context: string[];
|
|
7
|
+
timestamp?: string;
|
|
8
|
+
app?: string;
|
|
9
|
+
separator?: string;
|
|
10
|
+
correlationId?: string;
|
|
11
|
+
rawMessage: string;
|
|
12
|
+
filteredMessage: string;
|
|
13
|
+
meta?: LogMeta;
|
|
14
|
+
metaString?: string;
|
|
15
|
+
stack?: string;
|
|
16
|
+
stackLabel?: string;
|
|
17
|
+
applyTheme(value: string, type: string): string;
|
|
18
|
+
};
|
|
19
|
+
export interface LogParameterDescriptor {
|
|
20
|
+
key: string;
|
|
21
|
+
render(payload: LogParameterPayload): string | undefined;
|
|
22
|
+
style?(rendered: string, payload: LogParameterPayload): string;
|
|
23
|
+
shouldInclude?(payload: LogParameterPayload): boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface LogPatternLiteralSegment {
|
|
26
|
+
type: "literal";
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
export interface LogPatternParameterSegment {
|
|
30
|
+
type: "parameter";
|
|
31
|
+
key: string;
|
|
32
|
+
}
|
|
33
|
+
export interface LogPatternOptionalSegment {
|
|
34
|
+
type: "optional";
|
|
35
|
+
prefix: string;
|
|
36
|
+
suffix: string;
|
|
37
|
+
children: LogPatternSegment[];
|
|
38
|
+
}
|
|
39
|
+
export type LogPatternSegment = LogPatternLiteralSegment | LogPatternParameterSegment | LogPatternOptionalSegment;
|
|
40
|
+
export type LogPatternDefinition = {
|
|
41
|
+
pattern: string;
|
|
42
|
+
segments: LogPatternSegment[];
|
|
43
|
+
keys: string[];
|
|
44
|
+
includesMeta: boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare class LogParameterRegistry {
|
|
47
|
+
private readonly descriptors;
|
|
48
|
+
register(descriptor: LogParameterDescriptor): this;
|
|
49
|
+
unregister(key: string): this;
|
|
50
|
+
get(key: string): LogParameterDescriptor | undefined;
|
|
51
|
+
render(payload: LogParameterPayload, keys: string[]): Record<string, string>;
|
|
52
|
+
keys(): string[];
|
|
53
|
+
}
|
|
54
|
+
export declare function compileLogPattern(pattern: string): LogPatternDefinition;
|
|
55
|
+
export declare function renderPattern(definition: LogPatternDefinition, rendered: Record<string, string>): string;
|
|
56
|
+
export declare const logParameterRegistry: LogParameterRegistry;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { LogLevel } from "./constants.js";
|
|
2
|
+
import { LogMeta, LoggingConfig } from "./types.js";
|
|
3
|
+
export type LogParameterPayload = {
|
|
4
|
+
config: LoggingConfig;
|
|
5
|
+
level: LogLevel;
|
|
6
|
+
context: string[];
|
|
7
|
+
timestamp?: string;
|
|
8
|
+
app?: string;
|
|
9
|
+
separator?: string;
|
|
10
|
+
correlationId?: string;
|
|
11
|
+
rawMessage: string;
|
|
12
|
+
filteredMessage: string;
|
|
13
|
+
meta?: LogMeta;
|
|
14
|
+
metaString?: string;
|
|
15
|
+
stack?: string;
|
|
16
|
+
stackLabel?: string;
|
|
17
|
+
applyTheme(value: string, type: string): string;
|
|
18
|
+
};
|
|
19
|
+
export interface LogParameterDescriptor {
|
|
20
|
+
key: string;
|
|
21
|
+
render(payload: LogParameterPayload): string | undefined;
|
|
22
|
+
style?(rendered: string, payload: LogParameterPayload): string;
|
|
23
|
+
shouldInclude?(payload: LogParameterPayload): boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface LogPatternLiteralSegment {
|
|
26
|
+
type: "literal";
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
export interface LogPatternParameterSegment {
|
|
30
|
+
type: "parameter";
|
|
31
|
+
key: string;
|
|
32
|
+
}
|
|
33
|
+
export interface LogPatternOptionalSegment {
|
|
34
|
+
type: "optional";
|
|
35
|
+
prefix: string;
|
|
36
|
+
suffix: string;
|
|
37
|
+
children: LogPatternSegment[];
|
|
38
|
+
}
|
|
39
|
+
export type LogPatternSegment = LogPatternLiteralSegment | LogPatternParameterSegment | LogPatternOptionalSegment;
|
|
40
|
+
export type LogPatternDefinition = {
|
|
41
|
+
pattern: string;
|
|
42
|
+
segments: LogPatternSegment[];
|
|
43
|
+
keys: string[];
|
|
44
|
+
includesMeta: boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare class LogParameterRegistry {
|
|
47
|
+
private readonly descriptors;
|
|
48
|
+
register(descriptor: LogParameterDescriptor): this;
|
|
49
|
+
unregister(key: string): this;
|
|
50
|
+
get(key: string): LogParameterDescriptor | undefined;
|
|
51
|
+
render(payload: LogParameterPayload, keys: string[]): Record<string, string>;
|
|
52
|
+
keys(): string[];
|
|
53
|
+
}
|
|
54
|
+
export declare function compileLogPattern(pattern: string): LogPatternDefinition;
|
|
55
|
+
export declare function renderPattern(definition: LogPatternDefinition, rendered: Record<string, string>): string;
|
|
56
|
+
export declare const logParameterRegistry: LogParameterRegistry;
|