@decaf-ts/logging 0.15.0 → 0.16.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 +1 -1
  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,287 @@
1
+ import { styles } from "styled-string-builder";
2
+ import { LoggingMode, LogLevel } from "./constants.cjs";
3
+ /**
4
+ * @description A string-compatible value that can be accepted by the logging APIs.
5
+ * @summary Represents either a literal string or an object that has a `toString()` method. This allows for the lazy stringification of complex payloads.
6
+ * @typedef {(string|Object)} StringLike
7
+ * @memberOf module:Logging
8
+ */
9
+ export type StringLike = string | {
10
+ toString: () => string;
11
+ };
12
+ export type LogMeta = Record<string, unknown>;
13
+ /**
14
+ * @description A generic function signature for loosely typed callbacks.
15
+ * @summary This type covers variadic functions where the arguments and return types are not constrained, which enables the logging layer to accept any callable.
16
+ * @typedef {function(...any[]): any} AnyFunction
17
+ * @memberOf module:Logging
18
+ */
19
+ export type AnyFunction = (...args: any[]) => any;
20
+ /**
21
+ * @description A constructable class type.
22
+ * @summary Describes a constructor that produces instances of type `T`. This allows APIs to accept class references for context-aware logging.
23
+ * @template T
24
+ * @typedef Class
25
+ * @memberOf module:Logging
26
+ */
27
+ export type Class<T> = {
28
+ new (...args: any[]): T;
29
+ };
30
+ /**
31
+ * @description A context descriptor that is accepted when requesting a logger instance.
32
+ * @summary Allows the logging system to resolve context names from strings, constructors, or functions.
33
+ * @typedef {(string|Class<any>|AnyFunction)} LoggingContext
34
+ * @memberOf module:Logging
35
+ */
36
+ export type LoggingContext = string | Class<any> | AnyFunction;
37
+ /**
38
+ * @description An interface for factories that create contextual clones of the receiver.
39
+ * @summary Declares a `for` method that returns another instance of `THIS` using the provided arguments. This enables chained logger customization.
40
+ * @template THIS
41
+ * @template ARGS
42
+ * @interface Impersonatable
43
+ * @memberOf module:Logging
44
+ */
45
+ export interface Impersonatable<THIS, ARGS extends any[] = any[]> {
46
+ /**
47
+ * @description Produce a copy of the current instance with altered context.
48
+ * @summary Called by logging utilities to derive child objects with supplemental configuration and context metadata.
49
+ * @param {ARGS} args - Arguments forwarded to the impersonation strategy.
50
+ * @return {THIS} Derived instance using the provided arguments.
51
+ */
52
+ for(...args: ARGS): THIS;
53
+ }
54
+ /**
55
+ * @description An interface for loggers that support multiple verbosity levels.
56
+ * @summary This interface declares severity-specific log methods, configuration overrides, and factory helpers that are used throughout the logging toolkit.
57
+ * @interface Logger
58
+ * @memberOf module:Logging
59
+ */
60
+ export interface Logger extends Impersonatable<Logger, [
61
+ (string | {
62
+ new (...args: any[]): any;
63
+ } | AnyFunction | Partial<LoggingConfig>),
64
+ Partial<LoggingConfig>,
65
+ ...any[]
66
+ ]> {
67
+ /**
68
+ * @description Logs a benchmark message.
69
+ * @summary Emits high-frequency performance metrics at the `benchmark` log level.
70
+ * @param {StringLike} msg - Message or payload to emit.
71
+ * @return {void}
72
+ */
73
+ benchmark(msg: StringLike, meta?: LogMeta): void;
74
+ /**
75
+ * @description Logs a `way too verbose` or a silly message.
76
+ * @summary Emits playful or extremely verbose details at the `silly` log level.
77
+ * @param {StringLike} msg - Message or payload to emit.
78
+ * @return {void}
79
+ */
80
+ silly(msg: StringLike, verbosity?: number | LogMeta, meta?: LogMeta): void;
81
+ /**
82
+ * @description Logs developer trace messages.
83
+ * @summary Emits playful or extremely verbose details at the `silly` log level.
84
+ * @param {StringLike} msg - Message or payload to emit.
85
+ * @return {void}
86
+ */
87
+ trace(msg: StringLike, meta?: LogMeta): void;
88
+ /**
89
+ * @description Logs a verbose message.
90
+ * @summary Writes diagnostic output governed by the configured verbosity threshold.
91
+ * @param {StringLike} msg - Message or payload to emit.
92
+ * @param {number} [verbosity] - Verbosity level required for the message to pass through.
93
+ * @return {void}
94
+ */
95
+ verbose(msg: StringLike, verbosityOrMeta?: number | LogMeta, meta?: LogMeta): void;
96
+ /**
97
+ * @description Logs an info message.
98
+ * @summary Emits general informational events that describe application progress.
99
+ * @param {StringLike} msg - Message or payload to emit.
100
+ * @return {void}
101
+ */
102
+ info(msg: StringLike, meta?: LogMeta): void;
103
+ /**
104
+ * @description Logs an error message.
105
+ * @summary Records errors and exceptions, including optional stack traces.
106
+ * @param {StringLike|Error} msg - Message or {@link Error} instance to log.
107
+ * @param {Error} [e] - Optional secondary error or cause.
108
+ * @return {void}
109
+ */
110
+ error(msg: StringLike | Error, error?: Error | LogMeta, meta?: LogMeta): void;
111
+ /**
112
+ * @description Logs a debug message.
113
+ * @summary Emits fine-grained diagnostic details useful during development and troubleshooting.
114
+ * @param {StringLike} msg - Message or payload to emit.
115
+ * @return {void}
116
+ */
117
+ debug(msg: StringLike, meta?: LogMeta): void;
118
+ /**
119
+ * @description Logs a debug message.
120
+ * @summary Emits fine-grained diagnostic details useful during development and troubleshooting.
121
+ * @param {StringLike} msg - Message or payload to emit.
122
+ * @return {void}
123
+ */
124
+ warn(msg: StringLike, meta?: LogMeta): void;
125
+ /**
126
+ * @description Creates a new logger for a specific method or context.
127
+ * @summary Produces a scoped logger that formats entries using the derived context and overrides supplied configuration.
128
+ * @param {any} method - Method name, callback, constructor, or partial configuration used to seed the child logger.
129
+ * @param {Partial<LoggingConfig>} [config] - Optional configuration overrides for the child logger.
130
+ * @param {...any[]} args - Extra arguments forwarded to factory implementations.
131
+ * @return {Logger} Logger instance tailored to the supplied context.
132
+ */
133
+ for(config: Partial<LoggingConfig>): this;
134
+ for(context: string | {
135
+ new (...args: any[]): any;
136
+ } | AnyFunction | object): this;
137
+ for(method: string | {
138
+ new (...args: any[]): any;
139
+ } | AnyFunction | object | Partial<LoggingConfig>, config?: Partial<LoggingConfig>, ...args: any[]): this;
140
+ /**
141
+ * @description Clears any contextual overrides applied via {@link Logger.for}.
142
+ * @summary Resets temporary context/configuration so ensuing chains start from the base logger while preserving the concrete instance type.
143
+ * @return {this} The same logger instance to continue chaining.
144
+ */
145
+ clear(): this;
146
+ /**
147
+ * @description Updates the logger configuration.
148
+ * @summary Merges the given options into the logger's existing configuration.
149
+ * @param {Partial<LoggingConfig>} config - Configuration overrides to apply.
150
+ * @return {void}
151
+ */
152
+ setConfig(config: Partial<LoggingConfig>): void;
153
+ /**
154
+ * @description Immutable base context for the logger instance.
155
+ * @summary Returned as a copy so callers cannot mutate the internal base context while still allowing inspection.
156
+ */
157
+ readonly root: string[];
158
+ }
159
+ /**
160
+ * @description An interface for filters that can mutate or reject log messages.
161
+ * @summary This allows for custom pre-processing of log entries before they are formatted or emitted.
162
+ * @interface LoggingFilter
163
+ * @memberOf module:Logging
164
+ */
165
+ export interface LoggingFilter {
166
+ /**
167
+ * @description Apply filtering logic to an incoming message.
168
+ * @summary Receives the active configuration, original message, and context stack to produce the final message string.
169
+ * @param {LoggingConfig} config - Active logging configuration.
170
+ * @param {string} message - Message submitted for logging.
171
+ * @param {string[]} context - Context identifiers associated with the message.
172
+ * @return {string} Filtered message string.
173
+ */
174
+ filter(config: LoggingConfig, message: string, context: string[]): string;
175
+ }
176
+ /**
177
+ * @description Configuration for the logging system.
178
+ * @summary Defines the log level, verbosity, and other settings for logging.
179
+ * @template TRANSPORT
180
+ * @typedef {object} LoggingConfig
181
+ * @property {string} env - The environment, e.g., "development", "production".
182
+ * @property {LogLevel} level - The logging level.
183
+ * @property {boolean} [logLevel] - Whether to display the log level in the output.
184
+ * @property {number} verbose - The verbosity level.
185
+ * @property {string} contextSeparator - The separator to use between context entries.
186
+ * @property {string} separator - The separator to use between log components.
187
+ * @property {boolean} [style] - Whether to apply styling to the log output.
188
+ * @property {boolean} [timestamp] - Whether to include timestamps in log messages.
189
+ * @property {string} [timestampFormat] - The format for timestamps.
190
+ * @property {boolean} [context] - Whether to include context information in log messages.
191
+ * @property {Theme} [theme] - The theme to use for styling log messages.
192
+ * @property {LoggingMode} format - The output format for log messages.
193
+ * @property {string} pattern - The pattern to use for formatting log messages.
194
+ * @property {(string|number)} [correlationId] - A correlation ID for tracking related log messages.
195
+ * @property {(string[]|LoggingFilter[])} [filters] - An array of filters to apply to log messages.
196
+ * @property {TRANSPORT[]} [transports] - An array of transports to use for logging.
197
+ * @memberOf module:Logging
198
+ */
199
+ export type LoggingConfig<TRANSPORT = object> = {
200
+ env: "development" | "production" | "test" | "staging" | string;
201
+ level: LogLevel;
202
+ logLevel?: boolean;
203
+ verbose: number;
204
+ contextSeparator: string;
205
+ separator: string;
206
+ style?: boolean;
207
+ timestamp?: boolean;
208
+ timestampFormat?: string;
209
+ context?: boolean;
210
+ meta?: boolean;
211
+ theme?: Theme;
212
+ format: LoggingMode;
213
+ pattern: string;
214
+ correlationId?: string | number;
215
+ filters?: string[] | LoggingFilter[];
216
+ transports?: TRANSPORT[];
217
+ };
218
+ /**
219
+ * @description A factory signature for creating logger instances.
220
+ * @summary This allows consumers to override the logger construction with custom implementations.
221
+ * @template L
222
+ * @typedef {function(string, Partial<LoggingConfig>, ...any[]): L} LoggerFactory
223
+ * @memberOf module:Logging
224
+ */
225
+ export type LoggerFactory<L extends Logger = Logger> = (object?: string, config?: Partial<LoggingConfig>, ...args: any[]) => L;
226
+ /**
227
+ * @description A theme option that is applied to a specific log element.
228
+ * @summary This interface configures the foreground and background colors, as well as additional style directives for styled console output.
229
+ * @interface ThemeOption
230
+ * @memberOf module:Logging
231
+ */
232
+ export interface ThemeOption {
233
+ fg?: number | [number] | [number, number, number];
234
+ bg?: number | [number] | [number, number, number];
235
+ style?: number[] | [keyof typeof styles];
236
+ }
237
+ /**
238
+ * @description A mapping between log levels and theme overrides.
239
+ * @summary This enables level-specific styling by associating each {@link LogLevel} with a {@link ThemeOption} configuration.
240
+ * @typedef {Partial<Record<LogLevel, ThemeOption>>} ThemeOptionByLogLevel
241
+ * @memberOf module:Logging
242
+ */
243
+ export type ThemeOptionByLogLevel = Partial<Record<LogLevel, ThemeOption>>;
244
+ /**
245
+ * @description A theme definition that is applied to the console output.
246
+ * @summary This interface specifies the styling for each console log element and supports overrides based on {@link LogLevel} values.
247
+ * @interface Theme
248
+ * @memberOf module:Logging
249
+ */
250
+ export interface Theme {
251
+ /**
252
+ * @description Styling for application identifiers in the output.
253
+ */
254
+ app: ThemeOption | ThemeOptionByLogLevel;
255
+ /**
256
+ * @description Styling for separators inserted between log sections.
257
+ */
258
+ separator: ThemeOption | ThemeOptionByLogLevel;
259
+ /**
260
+ * @description Styling for class names in the output.
261
+ */
262
+ class: ThemeOption | ThemeOptionByLogLevel;
263
+ /**
264
+ * @description Styling for timestamps in the output.
265
+ */
266
+ timestamp: ThemeOption | ThemeOptionByLogLevel;
267
+ /**
268
+ * @description Styling for the main message text in the output.
269
+ */
270
+ message: ThemeOption | ThemeOptionByLogLevel;
271
+ /**
272
+ * @description Styling for method names in the output.
273
+ */
274
+ method: ThemeOption | ThemeOptionByLogLevel;
275
+ /**
276
+ * @description Styling for identifier elements in the output.
277
+ */
278
+ id: ThemeOption | ThemeOptionByLogLevel;
279
+ /**
280
+ * @description Styling for stack trace blocks in the output.
281
+ */
282
+ stack: ThemeOption;
283
+ /**
284
+ * @description Styling overrides keyed by {@link LogLevel}.
285
+ */
286
+ logLevel: ThemeOptionByLogLevel;
287
+ }
@@ -0,0 +1,287 @@
1
+ import { styles } from "styled-string-builder";
2
+ import { LoggingMode, LogLevel } from "./constants.js";
3
+ /**
4
+ * @description A string-compatible value that can be accepted by the logging APIs.
5
+ * @summary Represents either a literal string or an object that has a `toString()` method. This allows for the lazy stringification of complex payloads.
6
+ * @typedef {(string|Object)} StringLike
7
+ * @memberOf module:Logging
8
+ */
9
+ export type StringLike = string | {
10
+ toString: () => string;
11
+ };
12
+ export type LogMeta = Record<string, unknown>;
13
+ /**
14
+ * @description A generic function signature for loosely typed callbacks.
15
+ * @summary This type covers variadic functions where the arguments and return types are not constrained, which enables the logging layer to accept any callable.
16
+ * @typedef {function(...any[]): any} AnyFunction
17
+ * @memberOf module:Logging
18
+ */
19
+ export type AnyFunction = (...args: any[]) => any;
20
+ /**
21
+ * @description A constructable class type.
22
+ * @summary Describes a constructor that produces instances of type `T`. This allows APIs to accept class references for context-aware logging.
23
+ * @template T
24
+ * @typedef Class
25
+ * @memberOf module:Logging
26
+ */
27
+ export type Class<T> = {
28
+ new (...args: any[]): T;
29
+ };
30
+ /**
31
+ * @description A context descriptor that is accepted when requesting a logger instance.
32
+ * @summary Allows the logging system to resolve context names from strings, constructors, or functions.
33
+ * @typedef {(string|Class<any>|AnyFunction)} LoggingContext
34
+ * @memberOf module:Logging
35
+ */
36
+ export type LoggingContext = string | Class<any> | AnyFunction;
37
+ /**
38
+ * @description An interface for factories that create contextual clones of the receiver.
39
+ * @summary Declares a `for` method that returns another instance of `THIS` using the provided arguments. This enables chained logger customization.
40
+ * @template THIS
41
+ * @template ARGS
42
+ * @interface Impersonatable
43
+ * @memberOf module:Logging
44
+ */
45
+ export interface Impersonatable<THIS, ARGS extends any[] = any[]> {
46
+ /**
47
+ * @description Produce a copy of the current instance with altered context.
48
+ * @summary Called by logging utilities to derive child objects with supplemental configuration and context metadata.
49
+ * @param {ARGS} args - Arguments forwarded to the impersonation strategy.
50
+ * @return {THIS} Derived instance using the provided arguments.
51
+ */
52
+ for(...args: ARGS): THIS;
53
+ }
54
+ /**
55
+ * @description An interface for loggers that support multiple verbosity levels.
56
+ * @summary This interface declares severity-specific log methods, configuration overrides, and factory helpers that are used throughout the logging toolkit.
57
+ * @interface Logger
58
+ * @memberOf module:Logging
59
+ */
60
+ export interface Logger extends Impersonatable<Logger, [
61
+ (string | {
62
+ new (...args: any[]): any;
63
+ } | AnyFunction | Partial<LoggingConfig>),
64
+ Partial<LoggingConfig>,
65
+ ...any[]
66
+ ]> {
67
+ /**
68
+ * @description Logs a benchmark message.
69
+ * @summary Emits high-frequency performance metrics at the `benchmark` log level.
70
+ * @param {StringLike} msg - Message or payload to emit.
71
+ * @return {void}
72
+ */
73
+ benchmark(msg: StringLike, meta?: LogMeta): void;
74
+ /**
75
+ * @description Logs a `way too verbose` or a silly message.
76
+ * @summary Emits playful or extremely verbose details at the `silly` log level.
77
+ * @param {StringLike} msg - Message or payload to emit.
78
+ * @return {void}
79
+ */
80
+ silly(msg: StringLike, verbosity?: number | LogMeta, meta?: LogMeta): void;
81
+ /**
82
+ * @description Logs developer trace messages.
83
+ * @summary Emits playful or extremely verbose details at the `silly` log level.
84
+ * @param {StringLike} msg - Message or payload to emit.
85
+ * @return {void}
86
+ */
87
+ trace(msg: StringLike, meta?: LogMeta): void;
88
+ /**
89
+ * @description Logs a verbose message.
90
+ * @summary Writes diagnostic output governed by the configured verbosity threshold.
91
+ * @param {StringLike} msg - Message or payload to emit.
92
+ * @param {number} [verbosity] - Verbosity level required for the message to pass through.
93
+ * @return {void}
94
+ */
95
+ verbose(msg: StringLike, verbosityOrMeta?: number | LogMeta, meta?: LogMeta): void;
96
+ /**
97
+ * @description Logs an info message.
98
+ * @summary Emits general informational events that describe application progress.
99
+ * @param {StringLike} msg - Message or payload to emit.
100
+ * @return {void}
101
+ */
102
+ info(msg: StringLike, meta?: LogMeta): void;
103
+ /**
104
+ * @description Logs an error message.
105
+ * @summary Records errors and exceptions, including optional stack traces.
106
+ * @param {StringLike|Error} msg - Message or {@link Error} instance to log.
107
+ * @param {Error} [e] - Optional secondary error or cause.
108
+ * @return {void}
109
+ */
110
+ error(msg: StringLike | Error, error?: Error | LogMeta, meta?: LogMeta): void;
111
+ /**
112
+ * @description Logs a debug message.
113
+ * @summary Emits fine-grained diagnostic details useful during development and troubleshooting.
114
+ * @param {StringLike} msg - Message or payload to emit.
115
+ * @return {void}
116
+ */
117
+ debug(msg: StringLike, meta?: LogMeta): void;
118
+ /**
119
+ * @description Logs a debug message.
120
+ * @summary Emits fine-grained diagnostic details useful during development and troubleshooting.
121
+ * @param {StringLike} msg - Message or payload to emit.
122
+ * @return {void}
123
+ */
124
+ warn(msg: StringLike, meta?: LogMeta): void;
125
+ /**
126
+ * @description Creates a new logger for a specific method or context.
127
+ * @summary Produces a scoped logger that formats entries using the derived context and overrides supplied configuration.
128
+ * @param {any} method - Method name, callback, constructor, or partial configuration used to seed the child logger.
129
+ * @param {Partial<LoggingConfig>} [config] - Optional configuration overrides for the child logger.
130
+ * @param {...any[]} args - Extra arguments forwarded to factory implementations.
131
+ * @return {Logger} Logger instance tailored to the supplied context.
132
+ */
133
+ for(config: Partial<LoggingConfig>): this;
134
+ for(context: string | {
135
+ new (...args: any[]): any;
136
+ } | AnyFunction | object): this;
137
+ for(method: string | {
138
+ new (...args: any[]): any;
139
+ } | AnyFunction | object | Partial<LoggingConfig>, config?: Partial<LoggingConfig>, ...args: any[]): this;
140
+ /**
141
+ * @description Clears any contextual overrides applied via {@link Logger.for}.
142
+ * @summary Resets temporary context/configuration so ensuing chains start from the base logger while preserving the concrete instance type.
143
+ * @return {this} The same logger instance to continue chaining.
144
+ */
145
+ clear(): this;
146
+ /**
147
+ * @description Updates the logger configuration.
148
+ * @summary Merges the given options into the logger's existing configuration.
149
+ * @param {Partial<LoggingConfig>} config - Configuration overrides to apply.
150
+ * @return {void}
151
+ */
152
+ setConfig(config: Partial<LoggingConfig>): void;
153
+ /**
154
+ * @description Immutable base context for the logger instance.
155
+ * @summary Returned as a copy so callers cannot mutate the internal base context while still allowing inspection.
156
+ */
157
+ readonly root: string[];
158
+ }
159
+ /**
160
+ * @description An interface for filters that can mutate or reject log messages.
161
+ * @summary This allows for custom pre-processing of log entries before they are formatted or emitted.
162
+ * @interface LoggingFilter
163
+ * @memberOf module:Logging
164
+ */
165
+ export interface LoggingFilter {
166
+ /**
167
+ * @description Apply filtering logic to an incoming message.
168
+ * @summary Receives the active configuration, original message, and context stack to produce the final message string.
169
+ * @param {LoggingConfig} config - Active logging configuration.
170
+ * @param {string} message - Message submitted for logging.
171
+ * @param {string[]} context - Context identifiers associated with the message.
172
+ * @return {string} Filtered message string.
173
+ */
174
+ filter(config: LoggingConfig, message: string, context: string[]): string;
175
+ }
176
+ /**
177
+ * @description Configuration for the logging system.
178
+ * @summary Defines the log level, verbosity, and other settings for logging.
179
+ * @template TRANSPORT
180
+ * @typedef {object} LoggingConfig
181
+ * @property {string} env - The environment, e.g., "development", "production".
182
+ * @property {LogLevel} level - The logging level.
183
+ * @property {boolean} [logLevel] - Whether to display the log level in the output.
184
+ * @property {number} verbose - The verbosity level.
185
+ * @property {string} contextSeparator - The separator to use between context entries.
186
+ * @property {string} separator - The separator to use between log components.
187
+ * @property {boolean} [style] - Whether to apply styling to the log output.
188
+ * @property {boolean} [timestamp] - Whether to include timestamps in log messages.
189
+ * @property {string} [timestampFormat] - The format for timestamps.
190
+ * @property {boolean} [context] - Whether to include context information in log messages.
191
+ * @property {Theme} [theme] - The theme to use for styling log messages.
192
+ * @property {LoggingMode} format - The output format for log messages.
193
+ * @property {string} pattern - The pattern to use for formatting log messages.
194
+ * @property {(string|number)} [correlationId] - A correlation ID for tracking related log messages.
195
+ * @property {(string[]|LoggingFilter[])} [filters] - An array of filters to apply to log messages.
196
+ * @property {TRANSPORT[]} [transports] - An array of transports to use for logging.
197
+ * @memberOf module:Logging
198
+ */
199
+ export type LoggingConfig<TRANSPORT = object> = {
200
+ env: "development" | "production" | "test" | "staging" | string;
201
+ level: LogLevel;
202
+ logLevel?: boolean;
203
+ verbose: number;
204
+ contextSeparator: string;
205
+ separator: string;
206
+ style?: boolean;
207
+ timestamp?: boolean;
208
+ timestampFormat?: string;
209
+ context?: boolean;
210
+ meta?: boolean;
211
+ theme?: Theme;
212
+ format: LoggingMode;
213
+ pattern: string;
214
+ correlationId?: string | number;
215
+ filters?: string[] | LoggingFilter[];
216
+ transports?: TRANSPORT[];
217
+ };
218
+ /**
219
+ * @description A factory signature for creating logger instances.
220
+ * @summary This allows consumers to override the logger construction with custom implementations.
221
+ * @template L
222
+ * @typedef {function(string, Partial<LoggingConfig>, ...any[]): L} LoggerFactory
223
+ * @memberOf module:Logging
224
+ */
225
+ export type LoggerFactory<L extends Logger = Logger> = (object?: string, config?: Partial<LoggingConfig>, ...args: any[]) => L;
226
+ /**
227
+ * @description A theme option that is applied to a specific log element.
228
+ * @summary This interface configures the foreground and background colors, as well as additional style directives for styled console output.
229
+ * @interface ThemeOption
230
+ * @memberOf module:Logging
231
+ */
232
+ export interface ThemeOption {
233
+ fg?: number | [number] | [number, number, number];
234
+ bg?: number | [number] | [number, number, number];
235
+ style?: number[] | [keyof typeof styles];
236
+ }
237
+ /**
238
+ * @description A mapping between log levels and theme overrides.
239
+ * @summary This enables level-specific styling by associating each {@link LogLevel} with a {@link ThemeOption} configuration.
240
+ * @typedef {Partial<Record<LogLevel, ThemeOption>>} ThemeOptionByLogLevel
241
+ * @memberOf module:Logging
242
+ */
243
+ export type ThemeOptionByLogLevel = Partial<Record<LogLevel, ThemeOption>>;
244
+ /**
245
+ * @description A theme definition that is applied to the console output.
246
+ * @summary This interface specifies the styling for each console log element and supports overrides based on {@link LogLevel} values.
247
+ * @interface Theme
248
+ * @memberOf module:Logging
249
+ */
250
+ export interface Theme {
251
+ /**
252
+ * @description Styling for application identifiers in the output.
253
+ */
254
+ app: ThemeOption | ThemeOptionByLogLevel;
255
+ /**
256
+ * @description Styling for separators inserted between log sections.
257
+ */
258
+ separator: ThemeOption | ThemeOptionByLogLevel;
259
+ /**
260
+ * @description Styling for class names in the output.
261
+ */
262
+ class: ThemeOption | ThemeOptionByLogLevel;
263
+ /**
264
+ * @description Styling for timestamps in the output.
265
+ */
266
+ timestamp: ThemeOption | ThemeOptionByLogLevel;
267
+ /**
268
+ * @description Styling for the main message text in the output.
269
+ */
270
+ message: ThemeOption | ThemeOptionByLogLevel;
271
+ /**
272
+ * @description Styling for method names in the output.
273
+ */
274
+ method: ThemeOption | ThemeOptionByLogLevel;
275
+ /**
276
+ * @description Styling for identifier elements in the output.
277
+ */
278
+ id: ThemeOption | ThemeOptionByLogLevel;
279
+ /**
280
+ * @description Styling for stack trace blocks in the output.
281
+ */
282
+ stack: ThemeOption;
283
+ /**
284
+ * @description Styling overrides keyed by {@link LogLevel}.
285
+ */
286
+ logLevel: ThemeOptionByLogLevel;
287
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @description Checks if a value is a class.
3
+ * @summary This function determines if the given value is a class constructor.
4
+ * @param {unknown} value - The value to check.
5
+ * @return {boolean} `true` if the value is a class, `false` otherwise.
6
+ * @function isClass
7
+ * @memberOf module:Logging
8
+ */
9
+ export declare function isClass(value: unknown): value is abstract new (...args: any[]) => any;
10
+ /**
11
+ * @description Checks if a value is a function.
12
+ * @summary This function determines if the given value is a function, but not a class.
13
+ * @template T
14
+ * @param {unknown} value - The value to check.
15
+ * @return {boolean} `true` if the value is a function, `false` otherwise.
16
+ * @function isFunction
17
+ * @memberOf module:Logging
18
+ */
19
+ export declare function isFunction<T extends (...args: any[]) => unknown>(value: unknown): value is T;
20
+ /**
21
+ * @description Checks if a value is a method.
22
+ * @summary This function determines if the given value is a method.
23
+ * @template T
24
+ * @param {unknown} value - The value to check.
25
+ * @return {boolean} `true` if the value is a method, `false` otherwise.
26
+ * @function isMethod
27
+ * @memberOf module:Logging
28
+ */
29
+ export declare function isMethod<T extends (...args: any[]) => unknown>(value: unknown): value is T;
30
+ /**
31
+ * @description Checks if a value is an instance of a class.
32
+ * @summary This function determines if the given value is an instance of a class.
33
+ * @template T
34
+ * @param {unknown} value - The value to check.
35
+ * @return {boolean} `true` if the value is an instance of a class, `false` otherwise.
36
+ * @function isInstance
37
+ * @memberOf module:Logging
38
+ */
39
+ export declare function isInstance<T extends object>(value: unknown): value is T;
40
+ /**
41
+ * @description Gets the name of an object.
42
+ * @summary This function returns the name of the given object, which can be a class, an instance of a class, a function, or a primitive value.
43
+ * @param {unknown} value - The value to get the name of.
44
+ * @return {string} The name of the object.
45
+ * @function getObjectName
46
+ * @memberOf module:Logging
47
+ */
48
+ export declare function getObjectName(value: unknown): string;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @description Checks if a value is a class.
3
+ * @summary This function determines if the given value is a class constructor.
4
+ * @param {unknown} value - The value to check.
5
+ * @return {boolean} `true` if the value is a class, `false` otherwise.
6
+ * @function isClass
7
+ * @memberOf module:Logging
8
+ */
9
+ export declare function isClass(value: unknown): value is abstract new (...args: any[]) => any;
10
+ /**
11
+ * @description Checks if a value is a function.
12
+ * @summary This function determines if the given value is a function, but not a class.
13
+ * @template T
14
+ * @param {unknown} value - The value to check.
15
+ * @return {boolean} `true` if the value is a function, `false` otherwise.
16
+ * @function isFunction
17
+ * @memberOf module:Logging
18
+ */
19
+ export declare function isFunction<T extends (...args: any[]) => unknown>(value: unknown): value is T;
20
+ /**
21
+ * @description Checks if a value is a method.
22
+ * @summary This function determines if the given value is a method.
23
+ * @template T
24
+ * @param {unknown} value - The value to check.
25
+ * @return {boolean} `true` if the value is a method, `false` otherwise.
26
+ * @function isMethod
27
+ * @memberOf module:Logging
28
+ */
29
+ export declare function isMethod<T extends (...args: any[]) => unknown>(value: unknown): value is T;
30
+ /**
31
+ * @description Checks if a value is an instance of a class.
32
+ * @summary This function determines if the given value is an instance of a class.
33
+ * @template T
34
+ * @param {unknown} value - The value to check.
35
+ * @return {boolean} `true` if the value is an instance of a class, `false` otherwise.
36
+ * @function isInstance
37
+ * @memberOf module:Logging
38
+ */
39
+ export declare function isInstance<T extends object>(value: unknown): value is T;
40
+ /**
41
+ * @description Gets the name of an object.
42
+ * @summary This function returns the name of the given object, which can be a class, an instance of a class, a function, or a primitive value.
43
+ * @param {unknown} value - The value to get the name of.
44
+ * @return {string} The name of the object.
45
+ * @function getObjectName
46
+ * @memberOf module:Logging
47
+ */
48
+ export declare function getObjectName(value: unknown): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @description Determines if the current environment is a browser by checking the prototype chain of the global object.
3
+ * @summary This function checks if the code is running in a browser environment.
4
+ * @return {boolean} `true` if the environment is a browser, `false` otherwise.
5
+ * @function isBrowser
6
+ * @memberOf module:Logging
7
+ */
8
+ export declare function isBrowser(): boolean;