@decaf-ts/logging 0.10.0 → 0.10.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.
- package/README.md +298 -171
- package/dist/logging.cjs +1 -1
- package/dist/logging.cjs.map +1 -1
- package/dist/logging.js +1 -1
- package/dist/logging.js.map +1 -1
- package/lib/LoggedClass.cjs +4 -4
- package/lib/LoggedClass.d.ts +4 -4
- package/lib/constants.cjs +32 -63
- package/lib/constants.d.ts +32 -63
- package/lib/constants.js.map +1 -1
- package/lib/decorators.cjs +28 -28
- package/lib/decorators.d.ts +29 -36
- package/lib/decorators.js.map +1 -1
- package/lib/environment.cjs +34 -41
- package/lib/environment.d.ts +31 -32
- package/lib/environment.js.map +1 -1
- package/lib/esm/LoggedClass.d.ts +4 -4
- package/lib/esm/LoggedClass.js +4 -4
- package/lib/esm/constants.d.ts +32 -63
- package/lib/esm/constants.js +32 -63
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/decorators.d.ts +29 -36
- package/lib/esm/decorators.js +28 -28
- package/lib/esm/decorators.js.map +1 -1
- package/lib/esm/environment.d.ts +31 -32
- package/lib/esm/environment.js +34 -41
- package/lib/esm/environment.js.map +1 -1
- package/lib/esm/filters/LogFilter.d.ts +11 -11
- package/lib/esm/filters/LogFilter.js +5 -5
- package/lib/esm/filters/PatternFilter.d.ts +15 -15
- package/lib/esm/filters/PatternFilter.js +12 -12
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +3 -3
- package/lib/esm/logging.d.ts +119 -113
- package/lib/esm/logging.js +223 -138
- package/lib/esm/logging.js.map +1 -1
- package/lib/esm/pino/index.d.ts +6 -0
- package/lib/esm/pino/index.js +6 -0
- package/lib/esm/pino/index.js.map +1 -1
- package/lib/esm/pino/pino.d.ts +13 -5
- package/lib/esm/pino/pino.js +70 -124
- package/lib/esm/pino/pino.js.map +1 -1
- package/lib/esm/text.d.ts +29 -67
- package/lib/esm/text.js +29 -67
- package/lib/esm/text.js.map +1 -1
- package/lib/esm/time.d.ts +45 -43
- package/lib/esm/time.js +38 -36
- package/lib/esm/time.js.map +1 -1
- package/lib/esm/types.d.ts +59 -50
- package/lib/esm/utils.d.ts +43 -0
- package/lib/esm/utils.js +55 -3
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/web.d.ts +2 -2
- package/lib/esm/web.js +2 -2
- package/lib/esm/winston/index.d.ts +7 -0
- package/lib/esm/winston/index.js +7 -1
- package/lib/esm/winston/index.js.map +1 -1
- package/lib/esm/winston/winston.d.ts +17 -21
- package/lib/esm/winston/winston.js +29 -36
- package/lib/esm/winston/winston.js.map +1 -1
- package/lib/filters/LogFilter.cjs +5 -5
- package/lib/filters/LogFilter.d.ts +11 -11
- package/lib/filters/PatternFilter.cjs +12 -12
- package/lib/filters/PatternFilter.d.ts +15 -15
- package/lib/index.cjs +3 -3
- package/lib/index.d.ts +2 -2
- package/lib/logging.cjs +224 -139
- package/lib/logging.d.ts +119 -113
- package/lib/logging.js.map +1 -1
- package/lib/pino/index.cjs +6 -0
- package/lib/pino/index.d.ts +6 -0
- package/lib/pino/index.js.map +1 -1
- package/lib/pino/pino.cjs +102 -126
- package/lib/pino/pino.d.ts +13 -5
- package/lib/pino/pino.js.map +1 -1
- package/lib/text.cjs +29 -67
- package/lib/text.d.ts +29 -67
- package/lib/text.js.map +1 -1
- package/lib/time.cjs +38 -36
- package/lib/time.d.ts +45 -43
- package/lib/time.js.map +1 -1
- package/lib/types.d.ts +59 -50
- package/lib/utils.cjs +55 -3
- package/lib/utils.d.ts +43 -0
- package/lib/utils.js.map +1 -1
- package/lib/web.cjs +2 -2
- package/lib/web.d.ts +2 -2
- package/lib/winston/index.cjs +22 -0
- package/lib/winston/index.d.ts +7 -0
- package/lib/winston/index.js.map +1 -1
- package/lib/winston/winston.cjs +29 -36
- package/lib/winston/winston.d.ts +17 -21
- package/lib/winston/winston.js.map +1 -1
- package/package.json +9 -10
- package/lib/accumulate.types.cjs +0 -27
- package/lib/accumulate.types.d.ts +0 -1
- package/lib/accumulate.types.js.map +0 -1
- package/lib/esm/accumulate.types.d.ts +0 -1
- package/lib/esm/accumulate.types.js +0 -25
- package/lib/esm/accumulate.types.js.map +0 -1
package/lib/esm/constants.js
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @description
|
|
3
|
-
* @summary
|
|
4
|
-
* @const BrowserEnvKey
|
|
5
|
-
* @type {string}
|
|
2
|
+
* @description The global key that is used to store environment variables in browser contexts.
|
|
3
|
+
* @summary This enables the logging environment helpers to locate serialized environment configuration on `globalThis`.
|
|
4
|
+
* @const {string} BrowserEnvKey
|
|
6
5
|
* @memberOf module:Logging
|
|
7
6
|
*/
|
|
8
7
|
export const BrowserEnvKey = "ENV";
|
|
9
8
|
/**
|
|
10
|
-
* @description
|
|
11
|
-
* @summary
|
|
12
|
-
* @const ENV_PATH_DELIMITER
|
|
13
|
-
* @type {string}
|
|
9
|
+
* @description The delimiter that is used for composing nested environment variable names.
|
|
10
|
+
* @summary This joins parent and child keys when mapping object paths to ENV strings.
|
|
11
|
+
* @const {string} ENV_PATH_DELIMITER
|
|
14
12
|
* @memberOf module:Logging
|
|
15
13
|
*/
|
|
16
14
|
export const ENV_PATH_DELIMITER = "__";
|
|
17
15
|
/**
|
|
18
|
-
* @description
|
|
19
|
-
* @summary
|
|
20
|
-
* @const DefaultPlaceholderWrappers
|
|
21
|
-
* @type {string[]}
|
|
16
|
+
* @description The default prefix and suffix that are used for template placeholders.
|
|
17
|
+
* @summary This provides wrapper strings that are applied when interpolating messages with {@link patchPlaceholders}.
|
|
18
|
+
* @const {string[]} DefaultPlaceholderWrappers
|
|
22
19
|
* @memberOf module:Logging
|
|
23
20
|
*/
|
|
24
21
|
export const DefaultPlaceholderWrappers = ["${", "}"];
|
|
25
22
|
/**
|
|
26
|
-
* @description
|
|
27
|
-
* @summary Defines different levels of logging for the application.
|
|
23
|
+
* @description An enum for log levels.
|
|
24
|
+
* @summary Defines the different levels of logging for the application.
|
|
28
25
|
* @enum {string}
|
|
29
26
|
* @readonly
|
|
30
27
|
* @memberOf module:Logging
|
|
@@ -49,22 +46,23 @@ export var LogLevel;
|
|
|
49
46
|
LogLevel["silly"] = "silly";
|
|
50
47
|
})(LogLevel || (LogLevel = {}));
|
|
51
48
|
/**
|
|
52
|
-
* @description
|
|
53
|
-
* @summary
|
|
54
|
-
* @typedef {
|
|
55
|
-
* @property {number} benchmark -
|
|
56
|
-
* @property {number} error -
|
|
57
|
-
* @property {number}
|
|
58
|
-
* @property {number}
|
|
59
|
-
* @property {number}
|
|
60
|
-
* @property {number}
|
|
49
|
+
* @description The numeric values that are associated with log levels.
|
|
50
|
+
* @summary This provides a numeric representation of log levels for comparison and filtering.
|
|
51
|
+
* @typedef {object} NumericLogLevelsShape
|
|
52
|
+
* @property {number} benchmark - The numeric value for the benchmark level (0).
|
|
53
|
+
* @property {number} error - The numeric value for the error level (3).
|
|
54
|
+
* @property {number} warn - The numeric value for the warn level (6).
|
|
55
|
+
* @property {number} info - The numeric value for the info level (9).
|
|
56
|
+
* @property {number} verbose - The numeric value for the verbose level (12).
|
|
57
|
+
* @property {number} debug - The numeric value for the debug level (15).
|
|
58
|
+
* @property {number} trace - The numeric value for the trace level (18).
|
|
59
|
+
* @property {number} silly - The numeric value for the silly level (21).
|
|
61
60
|
* @memberOf module:Logging
|
|
62
61
|
*/
|
|
63
62
|
/**
|
|
64
|
-
* @description
|
|
65
|
-
* @summary
|
|
66
|
-
* @const NumericLogLevels
|
|
67
|
-
* @type {NumericLogLevelsShape}
|
|
63
|
+
* @description The numeric values that are associated with log levels.
|
|
64
|
+
* @summary This provides a numeric representation of log levels for comparison and filtering.
|
|
65
|
+
* @const {NumericLogLevelsShape} NumericLogLevels
|
|
68
66
|
* @memberOf module:Logging
|
|
69
67
|
*/
|
|
70
68
|
export const NumericLogLevels = {
|
|
@@ -78,9 +76,10 @@ export const NumericLogLevels = {
|
|
|
78
76
|
silly: 21,
|
|
79
77
|
};
|
|
80
78
|
/**
|
|
81
|
-
* @description
|
|
82
|
-
* @summary Defines different output formats for log messages.
|
|
79
|
+
* @description An enum for logging output modes.
|
|
80
|
+
* @summary Defines the different output formats for log messages.
|
|
83
81
|
* @enum {string}
|
|
82
|
+
* @readonly
|
|
84
83
|
* @memberOf module:Logging
|
|
85
84
|
*/
|
|
86
85
|
export var LoggingMode;
|
|
@@ -91,28 +90,9 @@ export var LoggingMode;
|
|
|
91
90
|
LoggingMode["JSON"] = "json";
|
|
92
91
|
})(LoggingMode || (LoggingMode = {}));
|
|
93
92
|
/**
|
|
94
|
-
* @description
|
|
93
|
+
* @description The default theme for styling log output.
|
|
95
94
|
* @summary Defines the default color and style settings for various components of log messages.
|
|
96
|
-
* @
|
|
97
|
-
* @property {Object} class - Styling for class names.
|
|
98
|
-
* @property {number} class.fg - Foreground color code for class names (34).
|
|
99
|
-
* @property {Object} id - Styling for identifiers.
|
|
100
|
-
* @property {number} id.fg - Foreground color code for identifiers (36).
|
|
101
|
-
* @property {Object} stack - Styling for stack traces (empty object).
|
|
102
|
-
* @property {Object} timestamp - Styling for timestamps (empty object).
|
|
103
|
-
* @property {Object} message - Styling for different types of messages.
|
|
104
|
-
* @property {Object} message.error - Styling for error messages.
|
|
105
|
-
* @property {number} message.error.fg - Foreground color code for error messages (31).
|
|
106
|
-
* @property {Object} method - Styling for method names (empty object).
|
|
107
|
-
* @property {Object} logLevel - Styling for different log levels.
|
|
108
|
-
* @property {Object} logLevel.error - Styling for error level logs.
|
|
109
|
-
* @property {number} logLevel.error.fg - Foreground color code for error level logs (31).
|
|
110
|
-
* @property {string[]} logLevel.error.style - Style attributes for error level logs (["bold"]).
|
|
111
|
-
* @property {Object} logLevel.info - Styling for info level logs (empty object).
|
|
112
|
-
* @property {Object} logLevel.verbose - Styling for verbose level logs (empty object).
|
|
113
|
-
* @property {Object} logLevel.debug - Styling for debug level logs.
|
|
114
|
-
* @property {number} logLevel.debug.fg - Foreground color code for debug level logs (33).
|
|
115
|
-
* @const DefaultTheme
|
|
95
|
+
* @const {Theme} DefaultTheme
|
|
116
96
|
* @memberOf module:Logging
|
|
117
97
|
*/
|
|
118
98
|
export const DefaultTheme = {
|
|
@@ -164,20 +144,9 @@ export const DefaultTheme = {
|
|
|
164
144
|
},
|
|
165
145
|
};
|
|
166
146
|
/**
|
|
167
|
-
* @description
|
|
147
|
+
* @description The default configuration for logging.
|
|
168
148
|
* @summary Defines the default settings for the logging system, including verbosity, log level, styling, and timestamp format.
|
|
169
|
-
* @const DefaultLoggingConfig
|
|
170
|
-
* @typedef {LoggingConfig} DefaultLoggingConfig
|
|
171
|
-
* @property {number} verbose - Verbosity level (0).
|
|
172
|
-
* @property {LogLevel} level - Default log level (LogLevel.info).
|
|
173
|
-
* @property {boolean} logLevel - Whether to display log level in output (true).
|
|
174
|
-
* @property {LoggingMode} mode - Output format mode (LoggingMode.RAW).
|
|
175
|
-
* @property {boolean} style - Whether to apply styling to log output (false).
|
|
176
|
-
* @property {string} separator - Separator between log components (" - ").
|
|
177
|
-
* @property {boolean} timestamp - Whether to include timestamps in log messages (true).
|
|
178
|
-
* @property {string} timestampFormat - Format for timestamps ("HH:mm:ss.SSS").
|
|
179
|
-
* @property {boolean} context - Whether to include context information in log messages (true).
|
|
180
|
-
* @property {Theme} theme - The theme to use for styling log messages (DefaultTheme).
|
|
149
|
+
* @const {LoggingConfig} DefaultLoggingConfig
|
|
181
150
|
* @memberOf module:Logging
|
|
182
151
|
*/
|
|
183
152
|
export const DefaultLoggingConfig = {
|
package/lib/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC;;;;;GAKG;AACH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K,EAAE;YACL,EAAE,EAAE,EAAE;SACP;KACF;IACD,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;QACD,KAAK,EAAE;YACL,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;QACD,IAAI,EAAE;YACJ,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;QACD,OAAO,EAAE;YACP,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;QACD,KAAK,EAAE;YACL,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;QACD,KAAK,EAAE;YACL,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;QACD,KAAK,EAAE;YACL,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,CAAC,MAAM,CAAC;SAChB;KACF;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD,GAAG,EAAE,aAAa;IAClB,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,QAAQ,CAAC,IAAI;IACpB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,KAAK;IACZ,gBAAgB,EAAE,GAAG;IACrB,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,IAAI;IACf,eAAe,EAAE,cAAc;IAC/B,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,WAAW,CAAC,GAAG;IACvB,OAAO,EACL,qEAAqE;IACvE,KAAK,EAAE,YAAY;CACpB,CAAC"}
|
package/lib/esm/decorators.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { LogLevel } from "./constants";
|
|
|
2
2
|
export type ArgFormatFunction = (...args: any[]) => string;
|
|
3
3
|
export type ReturnFormatFunction = (e?: Error, result?: any) => string;
|
|
4
4
|
/**
|
|
5
|
-
* @description
|
|
6
|
-
* @summary
|
|
7
|
-
* @param {LogLevel} level -
|
|
8
|
-
* @param {number} [verbosity=0] -
|
|
9
|
-
* @param {ArgFormatFunction} [entryMessage] -
|
|
10
|
-
* @param {ReturnFormatFunction} [exitMessage] -
|
|
11
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
5
|
+
* @description A method decorator for logging function calls.
|
|
6
|
+
* @summary This decorator wraps a class method to automatically log entry, exit, timing, and optional custom messages at a configurable {@link LogLevel}.
|
|
7
|
+
* @param {LogLevel} [level=LogLevel.info] - The log level to apply to the generated log statements.
|
|
8
|
+
* @param {number} [verbosity=0] - The verbosity threshold that is required for the entry log to appear.
|
|
9
|
+
* @param {ArgFormatFunction} [entryMessage] - A formatter that is invoked with the original method arguments to describe the invocation.
|
|
10
|
+
* @param {ReturnFormatFunction} [exitMessage] - An optional formatter that describes the outcome or failure of the call.
|
|
11
|
+
* @return {function(any, any, PropertyDescriptor): void} A method decorator proxy that injects logging behavior.
|
|
12
12
|
* @function log
|
|
13
13
|
* @mermaid
|
|
14
14
|
* sequenceDiagram
|
|
@@ -35,9 +35,9 @@ export type ReturnFormatFunction = (e?: Error, result?: any) => string;
|
|
|
35
35
|
*/
|
|
36
36
|
export declare function log(level?: LogLevel, verbosity?: number, entryMessage?: ArgFormatFunction, exitMessage?: ReturnFormatFunction): (target: any, propertyKey?: any, descriptor?: any) => any;
|
|
37
37
|
/**
|
|
38
|
-
* @description
|
|
39
|
-
* @summary
|
|
40
|
-
* @return {function(any, any,
|
|
38
|
+
* @description A method decorator that records execution time at the benchmark level.
|
|
39
|
+
* @summary This decorator wraps the target method to emit {@link Logger.benchmark} entries that capture completion time or failure latency.
|
|
40
|
+
* @return {function(any, any, PropertyDescriptor): void} A method decorator proxy that benchmarks the original implementation.
|
|
41
41
|
* @function benchmark
|
|
42
42
|
* @mermaid
|
|
43
43
|
* sequenceDiagram
|
|
@@ -59,57 +59,50 @@ export declare function log(level?: LogLevel, verbosity?: number, entryMessage?:
|
|
|
59
59
|
*/
|
|
60
60
|
export declare function benchmark(): (target: any, propertyKey?: any, descriptor?: any) => any;
|
|
61
61
|
/**
|
|
62
|
-
* @description
|
|
63
|
-
* @summary
|
|
64
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
62
|
+
* @description A method decorator for logging function calls with the debug level.
|
|
63
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.debug`.
|
|
64
|
+
* @return {function(any, any, PropertyDescriptor): void} A debug-level logging decorator.
|
|
65
65
|
* @function debug
|
|
66
66
|
* @category Method Decorators
|
|
67
67
|
*/
|
|
68
68
|
export declare function debug(): (target: any, propertyKey?: any, descriptor?: any) => any;
|
|
69
69
|
/**
|
|
70
|
-
* @description
|
|
71
|
-
* @summary
|
|
72
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
70
|
+
* @description A method decorator for logging function calls with the info level.
|
|
71
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.info`.
|
|
72
|
+
* @return {function(any, any, PropertyDescriptor): void} An info-level logging decorator.
|
|
73
73
|
* @function info
|
|
74
74
|
* @category Method Decorators
|
|
75
75
|
*/
|
|
76
76
|
export declare function info(): (target: any, propertyKey?: any, descriptor?: any) => any;
|
|
77
77
|
/**
|
|
78
|
-
* @description
|
|
79
|
-
* @summary
|
|
80
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
78
|
+
* @description A method decorator for logging function calls with the silly level.
|
|
79
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.silly`.
|
|
80
|
+
* @return {function(any, any, PropertyDescriptor): void} A silly-level logging decorator.
|
|
81
81
|
* @function silly
|
|
82
82
|
* @category Method Decorators
|
|
83
83
|
*/
|
|
84
84
|
export declare function silly(): (target: any, propertyKey?: any, descriptor?: any) => any;
|
|
85
85
|
/**
|
|
86
|
-
* @description
|
|
87
|
-
* @summary
|
|
88
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
86
|
+
* @description A method decorator for logging function calls with the trace level.
|
|
87
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.trace`.
|
|
88
|
+
* @return {function(any, any, PropertyDescriptor): void} A trace-level logging decorator.
|
|
89
89
|
* @function trace
|
|
90
90
|
* @category Method Decorators
|
|
91
91
|
*/
|
|
92
92
|
export declare function trace(): (target: any, propertyKey?: any, descriptor?: any) => any;
|
|
93
93
|
/**
|
|
94
|
-
* @description
|
|
95
|
-
* @summary
|
|
96
|
-
* @
|
|
94
|
+
* @description A method decorator for logging function calls with the verbose level.
|
|
95
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.verbose` with a configurable verbosity.
|
|
96
|
+
* @param {(number|boolean)} [verbosity=0] - The verbosity level for log filtering or a flag to enable benchmarking.
|
|
97
|
+
* @return {function(any, any, PropertyDescriptor): void} A verbose logging decorator.
|
|
97
98
|
* @function verbose
|
|
98
99
|
* @category Method Decorators
|
|
99
100
|
*/
|
|
100
|
-
export declare function verbose(): (target: any, propertyKey?: any, descriptor?: any) =>
|
|
101
|
-
/**
|
|
102
|
-
* @description Method decorator for logging function calls with verbose level.
|
|
103
|
-
* @summary Convenience wrapper around {@link log} that logs using `LogLevel.verbose` while toggling benchmarking.
|
|
104
|
-
* @return {function(any, PropertyDescriptor): void} Verbose logging decorator.
|
|
105
|
-
* @function verbose
|
|
106
|
-
* @category Method Decorators
|
|
107
|
-
*/
|
|
108
|
-
export declare function verbose(): (target: any, propertyKey?: any, descriptor?: any) => void;
|
|
101
|
+
export declare function verbose(verbosity?: number | boolean): (target: any, propertyKey?: any, descriptor?: any) => any;
|
|
109
102
|
/**
|
|
110
103
|
* @description Creates a decorator that makes a method non-configurable.
|
|
111
|
-
* @summary
|
|
112
|
-
* @return {function(object, any, PropertyDescriptor): PropertyDescriptor|undefined}
|
|
104
|
+
* @summary This decorator prevents overriding by marking the method descriptor as non-configurable. It will throw an error if it is applied to non-method targets.
|
|
105
|
+
* @return {function(object, any, PropertyDescriptor): (PropertyDescriptor|undefined)} A decorator that hardens the method descriptor.
|
|
113
106
|
* @function final
|
|
114
107
|
* @category Method Decorators
|
|
115
108
|
*/
|
package/lib/esm/decorators.js
CHANGED
|
@@ -3,13 +3,13 @@ import { Logging } from "./logging.js";
|
|
|
3
3
|
import { now } from "./time.js";
|
|
4
4
|
import { LoggedClass } from "./LoggedClass.js";
|
|
5
5
|
/**
|
|
6
|
-
* @description
|
|
7
|
-
* @summary
|
|
8
|
-
* @param {LogLevel} level -
|
|
9
|
-
* @param {number} [verbosity=0] -
|
|
10
|
-
* @param {ArgFormatFunction} [entryMessage] -
|
|
11
|
-
* @param {ReturnFormatFunction} [exitMessage] -
|
|
12
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
6
|
+
* @description A method decorator for logging function calls.
|
|
7
|
+
* @summary This decorator wraps a class method to automatically log entry, exit, timing, and optional custom messages at a configurable {@link LogLevel}.
|
|
8
|
+
* @param {LogLevel} [level=LogLevel.info] - The log level to apply to the generated log statements.
|
|
9
|
+
* @param {number} [verbosity=0] - The verbosity threshold that is required for the entry log to appear.
|
|
10
|
+
* @param {ArgFormatFunction} [entryMessage] - A formatter that is invoked with the original method arguments to describe the invocation.
|
|
11
|
+
* @param {ReturnFormatFunction} [exitMessage] - An optional formatter that describes the outcome or failure of the call.
|
|
12
|
+
* @return {function(any, any, PropertyDescriptor): void} A method decorator proxy that injects logging behavior.
|
|
13
13
|
* @function log
|
|
14
14
|
* @mermaid
|
|
15
15
|
* sequenceDiagram
|
|
@@ -76,9 +76,9 @@ export function log(level = LogLevel.info, verbosity = 0, entryMessage = (...arg
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* @description
|
|
80
|
-
* @summary
|
|
81
|
-
* @return {function(any, any,
|
|
79
|
+
* @description A method decorator that records execution time at the benchmark level.
|
|
80
|
+
* @summary This decorator wraps the target method to emit {@link Logger.benchmark} entries that capture completion time or failure latency.
|
|
81
|
+
* @return {function(any, any, PropertyDescriptor): void} A method decorator proxy that benchmarks the original implementation.
|
|
82
82
|
* @function benchmark
|
|
83
83
|
* @mermaid
|
|
84
84
|
* sequenceDiagram
|
|
@@ -135,9 +135,9 @@ export function benchmark() {
|
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
|
-
* @description
|
|
139
|
-
* @summary
|
|
140
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
138
|
+
* @description A method decorator for logging function calls with the debug level.
|
|
139
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.debug`.
|
|
140
|
+
* @return {function(any, any, PropertyDescriptor): void} A debug-level logging decorator.
|
|
141
141
|
* @function debug
|
|
142
142
|
* @category Method Decorators
|
|
143
143
|
*/
|
|
@@ -149,9 +149,9 @@ export function debug() {
|
|
|
149
149
|
: "completed");
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
* @description
|
|
153
|
-
* @summary
|
|
154
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
152
|
+
* @description A method decorator for logging function calls with the info level.
|
|
153
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.info`.
|
|
154
|
+
* @return {function(any, any, PropertyDescriptor): void} An info-level logging decorator.
|
|
155
155
|
* @function info
|
|
156
156
|
* @category Method Decorators
|
|
157
157
|
*/
|
|
@@ -159,9 +159,9 @@ export function info() {
|
|
|
159
159
|
return log(LogLevel.info);
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
* @description
|
|
163
|
-
* @summary
|
|
164
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
162
|
+
* @description A method decorator for logging function calls with the silly level.
|
|
163
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.silly`.
|
|
164
|
+
* @return {function(any, any, PropertyDescriptor): void} A silly-level logging decorator.
|
|
165
165
|
* @function silly
|
|
166
166
|
* @category Method Decorators
|
|
167
167
|
*/
|
|
@@ -169,9 +169,9 @@ export function silly() {
|
|
|
169
169
|
return log(LogLevel.silly);
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
|
-
* @description
|
|
173
|
-
* @summary
|
|
174
|
-
* @return {function(any, any, PropertyDescriptor): void}
|
|
172
|
+
* @description A method decorator for logging function calls with the trace level.
|
|
173
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.trace`.
|
|
174
|
+
* @return {function(any, any, PropertyDescriptor): void} A trace-level logging decorator.
|
|
175
175
|
* @function trace
|
|
176
176
|
* @category Method Decorators
|
|
177
177
|
*/
|
|
@@ -179,10 +179,10 @@ export function trace() {
|
|
|
179
179
|
return log(LogLevel.trace);
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
|
-
* @description
|
|
183
|
-
* @summary
|
|
184
|
-
* @param {number|boolean} verbosity -
|
|
185
|
-
* @return {function(any, any,PropertyDescriptor): void}
|
|
182
|
+
* @description A method decorator for logging function calls with the verbose level.
|
|
183
|
+
* @summary This is a convenience wrapper around {@link log} that logs using `LogLevel.verbose` with a configurable verbosity.
|
|
184
|
+
* @param {(number|boolean)} [verbosity=0] - The verbosity level for log filtering or a flag to enable benchmarking.
|
|
185
|
+
* @return {function(any, any, PropertyDescriptor): void} A verbose logging decorator.
|
|
186
186
|
* @function verbose
|
|
187
187
|
* @category Method Decorators
|
|
188
188
|
*/
|
|
@@ -194,8 +194,8 @@ export function verbose(verbosity = 0) {
|
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
196
|
* @description Creates a decorator that makes a method non-configurable.
|
|
197
|
-
* @summary
|
|
198
|
-
* @return {function(object, any, PropertyDescriptor): PropertyDescriptor|undefined}
|
|
197
|
+
* @summary This decorator prevents overriding by marking the method descriptor as non-configurable. It will throw an error if it is applied to non-method targets.
|
|
198
|
+
* @return {function(object, any, PropertyDescriptor): (PropertyDescriptor|undefined)} A decorator that hardens the method descriptor.
|
|
199
199
|
* @function final
|
|
200
200
|
* @category Method Decorators
|
|
201
201
|
*/
|
|
@@ -1 +1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K,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC,YAA8B,CAAC;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAmB,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,CAAC,MAAc,EAAE,WAAiB,EAAE,UAAgB,EAAE,EAAE;QAC7D,IAAI,CAAC,UAAU;YACb,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,IAAI,UAAU,EAAE,YAAY,EAAE,CAAC;YAC7B,UAAU,CAAC,YAAY,GAAG,KAAK,CAAC;QAClC,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/esm/environment.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ObjectAccumulator } from "typed-object-accumulator";
|
|
2
2
|
/**
|
|
3
|
-
* @description
|
|
4
|
-
* @summary
|
|
3
|
+
* @description A factory type for creating Environment instances.
|
|
4
|
+
* @summary This describes factories that construct {@link Environment} derivatives with custom initialization.
|
|
5
5
|
* @template T - The type of object the Environment will accumulate.
|
|
6
6
|
* @template E - The specific Environment type to be created, extending Environment<T>.
|
|
7
7
|
* @typedef {function(unknown[]): E} EnvironmentFactory
|
|
@@ -33,72 +33,71 @@ export declare class Environment<T extends object> extends ObjectAccumulator<T>
|
|
|
33
33
|
protected constructor();
|
|
34
34
|
/**
|
|
35
35
|
* @description Retrieves a value from the runtime environment.
|
|
36
|
-
* @summary
|
|
37
|
-
* @param {string} k -
|
|
38
|
-
* @return {unknown}
|
|
36
|
+
* @summary This method handles browser and Node.js environments by normalizing keys and parsing values.
|
|
37
|
+
* @param {string} k - The key to resolve from the environment.
|
|
38
|
+
* @return {unknown} The value that is resolved from the environment, or `undefined` if it is absent.
|
|
39
39
|
*/
|
|
40
40
|
protected fromEnv(k: string): unknown;
|
|
41
41
|
/**
|
|
42
42
|
* @description Converts stringified environment values into native types.
|
|
43
|
-
* @summary
|
|
44
|
-
* @param {unknown} val -
|
|
45
|
-
* @return {unknown}
|
|
43
|
+
* @summary This method interprets booleans and numbers, while leaving other types unchanged.
|
|
44
|
+
* @param {unknown} val - The raw value that is retrieved from the environment.
|
|
45
|
+
* @return {unknown} The parsed value, converted to a boolean or number, or left as-is.
|
|
46
46
|
*/
|
|
47
47
|
protected parseEnvValue(val: unknown): unknown;
|
|
48
48
|
/**
|
|
49
49
|
* @description Expands an object into the environment.
|
|
50
|
-
* @summary
|
|
51
|
-
* @template V -
|
|
52
|
-
* @param {V} value -
|
|
50
|
+
* @summary This method defines lazy properties that first consult runtime variables before falling back to seeded values.
|
|
51
|
+
* @template V - The type of the object being expanded.
|
|
52
|
+
* @param {V} value - The object to expose through environment getters and setters.
|
|
53
53
|
* @return {void}
|
|
54
54
|
*/
|
|
55
55
|
protected expand<V extends object>(value: V): void;
|
|
56
56
|
/**
|
|
57
|
-
* @description Returns a proxy
|
|
58
|
-
* @summary Accessing a property that resolves to `undefined` or an empty string when declared in the model
|
|
59
|
-
* @return {
|
|
57
|
+
* @description Returns a proxy that enforces required environment variables.
|
|
58
|
+
* @summary Accessing a property that resolves to `undefined` or an empty string when declared in the model will throw an error.
|
|
59
|
+
* @return {EnvironmentInstance<any>} A proxy of the environment that enforces required variables.
|
|
60
60
|
*/
|
|
61
61
|
orThrow(): EnvironmentInstance<any>;
|
|
62
62
|
/**
|
|
63
63
|
* @protected
|
|
64
64
|
* @static
|
|
65
65
|
* @description Retrieves or creates the singleton instance of the Environment class.
|
|
66
|
-
* @summary
|
|
66
|
+
* @summary This method ensures that only one {@link Environment} instance is created, and wraps it in a proxy to compose ENV keys on demand.
|
|
67
67
|
* @template E
|
|
68
|
-
* @param {...unknown[]} args - Arguments forwarded to the factory when instantiating the singleton.
|
|
69
|
-
* @return {E}
|
|
68
|
+
* @param {...unknown[]} args - Arguments that are forwarded to the factory when instantiating the singleton.
|
|
69
|
+
* @return {E} The singleton environment instance.
|
|
70
70
|
*/
|
|
71
71
|
protected static instance<E extends Environment<any>>(...args: unknown[]): E;
|
|
72
72
|
accumulate<V extends object>(value: V): AccumulatedEnvironment<T & V>;
|
|
73
73
|
/**
|
|
74
74
|
* @static
|
|
75
75
|
* @description Accumulates the given value into the environment.
|
|
76
|
-
* @summary
|
|
77
|
-
* @template T
|
|
76
|
+
* @summary This method adds new properties and hides raw descriptors to avoid leaking enumeration semantics.
|
|
78
77
|
* @template V
|
|
79
|
-
* @param {V} value -
|
|
80
|
-
* @return {
|
|
78
|
+
* @param {V} value - The object to merge into the environment.
|
|
79
|
+
* @return {AccumulatedEnvironment<any>} The updated environment reference.
|
|
81
80
|
*/
|
|
82
81
|
static accumulate<V extends object>(value: V): AccumulatedEnvironment<any>;
|
|
83
82
|
/**
|
|
84
83
|
* @description Retrieves a value using a dot-path key from the accumulated environment.
|
|
85
|
-
* @summary
|
|
86
|
-
* @param {string} key -
|
|
87
|
-
* @return {unknown}
|
|
84
|
+
* @summary This method delegates to the singleton instance to access stored configuration.
|
|
85
|
+
* @param {string} key - The key to resolve from the environment store.
|
|
86
|
+
* @return {unknown} The stored value that corresponds to the provided key.
|
|
88
87
|
*/
|
|
89
88
|
static get(key: string): any;
|
|
90
89
|
/**
|
|
91
90
|
* @description Builds a proxy that composes environment keys for nested properties.
|
|
92
|
-
* @summary
|
|
93
|
-
* @param {any} current -
|
|
94
|
-
* @param {string[]} path -
|
|
95
|
-
* @return {any}
|
|
91
|
+
* @summary This allows chained property access to emit uppercase ENV identifiers, while honoring existing runtime overrides.
|
|
92
|
+
* @param {any} current - The seed model segment to use when projecting nested structures.
|
|
93
|
+
* @param {string[]} path - The accumulated path segments that lead to the proxy.
|
|
94
|
+
* @return {any} A proxy that resolves environment values or composes additional proxies for deeper paths.
|
|
96
95
|
*/
|
|
97
96
|
private static buildEnvProxy;
|
|
98
97
|
/**
|
|
99
98
|
* @static
|
|
100
99
|
* @description Retrieves the keys of the environment, optionally converting them to ENV format.
|
|
101
|
-
* @summary
|
|
100
|
+
* @summary This method gets all keys in the environment, with an option to format them for environment variables.
|
|
102
101
|
* @param {boolean} [toEnv=true] - Whether to convert the keys to ENV format.
|
|
103
102
|
* @return {string[]} An array of keys from the environment.
|
|
104
103
|
*/
|
|
@@ -108,9 +107,9 @@ export declare class Environment<T extends object> extends ObjectAccumulator<T>
|
|
|
108
107
|
private static missingEnvError;
|
|
109
108
|
}
|
|
110
109
|
/**
|
|
111
|
-
* @description
|
|
112
|
-
* @summary
|
|
113
|
-
* @const LoggedEnvironment
|
|
110
|
+
* @description A singleton environment instance that is seeded with the default logging configuration.
|
|
111
|
+
* @summary This constant combines {@link DefaultLoggingConfig} with runtime environment variables to provide consistent logging defaults across platforms.
|
|
112
|
+
* @const {AccumulatedEnvironment<any>} LoggedEnvironment
|
|
114
113
|
* @memberOf module:Logging
|
|
115
114
|
*/
|
|
116
115
|
export declare const LoggedEnvironment: any;
|