@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.
Files changed (98) hide show
  1. package/dist/logging.cjs +1 -1
  2. package/lib/cjs/LoggedClass.cjs +3 -2
  3. package/lib/cjs/LoggedClass.cjs.map +1 -0
  4. package/lib/cjs/constants.cjs +5 -20
  5. package/lib/cjs/constants.cjs.map +1 -0
  6. package/lib/cjs/decorators.cjs +20 -19
  7. package/lib/cjs/decorators.cjs.map +1 -0
  8. package/lib/cjs/environment.cjs +16 -15
  9. package/lib/cjs/environment.cjs.map +1 -0
  10. package/lib/cjs/filters/LogFilter.cjs +3 -2
  11. package/lib/cjs/filters/LogFilter.cjs.map +1 -0
  12. package/lib/cjs/filters/PatternFilter.cjs +15 -9
  13. package/lib/cjs/filters/PatternFilter.cjs.map +1 -0
  14. package/lib/cjs/filters/index.cjs +1 -0
  15. package/lib/cjs/filters/index.cjs.map +1 -0
  16. package/lib/cjs/index.cjs +2 -1
  17. package/lib/cjs/index.cjs.map +1 -0
  18. package/lib/cjs/logParameters.cjs +1 -0
  19. package/lib/cjs/logParameters.cjs.map +1 -0
  20. package/lib/cjs/logging.cjs +41 -38
  21. package/lib/cjs/logging.cjs.map +1 -0
  22. package/lib/cjs/pino/index.cjs +1 -0
  23. package/lib/cjs/pino/index.cjs.map +1 -0
  24. package/lib/cjs/pino/pino.cjs +21 -20
  25. package/lib/cjs/pino/pino.cjs.map +1 -0
  26. package/lib/cjs/text.cjs +3 -2
  27. package/lib/cjs/text.cjs.map +1 -0
  28. package/lib/cjs/time.cjs +1 -0
  29. package/lib/cjs/time.cjs.map +1 -0
  30. package/lib/cjs/types.cjs +1 -0
  31. package/lib/cjs/types.cjs.map +1 -0
  32. package/lib/cjs/utils.cjs +1 -0
  33. package/lib/cjs/utils.cjs.map +1 -0
  34. package/lib/cjs/web.cjs +1 -0
  35. package/lib/cjs/web.cjs.map +1 -0
  36. package/lib/cjs/winston/index.cjs +1 -0
  37. package/lib/cjs/winston/index.cjs.map +1 -0
  38. package/lib/cjs/winston/winston.cjs +4 -3
  39. package/lib/cjs/winston/winston.cjs.map +1 -0
  40. package/lib/esm/index.js +1 -1
  41. package/lib/types/LoggedClass.d.cts +39 -0
  42. package/lib/types/LoggedClass.d.mts +39 -0
  43. package/lib/types/constants.d.cts +104 -0
  44. package/lib/types/constants.d.mts +104 -0
  45. package/lib/types/decorators.d.cts +109 -0
  46. package/lib/types/decorators.d.mts +109 -0
  47. package/lib/types/environment.d.cts +120 -0
  48. package/lib/types/environment.d.mts +120 -0
  49. package/lib/types/filters/LogFilter.d.cts +43 -0
  50. package/lib/types/filters/LogFilter.d.mts +43 -0
  51. package/lib/types/filters/PatternFilter.d.cts +56 -0
  52. package/lib/types/filters/PatternFilter.d.mts +56 -0
  53. package/lib/types/filters/index.d.cts +7 -0
  54. package/lib/types/filters/index.d.mts +7 -0
  55. package/lib/types/index.d.cts +34 -0
  56. package/lib/types/index.d.mts +34 -0
  57. package/lib/types/logParameters.d.cts +56 -0
  58. package/lib/types/logParameters.d.mts +56 -0
  59. package/lib/types/logging.d.cts +373 -0
  60. package/lib/types/logging.d.mts +373 -0
  61. package/lib/types/pino/index.d.cts +7 -0
  62. package/lib/types/pino/index.d.mts +7 -0
  63. package/lib/types/pino/pino.d.cts +29 -0
  64. package/lib/types/pino/pino.d.mts +29 -0
  65. package/lib/types/text.d.cts +118 -0
  66. package/lib/types/text.d.mts +118 -0
  67. package/lib/types/time.d.cts +151 -0
  68. package/lib/types/time.d.mts +151 -0
  69. package/lib/types/types.d.cts +287 -0
  70. package/lib/types/types.d.mts +287 -0
  71. package/lib/types/utils.d.cts +48 -0
  72. package/lib/types/utils.d.mts +48 -0
  73. package/lib/types/web.d.cts +8 -0
  74. package/lib/types/web.d.mts +8 -0
  75. package/lib/types/winston/index.d.cts +7 -0
  76. package/lib/types/winston/index.d.mts +7 -0
  77. package/lib/types/winston/winston.d.cts +47 -0
  78. package/lib/types/winston/winston.d.mts +47 -0
  79. package/package.json +4 -4
  80. package/lib/cjs/LoggedClass.js.map +0 -1
  81. package/lib/cjs/constants.js.map +0 -1
  82. package/lib/cjs/decorators.js.map +0 -1
  83. package/lib/cjs/environment.js.map +0 -1
  84. package/lib/cjs/filters/LogFilter.js.map +0 -1
  85. package/lib/cjs/filters/PatternFilter.js.map +0 -1
  86. package/lib/cjs/filters/index.js.map +0 -1
  87. package/lib/cjs/index.js.map +0 -1
  88. package/lib/cjs/logParameters.js.map +0 -1
  89. package/lib/cjs/logging.js.map +0 -1
  90. package/lib/cjs/pino/index.js.map +0 -1
  91. package/lib/cjs/pino/pino.js.map +0 -1
  92. package/lib/cjs/text.js.map +0 -1
  93. package/lib/cjs/time.js.map +0 -1
  94. package/lib/cjs/types.js.map +0 -1
  95. package/lib/cjs/utils.js.map +0 -1
  96. package/lib/cjs/web.js.map +0 -1
  97. package/lib/cjs/winston/index.js.map +0 -1
  98. package/lib/cjs/winston/winston.js.map +0 -1
@@ -0,0 +1,104 @@
1
+ import { LoggingConfig, Theme } from "./types.cjs";
2
+ /**
3
+ * @description The global key that is used to store environment variables in browser contexts.
4
+ * @summary This enables the logging environment helpers to locate serialized environment configuration on `globalThis`.
5
+ * @const {string} BrowserEnvKey
6
+ * @memberOf module:Logging
7
+ */
8
+ export declare const BrowserEnvKey = "ENV";
9
+ /**
10
+ * @description The delimiter that is used for composing nested environment variable names.
11
+ * @summary This joins parent and child keys when mapping object paths to ENV strings.
12
+ * @const {string} ENV_PATH_DELIMITER
13
+ * @memberOf module:Logging
14
+ */
15
+ export declare const ENV_PATH_DELIMITER = "__";
16
+ /**
17
+ * @description The default prefix and suffix that are used for template placeholders.
18
+ * @summary This provides wrapper strings that are applied when interpolating messages with {@link patchPlaceholders}.
19
+ * @const {string[]} DefaultPlaceholderWrappers
20
+ * @memberOf module:Logging
21
+ */
22
+ export declare const DefaultPlaceholderWrappers: string[];
23
+ /**
24
+ * @description An enum for log levels.
25
+ * @summary Defines the different levels of logging for the application.
26
+ * @enum {string}
27
+ * @readonly
28
+ * @memberOf module:Logging
29
+ */
30
+ export declare enum LogLevel {
31
+ /** @description Benchmark events that capture performance metrics. */
32
+ benchmark = "benchmark",
33
+ /** @description Error events that indicate failures requiring attention. */
34
+ error = "error",
35
+ /** @description Warning events that may indicate issues. */
36
+ warn = "warn",
37
+ /** @description Informational events describing normal operation. */
38
+ info = "info",
39
+ /** @description Verbose diagnostic information for detailed tracing. */
40
+ verbose = "verbose",
41
+ /** @description Debug or trace details aimed at developers. */
42
+ debug = "debug",
43
+ /** @description trace details aimed at developers */
44
+ trace = "trace",
45
+ /** @description Extremely chatty or playful log entries. */
46
+ silly = "silly"
47
+ }
48
+ /**
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).
60
+ * @memberOf module:Logging
61
+ */
62
+ /**
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
66
+ * @memberOf module:Logging
67
+ */
68
+ export declare const NumericLogLevels: {
69
+ benchmark: number;
70
+ error: number;
71
+ warn: number;
72
+ info: number;
73
+ verbose: number;
74
+ debug: number;
75
+ trace: number;
76
+ silly: number;
77
+ };
78
+ /**
79
+ * @description An enum for logging output modes.
80
+ * @summary Defines the different output formats for log messages.
81
+ * @enum {string}
82
+ * @readonly
83
+ * @memberOf module:Logging
84
+ */
85
+ export declare enum LoggingMode {
86
+ /** Raw text format for human readability */
87
+ RAW = "raw",
88
+ /** JSON format for machine parsing */
89
+ JSON = "json"
90
+ }
91
+ /**
92
+ * @description The default theme for styling log output.
93
+ * @summary Defines the default color and style settings for various components of log messages.
94
+ * @const {Theme} DefaultTheme
95
+ * @memberOf module:Logging
96
+ */
97
+ export declare const DefaultTheme: Theme;
98
+ /**
99
+ * @description The default configuration for logging.
100
+ * @summary Defines the default settings for the logging system, including verbosity, log level, styling, and timestamp format.
101
+ * @const {LoggingConfig} DefaultLoggingConfig
102
+ * @memberOf module:Logging
103
+ */
104
+ export declare const DefaultLoggingConfig: LoggingConfig;
@@ -0,0 +1,104 @@
1
+ import { LoggingConfig, Theme } from "./types.js";
2
+ /**
3
+ * @description The global key that is used to store environment variables in browser contexts.
4
+ * @summary This enables the logging environment helpers to locate serialized environment configuration on `globalThis`.
5
+ * @const {string} BrowserEnvKey
6
+ * @memberOf module:Logging
7
+ */
8
+ export declare const BrowserEnvKey = "ENV";
9
+ /**
10
+ * @description The delimiter that is used for composing nested environment variable names.
11
+ * @summary This joins parent and child keys when mapping object paths to ENV strings.
12
+ * @const {string} ENV_PATH_DELIMITER
13
+ * @memberOf module:Logging
14
+ */
15
+ export declare const ENV_PATH_DELIMITER = "__";
16
+ /**
17
+ * @description The default prefix and suffix that are used for template placeholders.
18
+ * @summary This provides wrapper strings that are applied when interpolating messages with {@link patchPlaceholders}.
19
+ * @const {string[]} DefaultPlaceholderWrappers
20
+ * @memberOf module:Logging
21
+ */
22
+ export declare const DefaultPlaceholderWrappers: string[];
23
+ /**
24
+ * @description An enum for log levels.
25
+ * @summary Defines the different levels of logging for the application.
26
+ * @enum {string}
27
+ * @readonly
28
+ * @memberOf module:Logging
29
+ */
30
+ export declare enum LogLevel {
31
+ /** @description Benchmark events that capture performance metrics. */
32
+ benchmark = "benchmark",
33
+ /** @description Error events that indicate failures requiring attention. */
34
+ error = "error",
35
+ /** @description Warning events that may indicate issues. */
36
+ warn = "warn",
37
+ /** @description Informational events describing normal operation. */
38
+ info = "info",
39
+ /** @description Verbose diagnostic information for detailed tracing. */
40
+ verbose = "verbose",
41
+ /** @description Debug or trace details aimed at developers. */
42
+ debug = "debug",
43
+ /** @description trace details aimed at developers */
44
+ trace = "trace",
45
+ /** @description Extremely chatty or playful log entries. */
46
+ silly = "silly"
47
+ }
48
+ /**
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).
60
+ * @memberOf module:Logging
61
+ */
62
+ /**
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
66
+ * @memberOf module:Logging
67
+ */
68
+ export declare const NumericLogLevels: {
69
+ benchmark: number;
70
+ error: number;
71
+ warn: number;
72
+ info: number;
73
+ verbose: number;
74
+ debug: number;
75
+ trace: number;
76
+ silly: number;
77
+ };
78
+ /**
79
+ * @description An enum for logging output modes.
80
+ * @summary Defines the different output formats for log messages.
81
+ * @enum {string}
82
+ * @readonly
83
+ * @memberOf module:Logging
84
+ */
85
+ export declare enum LoggingMode {
86
+ /** Raw text format for human readability */
87
+ RAW = "raw",
88
+ /** JSON format for machine parsing */
89
+ JSON = "json"
90
+ }
91
+ /**
92
+ * @description The default theme for styling log output.
93
+ * @summary Defines the default color and style settings for various components of log messages.
94
+ * @const {Theme} DefaultTheme
95
+ * @memberOf module:Logging
96
+ */
97
+ export declare const DefaultTheme: Theme;
98
+ /**
99
+ * @description The default configuration for logging.
100
+ * @summary Defines the default settings for the logging system, including verbosity, log level, styling, and timestamp format.
101
+ * @const {LoggingConfig} DefaultLoggingConfig
102
+ * @memberOf module:Logging
103
+ */
104
+ export declare const DefaultLoggingConfig: LoggingConfig;
@@ -0,0 +1,109 @@
1
+ import { LogLevel } from "./constants.cjs";
2
+ export type ArgFormatFunction = (...args: any[]) => string;
3
+ export type ReturnFormatFunction = (e?: Error, result?: any) => string;
4
+ /**
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
+ * @function log
13
+ * @mermaid
14
+ * sequenceDiagram
15
+ * participant Client
16
+ * participant Decorator as log decorator
17
+ * participant Method as Original Method
18
+ * participant Logger as Logging instance
19
+ *
20
+ * Client->>Decorator: call decorated method
21
+ * Decorator->>Logger: log method call
22
+ * Decorator->>Method: call original method
23
+ * alt result is Promise
24
+ * Method-->>Decorator: return Promise
25
+ * Decorator->>Decorator: attach then handler
26
+ * Note over Decorator: Promise resolves
27
+ * Decorator->>Logger: log benchmark (if enabled)
28
+ * Decorator-->>Client: return result
29
+ * else result is not Promise
30
+ * Method-->>Decorator: return result
31
+ * Decorator->>Logger: log benchmark (if enabled)
32
+ * Decorator-->>Client: return result
33
+ * end
34
+ * @category Method Decorators
35
+ */
36
+ export declare function log(level?: LogLevel, verbosity?: number, entryMessage?: ArgFormatFunction, exitMessage?: ReturnFormatFunction): (target: any, propertyKey?: any, descriptor?: any) => any;
37
+ /**
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
+ * @function benchmark
42
+ * @mermaid
43
+ * sequenceDiagram
44
+ * participant Caller
45
+ * participant Decorator as benchmark
46
+ * participant Method as Original Method
47
+ * Caller->>Decorator: invoke()
48
+ * Decorator->>Method: Reflect.apply(...)
49
+ * alt Promise result
50
+ * Method-->>Decorator: Promise
51
+ * Decorator->>Decorator: attach then()
52
+ * Decorator->>Decorator: log completion duration
53
+ * else Synchronous result
54
+ * Method-->>Decorator: value
55
+ * Decorator->>Decorator: log completion duration
56
+ * end
57
+ * Decorator-->>Caller: return result
58
+ * @category Method Decorators
59
+ */
60
+ export declare function benchmark(): (target: any, propertyKey?: any, descriptor?: any) => any;
61
+ /**
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
+ * @function debug
66
+ * @category Method Decorators
67
+ */
68
+ export declare function debug(): (target: any, propertyKey?: any, descriptor?: any) => any;
69
+ /**
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
+ * @function info
74
+ * @category Method Decorators
75
+ */
76
+ export declare function info(): (target: any, propertyKey?: any, descriptor?: any) => any;
77
+ /**
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
+ * @function silly
82
+ * @category Method Decorators
83
+ */
84
+ export declare function silly(): (target: any, propertyKey?: any, descriptor?: any) => any;
85
+ /**
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
+ * @function trace
90
+ * @category Method Decorators
91
+ */
92
+ export declare function trace(): (target: any, propertyKey?: any, descriptor?: any) => any;
93
+ /**
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.
98
+ * @function verbose
99
+ * @category Method Decorators
100
+ */
101
+ export declare function verbose(verbosity?: number | boolean): (target: any, propertyKey?: any, descriptor?: any) => any;
102
+ /**
103
+ * @description Creates a decorator that makes a method non-configurable.
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.
106
+ * @function final
107
+ * @category Method Decorators
108
+ */
109
+ export declare function final(): (target: object, propertyKey?: any, descriptor?: any) => any;
@@ -0,0 +1,109 @@
1
+ import { LogLevel } from "./constants.js";
2
+ export type ArgFormatFunction = (...args: any[]) => string;
3
+ export type ReturnFormatFunction = (e?: Error, result?: any) => string;
4
+ /**
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
+ * @function log
13
+ * @mermaid
14
+ * sequenceDiagram
15
+ * participant Client
16
+ * participant Decorator as log decorator
17
+ * participant Method as Original Method
18
+ * participant Logger as Logging instance
19
+ *
20
+ * Client->>Decorator: call decorated method
21
+ * Decorator->>Logger: log method call
22
+ * Decorator->>Method: call original method
23
+ * alt result is Promise
24
+ * Method-->>Decorator: return Promise
25
+ * Decorator->>Decorator: attach then handler
26
+ * Note over Decorator: Promise resolves
27
+ * Decorator->>Logger: log benchmark (if enabled)
28
+ * Decorator-->>Client: return result
29
+ * else result is not Promise
30
+ * Method-->>Decorator: return result
31
+ * Decorator->>Logger: log benchmark (if enabled)
32
+ * Decorator-->>Client: return result
33
+ * end
34
+ * @category Method Decorators
35
+ */
36
+ export declare function log(level?: LogLevel, verbosity?: number, entryMessage?: ArgFormatFunction, exitMessage?: ReturnFormatFunction): (target: any, propertyKey?: any, descriptor?: any) => any;
37
+ /**
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
+ * @function benchmark
42
+ * @mermaid
43
+ * sequenceDiagram
44
+ * participant Caller
45
+ * participant Decorator as benchmark
46
+ * participant Method as Original Method
47
+ * Caller->>Decorator: invoke()
48
+ * Decorator->>Method: Reflect.apply(...)
49
+ * alt Promise result
50
+ * Method-->>Decorator: Promise
51
+ * Decorator->>Decorator: attach then()
52
+ * Decorator->>Decorator: log completion duration
53
+ * else Synchronous result
54
+ * Method-->>Decorator: value
55
+ * Decorator->>Decorator: log completion duration
56
+ * end
57
+ * Decorator-->>Caller: return result
58
+ * @category Method Decorators
59
+ */
60
+ export declare function benchmark(): (target: any, propertyKey?: any, descriptor?: any) => any;
61
+ /**
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
+ * @function debug
66
+ * @category Method Decorators
67
+ */
68
+ export declare function debug(): (target: any, propertyKey?: any, descriptor?: any) => any;
69
+ /**
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
+ * @function info
74
+ * @category Method Decorators
75
+ */
76
+ export declare function info(): (target: any, propertyKey?: any, descriptor?: any) => any;
77
+ /**
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
+ * @function silly
82
+ * @category Method Decorators
83
+ */
84
+ export declare function silly(): (target: any, propertyKey?: any, descriptor?: any) => any;
85
+ /**
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
+ * @function trace
90
+ * @category Method Decorators
91
+ */
92
+ export declare function trace(): (target: any, propertyKey?: any, descriptor?: any) => any;
93
+ /**
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.
98
+ * @function verbose
99
+ * @category Method Decorators
100
+ */
101
+ export declare function verbose(verbosity?: number | boolean): (target: any, propertyKey?: any, descriptor?: any) => any;
102
+ /**
103
+ * @description Creates a decorator that makes a method non-configurable.
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.
106
+ * @function final
107
+ * @category Method Decorators
108
+ */
109
+ export declare function final(): (target: object, propertyKey?: any, descriptor?: any) => any;
@@ -0,0 +1,120 @@
1
+ import { ObjectAccumulator } from "typed-object-accumulator";
2
+ /**
3
+ * @description A factory type for creating Environment instances.
4
+ * @summary This describes factories that construct {@link Environment} derivatives with custom initialization.
5
+ * @template T - The type of object the Environment will accumulate.
6
+ * @template E - The specific Environment type to be created, extending Environment<T>.
7
+ * @typedef {function(unknown[]): E} EnvironmentFactory
8
+ * @memberOf module:Logging
9
+ */
10
+ export type EnvironmentFactory<T extends object, E extends Environment<T>> = (...args: unknown[]) => E;
11
+ export type EnvironmentInstance<T extends object = any> = Environment<T> & T & {
12
+ orThrow(): EnvironmentInstance<any>;
13
+ };
14
+ export type AccumulatedEnvironment<T extends object = any> = EnvironmentInstance<T> & ObjectAccumulator<T> & {
15
+ accumulate<V extends object>(value: V): AccumulatedEnvironment<T & V>;
16
+ };
17
+ export declare class Environment<T extends object> extends ObjectAccumulator<T> {
18
+ /**
19
+ * @static
20
+ * @protected
21
+ * @description A factory function for creating Environment instances.
22
+ * @summary Defines how new instances of the Environment class should be created.
23
+ * @return {Environment<any>} A new instance of the Environment class.
24
+ */
25
+ protected static factory: EnvironmentFactory<any, any>;
26
+ /**
27
+ * @static
28
+ * @private
29
+ * @description The singleton instance of the Environment class.
30
+ * @type {Environment<any>}
31
+ */
32
+ private static _instance;
33
+ protected constructor();
34
+ /**
35
+ * @description Retrieves a value from the runtime environment.
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
+ */
40
+ protected fromEnv(k: string): unknown;
41
+ /**
42
+ * @description Converts stringified environment values into native types.
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
+ */
47
+ protected parseEnvValue(val: unknown): unknown;
48
+ private static parseRuntimeValue;
49
+ /**
50
+ * @description Expands an object into the environment.
51
+ * @summary This method defines lazy properties that first consult runtime variables before falling back to seeded values.
52
+ * @template V - The type of the object being expanded.
53
+ * @param {V} value - The object to expose through environment getters and setters.
54
+ * @return {void}
55
+ */
56
+ protected expand<V extends object>(value: V): void;
57
+ /**
58
+ * @description Returns a proxy that enforces required environment variables.
59
+ * @summary Accessing a property that resolves to `undefined` or an empty string when declared in the model will throw an error.
60
+ * @return {EnvironmentInstance<any>} A proxy of the environment that enforces required variables.
61
+ */
62
+ orThrow(): EnvironmentInstance<any>;
63
+ /**
64
+ * @protected
65
+ * @static
66
+ * @description Retrieves or creates the singleton instance of the Environment class.
67
+ * @summary This method ensures that only one {@link Environment} instance is created, and wraps it in a proxy to compose ENV keys on demand.
68
+ * @template E
69
+ * @param {...unknown[]} args - Arguments that are forwarded to the factory when instantiating the singleton.
70
+ * @return {E} The singleton environment instance.
71
+ */
72
+ protected static instance<E extends Environment<any>>(...args: unknown[]): E;
73
+ accumulate<V extends object>(value: V): AccumulatedEnvironment<T & V>;
74
+ /**
75
+ * @static
76
+ * @description Accumulates the given value into the environment.
77
+ * @summary This method adds new properties and hides raw descriptors to avoid leaking enumeration semantics.
78
+ * @template V
79
+ * @param {V} value - The object to merge into the environment.
80
+ * @return {AccumulatedEnvironment<any>} The updated environment reference.
81
+ */
82
+ static accumulate<V extends object>(value: V): AccumulatedEnvironment<any>;
83
+ /**
84
+ * @description Retrieves a value using a dot-path key from the accumulated environment.
85
+ * @summary This method delegates to the singleton instance to access stored configuration.
86
+ * @param {string} key - The key to resolve from the environment store.
87
+ * @return {unknown} The stored value that corresponds to the provided key.
88
+ */
89
+ static get(key: string): any;
90
+ private static formatEnvSegment;
91
+ private static buildEnvKey;
92
+ private static buildRawKey;
93
+ private static readRuntimeForPath;
94
+ /**
95
+ * @description Builds a proxy that composes environment keys for nested properties.
96
+ * @summary This allows chained property access to emit uppercase ENV identifiers, while honoring existing runtime overrides.
97
+ * @param {any} current - The seed model segment to use when projecting nested structures.
98
+ * @param {string[]} path - The accumulated path segments that lead to the proxy.
99
+ * @return {any} A proxy that resolves environment values or composes additional proxies for deeper paths.
100
+ */
101
+ private static buildEnvProxy;
102
+ /**
103
+ * @static
104
+ * @description Retrieves the keys of the environment, optionally converting them to ENV format.
105
+ * @summary This method gets all keys in the environment, with an option to format them for environment variables.
106
+ * @param {boolean} [toEnv=true] - Whether to convert the keys to ENV format.
107
+ * @return {string[]} An array of keys from the environment.
108
+ */
109
+ static keys(toEnv?: boolean): string[];
110
+ private static mergeModel;
111
+ private static readRuntimeEnv;
112
+ private static missingEnvError;
113
+ }
114
+ /**
115
+ * @description A singleton environment instance that is seeded with the default logging configuration.
116
+ * @summary This constant combines {@link DefaultLoggingConfig} with runtime environment variables to provide consistent logging defaults across platforms.
117
+ * @const {AccumulatedEnvironment<any>} LoggedEnvironment
118
+ * @memberOf module:Logging
119
+ */
120
+ export declare const LoggedEnvironment: any;
@@ -0,0 +1,120 @@
1
+ import { ObjectAccumulator } from "typed-object-accumulator";
2
+ /**
3
+ * @description A factory type for creating Environment instances.
4
+ * @summary This describes factories that construct {@link Environment} derivatives with custom initialization.
5
+ * @template T - The type of object the Environment will accumulate.
6
+ * @template E - The specific Environment type to be created, extending Environment<T>.
7
+ * @typedef {function(unknown[]): E} EnvironmentFactory
8
+ * @memberOf module:Logging
9
+ */
10
+ export type EnvironmentFactory<T extends object, E extends Environment<T>> = (...args: unknown[]) => E;
11
+ export type EnvironmentInstance<T extends object = any> = Environment<T> & T & {
12
+ orThrow(): EnvironmentInstance<any>;
13
+ };
14
+ export type AccumulatedEnvironment<T extends object = any> = EnvironmentInstance<T> & ObjectAccumulator<T> & {
15
+ accumulate<V extends object>(value: V): AccumulatedEnvironment<T & V>;
16
+ };
17
+ export declare class Environment<T extends object> extends ObjectAccumulator<T> {
18
+ /**
19
+ * @static
20
+ * @protected
21
+ * @description A factory function for creating Environment instances.
22
+ * @summary Defines how new instances of the Environment class should be created.
23
+ * @return {Environment<any>} A new instance of the Environment class.
24
+ */
25
+ protected static factory: EnvironmentFactory<any, any>;
26
+ /**
27
+ * @static
28
+ * @private
29
+ * @description The singleton instance of the Environment class.
30
+ * @type {Environment<any>}
31
+ */
32
+ private static _instance;
33
+ protected constructor();
34
+ /**
35
+ * @description Retrieves a value from the runtime environment.
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
+ */
40
+ protected fromEnv(k: string): unknown;
41
+ /**
42
+ * @description Converts stringified environment values into native types.
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
+ */
47
+ protected parseEnvValue(val: unknown): unknown;
48
+ private static parseRuntimeValue;
49
+ /**
50
+ * @description Expands an object into the environment.
51
+ * @summary This method defines lazy properties that first consult runtime variables before falling back to seeded values.
52
+ * @template V - The type of the object being expanded.
53
+ * @param {V} value - The object to expose through environment getters and setters.
54
+ * @return {void}
55
+ */
56
+ protected expand<V extends object>(value: V): void;
57
+ /**
58
+ * @description Returns a proxy that enforces required environment variables.
59
+ * @summary Accessing a property that resolves to `undefined` or an empty string when declared in the model will throw an error.
60
+ * @return {EnvironmentInstance<any>} A proxy of the environment that enforces required variables.
61
+ */
62
+ orThrow(): EnvironmentInstance<any>;
63
+ /**
64
+ * @protected
65
+ * @static
66
+ * @description Retrieves or creates the singleton instance of the Environment class.
67
+ * @summary This method ensures that only one {@link Environment} instance is created, and wraps it in a proxy to compose ENV keys on demand.
68
+ * @template E
69
+ * @param {...unknown[]} args - Arguments that are forwarded to the factory when instantiating the singleton.
70
+ * @return {E} The singleton environment instance.
71
+ */
72
+ protected static instance<E extends Environment<any>>(...args: unknown[]): E;
73
+ accumulate<V extends object>(value: V): AccumulatedEnvironment<T & V>;
74
+ /**
75
+ * @static
76
+ * @description Accumulates the given value into the environment.
77
+ * @summary This method adds new properties and hides raw descriptors to avoid leaking enumeration semantics.
78
+ * @template V
79
+ * @param {V} value - The object to merge into the environment.
80
+ * @return {AccumulatedEnvironment<any>} The updated environment reference.
81
+ */
82
+ static accumulate<V extends object>(value: V): AccumulatedEnvironment<any>;
83
+ /**
84
+ * @description Retrieves a value using a dot-path key from the accumulated environment.
85
+ * @summary This method delegates to the singleton instance to access stored configuration.
86
+ * @param {string} key - The key to resolve from the environment store.
87
+ * @return {unknown} The stored value that corresponds to the provided key.
88
+ */
89
+ static get(key: string): any;
90
+ private static formatEnvSegment;
91
+ private static buildEnvKey;
92
+ private static buildRawKey;
93
+ private static readRuntimeForPath;
94
+ /**
95
+ * @description Builds a proxy that composes environment keys for nested properties.
96
+ * @summary This allows chained property access to emit uppercase ENV identifiers, while honoring existing runtime overrides.
97
+ * @param {any} current - The seed model segment to use when projecting nested structures.
98
+ * @param {string[]} path - The accumulated path segments that lead to the proxy.
99
+ * @return {any} A proxy that resolves environment values or composes additional proxies for deeper paths.
100
+ */
101
+ private static buildEnvProxy;
102
+ /**
103
+ * @static
104
+ * @description Retrieves the keys of the environment, optionally converting them to ENV format.
105
+ * @summary This method gets all keys in the environment, with an option to format them for environment variables.
106
+ * @param {boolean} [toEnv=true] - Whether to convert the keys to ENV format.
107
+ * @return {string[]} An array of keys from the environment.
108
+ */
109
+ static keys(toEnv?: boolean): string[];
110
+ private static mergeModel;
111
+ private static readRuntimeEnv;
112
+ private static missingEnvError;
113
+ }
114
+ /**
115
+ * @description A singleton environment instance that is seeded with the default logging configuration.
116
+ * @summary This constant combines {@link DefaultLoggingConfig} with runtime environment variables to provide consistent logging defaults across platforms.
117
+ * @const {AccumulatedEnvironment<any>} LoggedEnvironment
118
+ * @memberOf module:Logging
119
+ */
120
+ export declare const LoggedEnvironment: any;