@decaf-ts/logging 0.20.0 → 0.21.1

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 (71) hide show
  1. package/README.md +1 -1
  2. package/dist/logging.cjs +1 -1
  3. package/dist/logging.cjs.map +1 -1
  4. package/dist/logging.js +1 -1
  5. package/dist/logging.js.map +1 -1
  6. package/lib/cjs/constants.cjs +16 -0
  7. package/lib/cjs/constants.cjs.map +1 -1
  8. package/lib/cjs/index.cjs +1 -1
  9. package/lib/cjs/logging.cjs +67 -3
  10. package/lib/cjs/logging.cjs.map +1 -1
  11. package/lib/cjs/pino/pino.cjs +3 -1
  12. package/lib/cjs/pino/pino.cjs.map +1 -1
  13. package/lib/cjs/winston/winston.cjs +15 -1
  14. package/lib/cjs/winston/winston.cjs.map +1 -1
  15. package/lib/esm/constants.js +16 -0
  16. package/lib/esm/constants.js.map +1 -1
  17. package/lib/esm/index.js +1 -1
  18. package/lib/esm/logging.js +67 -3
  19. package/lib/esm/logging.js.map +1 -1
  20. package/lib/esm/pino/pino.js +3 -1
  21. package/lib/esm/pino/pino.js.map +1 -1
  22. package/lib/esm/winston/winston.js +15 -1
  23. package/lib/esm/winston/winston.js.map +1 -1
  24. package/lib/types/LoggedClass.d.cts +1 -1
  25. package/lib/types/LoggedClass.d.mts +1 -1
  26. package/lib/types/constants.d.cts +9 -1
  27. package/lib/types/constants.d.mts +9 -1
  28. package/lib/types/decorators.d.cts +1 -1
  29. package/lib/types/decorators.d.mts +1 -1
  30. package/lib/types/filters/LogFilter.d.cts +2 -2
  31. package/lib/types/filters/LogFilter.d.mts +2 -2
  32. package/lib/types/filters/PatternFilter.d.cts +2 -2
  33. package/lib/types/filters/PatternFilter.d.mts +2 -2
  34. package/lib/types/filters/index.d.cts +2 -2
  35. package/lib/types/filters/index.d.mts +2 -2
  36. package/lib/types/index.d.cts +12 -12
  37. package/lib/types/index.d.mts +12 -12
  38. package/lib/types/logParameters.d.cts +2 -2
  39. package/lib/types/logParameters.d.mts +2 -2
  40. package/lib/types/logging.d.cts +42 -6
  41. package/lib/types/logging.d.mts +42 -6
  42. package/lib/types/pino/index.d.cts +1 -1
  43. package/lib/types/pino/index.d.mts +1 -1
  44. package/lib/types/pino/pino.d.cts +3 -3
  45. package/lib/types/pino/pino.d.mts +3 -3
  46. package/lib/types/types.d.cts +20 -2
  47. package/lib/types/types.d.mts +20 -2
  48. package/lib/types/winston/index.d.cts +1 -1
  49. package/lib/types/winston/index.d.mts +1 -1
  50. package/lib/types/winston/winston.d.cts +3 -3
  51. package/lib/types/winston/winston.d.mts +3 -3
  52. package/package.json +1 -1
  53. package/lib/types/LoggedClass.d.ts +0 -39
  54. package/lib/types/constants.d.ts +0 -104
  55. package/lib/types/decorators.d.ts +0 -109
  56. package/lib/types/environment.d.ts +0 -120
  57. package/lib/types/filters/LogFilter.d.ts +0 -43
  58. package/lib/types/filters/PatternFilter.d.ts +0 -56
  59. package/lib/types/filters/index.d.ts +0 -7
  60. package/lib/types/index.d.ts +0 -34
  61. package/lib/types/logParameters.d.ts +0 -56
  62. package/lib/types/logging.d.ts +0 -373
  63. package/lib/types/pino/index.d.ts +0 -7
  64. package/lib/types/pino/pino.d.ts +0 -29
  65. package/lib/types/text.d.ts +0 -118
  66. package/lib/types/time.d.ts +0 -151
  67. package/lib/types/types.d.ts +0 -287
  68. package/lib/types/utils.d.ts +0 -48
  69. package/lib/types/web.d.ts +0 -8
  70. package/lib/types/winston/index.d.ts +0 -7
  71. package/lib/types/winston/winston.d.ts +0 -47
@@ -1,56 +0,0 @@
1
- import { LogFilter } from "./LogFilter";
2
- import { LoggingConfig } from "../types";
3
- /**
4
- * @description A replacement callback that is used to transform RegExp matches.
5
- * @summary This function receives the matched substring and additional capture arguments, and returns the replacement text that will be injected into the log message.
6
- * @typedef {function(string, ...any): string} ReplacementFunction
7
- * @memberOf module:Logging
8
- */
9
- export type ReplacementFunction = (substring: string, ...args: any[]) => string;
10
- /**
11
- * @description A filter that patches log messages using regular expressions.
12
- * @summary This class applies a configured {@link RegExp} and replacement strategy to redact, mask, or restructure log payloads before they are emitted.
13
- * @param {RegExp} regexp - The expression to use for detecting sensitive or formatted text.
14
- * @param {(string|ReplacementFunction)} replacement - The replacement string or a callback that is invoked for each match.
15
- * @class PatternFilter
16
- * @example
17
- * const filter = new PatternFilter(/token=[^&]+/g, "token=***");
18
- * const sanitized = filter.filter(config, "token=123&user=tom", []);
19
- * // sanitized === "token=***&user=tom"
20
- * @mermaid
21
- * sequenceDiagram
22
- * participant Logger
23
- * participant Filter as PatternFilter
24
- * participant RegExp
25
- * Logger->>Filter: filter(config, message, context)
26
- * Filter->>RegExp: execute match()
27
- * alt match found
28
- * RegExp-->>Filter: captures
29
- * Filter->>RegExp: replace(message, replacement)
30
- * RegExp-->>Filter: transformed message
31
- * else no match
32
- * RegExp-->>Filter: null
33
- * end
34
- * Filter-->>Logger: sanitized message
35
- */
36
- export declare class PatternFilter extends LogFilter {
37
- protected readonly regexp: RegExp;
38
- protected readonly replacement: string | ReplacementFunction;
39
- constructor(regexp: RegExp, replacement: string | ReplacementFunction);
40
- /**
41
- * @description Ensures deterministic RegExp matching.
42
- * @summary This method runs the configured expression, then resets its state so that repeated invocations behave consistently.
43
- * @param {string} message - The message to test for matches.
44
- * @return {(RegExpExecArray|null)} The match result, or null if no match is found.
45
- */
46
- protected match(message: string): RegExpExecArray | null;
47
- /**
48
- * @description Applies the replacement strategy to the incoming message.
49
- * @summary This method executes {@link PatternFilter.match} and, when a match is found, replaces every occurrence using the configured replacement handler.
50
- * @param {LoggingConfig} config - The active logging configuration (unused, but part of the filter contract).
51
- * @param {string} message - The message to be sanitized.
52
- * @param {string[]} context - The context entries that are associated with the log event.
53
- * @return {string} The sanitized log message.
54
- */
55
- filter(config: LoggingConfig, message: string, context: string[]): string;
56
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * @description Exports for the filters module.
3
- * @summary This file exports all the necessary components for the filters functionality, including LogFilter and PatternFilter.
4
- * @module logging/filters
5
- */
6
- export * from "./LogFilter";
7
- export * from "./PatternFilter";
@@ -1,34 +0,0 @@
1
- /**
2
- * @module Logging
3
- * @description A comprehensive and versatile logging toolkit for both browser and Node.js environments.
4
- * @summary This module provides a complete logging solution, exposing {@link Logging} and {@link MiniLogger} for runtime logging. It also includes decorators like {@link log} for method instrumentation, and various utilities such as {@link PatternFilter}, {@link StopWatch}, and {@link LoggedEnvironment} to help build configurable and theme-aware log pipelines.
5
- */
6
- export * from "./filters";
7
- export * from "./constants";
8
- export * from "./decorators";
9
- export * from "./environment";
10
- export * from "./LoggedClass";
11
- export * from "./logging";
12
- export * from "./logParameters";
13
- export * from "./text";
14
- export * from "./time";
15
- export * from "./types";
16
- export * from "./web";
17
- export * from "./utils";
18
- export * from "styled-string-builder";
19
- /**
20
- * @description Current package version string.
21
- * @summary Stores the package version for diagnostics and compatibility checks.
22
- * @const VERSION
23
- * @type {string}
24
- * @memberOf module:Logging
25
- */
26
- export declare const VERSION: string;
27
- /**
28
- * @description Current package version string.
29
- * @summary Stores the package version for diagnostics and compatibility checks.
30
- * @const PACKAGE_NAME
31
- * @type {string}
32
- * @memberOf module:Logging
33
- */
34
- export declare const PACKAGE_NAME: string;
@@ -1,56 +0,0 @@
1
- import { LogLevel } from "./constants";
2
- import { LogMeta, LoggingConfig } from "./types";
3
- export type LogParameterPayload = {
4
- config: LoggingConfig;
5
- level: LogLevel;
6
- context: string[];
7
- timestamp?: string;
8
- app?: string;
9
- separator?: string;
10
- correlationId?: string;
11
- rawMessage: string;
12
- filteredMessage: string;
13
- meta?: LogMeta;
14
- metaString?: string;
15
- stack?: string;
16
- stackLabel?: string;
17
- applyTheme(value: string, type: string): string;
18
- };
19
- export interface LogParameterDescriptor {
20
- key: string;
21
- render(payload: LogParameterPayload): string | undefined;
22
- style?(rendered: string, payload: LogParameterPayload): string;
23
- shouldInclude?(payload: LogParameterPayload): boolean;
24
- }
25
- export interface LogPatternLiteralSegment {
26
- type: "literal";
27
- value: string;
28
- }
29
- export interface LogPatternParameterSegment {
30
- type: "parameter";
31
- key: string;
32
- }
33
- export interface LogPatternOptionalSegment {
34
- type: "optional";
35
- prefix: string;
36
- suffix: string;
37
- children: LogPatternSegment[];
38
- }
39
- export type LogPatternSegment = LogPatternLiteralSegment | LogPatternParameterSegment | LogPatternOptionalSegment;
40
- export type LogPatternDefinition = {
41
- pattern: string;
42
- segments: LogPatternSegment[];
43
- keys: string[];
44
- includesMeta: boolean;
45
- };
46
- export declare class LogParameterRegistry {
47
- private readonly descriptors;
48
- register(descriptor: LogParameterDescriptor): this;
49
- unregister(key: string): this;
50
- get(key: string): LogParameterDescriptor | undefined;
51
- render(payload: LogParameterPayload, keys: string[]): Record<string, string>;
52
- keys(): string[];
53
- }
54
- export declare function compileLogPattern(pattern: string): LogPatternDefinition;
55
- export declare function renderPattern(definition: LogPatternDefinition, rendered: Record<string, string>): string;
56
- export declare const logParameterRegistry: LogParameterRegistry;
@@ -1,373 +0,0 @@
1
- import { LoggerFactory, LoggingConfig, LoggingContext, LoggingFilter, LogMeta, StringLike, Theme, Logger } from "./types";
2
- import { LogLevel } from "./constants";
3
- import { LogParameterDescriptor } from "./logParameters";
4
- import { LoggedEnvironment } from "./environment";
5
- export declare const ROOT_CONTEXT_SYMBOL: unique symbol;
6
- /**
7
- * @description A minimal logger implementation.
8
- * @summary MiniLogger is a lightweight logging class that implements the Logger interface. It provides basic logging functionality with support for different log levels, verbosity, context-aware logging, and customizable formatting.
9
- * @param {string} [context] - The context (typically class name) this logger is associated with.
10
- * @param {Partial<LoggingConfig>} [conf] - Optional configuration to override global settings.
11
- * @param {string[]} [baseContext=[]] - The base context for the logger.
12
- * @class MiniLogger
13
- * @example
14
- * // Create a new logger for a class
15
- * const logger = new MiniLogger('MyClass');
16
- *
17
- * // Log messages at different levels
18
- * logger.info('This is an info message');
19
- * logger.debug('This is a debug message');
20
- * logger.error('Something went wrong');
21
- *
22
- * // Create a child logger for a specific method
23
- * const methodLogger = logger.for('myMethod');
24
- * methodLogger.verbose('Detailed information', 2);
25
- *
26
- * // Log with custom configuration
27
- * logger.for('specialMethod', { style: true }).info('Styled message');
28
- */
29
- export declare class MiniLogger implements Logger {
30
- protected conf?: Partial<LoggingConfig> | undefined;
31
- protected context: string[];
32
- protected baseContext: string[];
33
- constructor(context?: string, conf?: Partial<LoggingConfig> | undefined, baseContext?: string[]);
34
- protected config<K extends keyof LoggingConfig>(key: K): LoggingConfig[K];
35
- for(config: Partial<LoggingConfig>): this;
36
- for(method: string | ((...args: any[]) => any) | {
37
- new (...args: any[]): any;
38
- } | object): this;
39
- for(method: string | ((...args: any[]) => any) | {
40
- new (...args: any[]): any;
41
- } | object | Partial<LoggingConfig>, config: Partial<LoggingConfig>, ...args: any[]): this;
42
- protected getConfigSnapshot(): LoggingConfig;
43
- protected getContextSegments(): string[];
44
- protected resolveFilters(config: LoggingConfig): LoggingFilter[];
45
- protected applyFilters(message: string, context: string[], config: LoggingConfig): string;
46
- /**
47
- * @description Creates a formatted log string.
48
- * @summary Generates a log string with timestamp, colored log level, context, and message.
49
- * @param {LogLevel} level - The log level for this message.
50
- * @param {StringLike | Error} message - The message to log or an Error object.
51
- * @param {Error} [error] - Optional error to extract stack trace to include in the log.
52
- * @return {string} A formatted log string with all components.
53
- */
54
- protected createLog(level: LogLevel, message: StringLike | Error, error?: Error, meta?: LogMeta): string;
55
- private formatMeta;
56
- protected normalizePatternSpacing(value: string): string;
57
- /**
58
- * @description Logs a message with the specified log level.
59
- * @summary Checks if the message should be logged based on the current log level, then uses the appropriate console method to output the formatted log.
60
- * @param {LogLevel} level - The log level of the message.
61
- * @param {StringLike | Error} msg - The message to be logged or an Error object.
62
- * @param {Error} [error] - Optional stack trace to include in the log.
63
- * @return {void}
64
- */
65
- protected log(level: LogLevel, msg: StringLike | Error, error?: Error, meta?: LogMeta): void;
66
- /**
67
- * @description Logs a message at the benchmark level.
68
- * @summary Logs a message at the benchmark level if the current verbosity setting allows it.
69
- * @param {StringLike} msg - The message to be logged.
70
- * @param {object} [meta] - Optional metadata to include with the entry.
71
- * @return {void}
72
- */
73
- benchmark(msg: StringLike, meta?: LogMeta): void;
74
- /**
75
- * @description Logs a message at the silly level.
76
- * @summary Logs a message at the silly level if the current verbosity setting allows it.
77
- * @param {StringLike} msg - The message to be logged.
78
- * @param {number} [verbosity=0] - The verbosity level of the message.
79
- * @param {object} [meta] - Optional metadata to include with the entry.
80
- * @return {void}
81
- */
82
- silly(msg: StringLike, verbosityOrMeta?: number | LogMeta, meta?: LogMeta): void;
83
- /**
84
- * @description Logs a message at the verbose level.
85
- * @summary Logs a message at the verbose level if the current verbosity setting allows it.
86
- * @param {StringLike} msg - The message to be logged.
87
- * @param {number} [verbosity=0] - The verbosity level of the message.
88
- * @param {object} [meta] - Optional metadata to include with the entry.
89
- * @return {void}
90
- */
91
- verbose(msg: StringLike, verbosityOrMeta?: number | LogMeta, meta?: LogMeta): void;
92
- /**
93
- * @description Logs a message at the info level.
94
- * @summary Logs a message at the info level for general application information.
95
- * @param {StringLike} msg - The message to be logged.
96
- * @param {object} [meta] - Optional metadata to include with the entry.
97
- * @return {void}
98
- */
99
- info(msg: StringLike, meta?: LogMeta): void;
100
- /**
101
- * @description Logs a message at the debug level.
102
- * @summary Logs a message at the debug level for detailed troubleshooting information.
103
- * @param {StringLike} msg - The message to be logged.
104
- * @param {object} [meta] - Optional metadata to include with the entry.
105
- * @return {void}
106
- */
107
- debug(msg: StringLike, meta?: LogMeta): void;
108
- /**
109
- * @description Logs a message at the error level.
110
- * @summary Logs a message at the error level for errors and exceptions.
111
- * @param {StringLike | Error} msg - The message to be logged or an Error object.
112
- * @param {Error|object} [e] - Optional error or metadata to include in the log.
113
- * @param {object} [meta] - Optional metadata to include with the entry when an error is supplied.
114
- * @return {void}
115
- */
116
- error(msg: StringLike | Error, e?: Error | LogMeta, meta?: LogMeta): void;
117
- /**
118
- * @description Logs a message at the warning level.
119
- * @summary Logs a message at the warning level for potential issues.
120
- * @param {StringLike} msg - The message to be logged.
121
- * @param {object} [meta] - Optional metadata to include with the entry.
122
- * @return {void}
123
- */
124
- warn(msg: StringLike, meta?: LogMeta): void;
125
- /**
126
- * @description Logs a message at the trace level.
127
- * @summary Logs a message at the trace level for tracing code execution.
128
- * @param {StringLike} msg - The message to be logged.
129
- * @param {object} [meta] - Optional metadata to include with the entry.
130
- * @return {void}
131
- */
132
- trace(msg: StringLike, meta?: LogMeta): void;
133
- /**
134
- * @description Updates the logger configuration.
135
- * @summary Merges the provided configuration with the existing configuration.
136
- * @param {Partial<LoggingConfig>} config - The configuration options to apply.
137
- * @return {void}
138
- */
139
- setConfig(config: Partial<LoggingConfig>): void;
140
- get root(): string[];
141
- /**
142
- * @description Clears any contextual overrides applied by `for`.
143
- * @summary Returns the same logger instance so more contexts can be chained afterwards.
144
- * @return {this} The same logger instance.
145
- */
146
- clear(): this;
147
- }
148
- /**
149
- * @description A static class for managing logging operations.
150
- * @summary The Logging class provides a centralized logging mechanism with support for different log levels, verbosity, and styling. It uses a singleton pattern to maintain a global logger instance and allows creating specific loggers for different classes and methods.
151
- * @class Logging
152
- * @example
153
- * // Set global configuration
154
- * Logging.setConfig({ level: LogLevel.debug, style: true });
155
- *
156
- * // Get a logger for a specific class
157
- * const logger = Logging.for('MyClass');
158
- *
159
- * // Log messages at different levels
160
- * logger.info('Application started');
161
- * logger.debug('Processing data...');
162
- *
163
- * // Log with context
164
- * const methodLogger = Logging.for('MyClass.myMethod');
165
- * methodLogger.verbose('Detailed operation information', 1);
166
- *
167
- * // Log errors
168
- * try {
169
- * // some operation
170
- * } catch (error) {
171
- * logger.error(error);
172
- * }
173
- * @mermaid
174
- * classDiagram
175
- * class Logger {
176
- * <<interface>>
177
- * +for(method, config, ...args)
178
- * +silly(msg, verbosity)
179
- * +verbose(msg, verbosity)
180
- * +info(msg)
181
- * +debug(msg)
182
- * +error(msg)
183
- * +setConfig(config)
184
- * }
185
- *
186
- * class Logging {
187
- * -global: Logger
188
- * -_factory: LoggerFactory
189
- * -_config: LoggingConfig
190
- * +setFactory(factory)
191
- * +setConfig(config)
192
- * +getConfig()
193
- * +get()
194
- * +verbose(msg, verbosity)
195
- * +info(msg)
196
- * +debug(msg)
197
- * +silly(msg)
198
- * +error(msg)
199
- * +for(object, config, ...args)
200
- * +because(reason, id)
201
- * +theme(text, type, loggerLevel, template)
202
- * }
203
- *
204
- * class MiniLogger {
205
- * +constructor(context, conf?)
206
- * }
207
- *
208
- * Logging ..> Logger : creates
209
- * Logging ..> MiniLogger : creates by default
210
- */
211
- export declare class Logging {
212
- /**
213
- * @description The global logger instance.
214
- * @summary A singleton instance of Logger used for global logging.
215
- */
216
- private static global?;
217
- /**
218
- * @description Factory function for creating logger instances.
219
- * @summary A function that creates new Logger instances. By default, it creates a MiniLogger.
220
- */
221
- private static _factory;
222
- private static _config;
223
- private constructor();
224
- /**
225
- * @description Sets the factory function for creating logger instances.
226
- * @summary Allows customizing how logger instances are created.
227
- * @param {LoggerFactory} factory - The factory function to use for creating loggers.
228
- * @return {void}
229
- */
230
- static setFactory(factory: LoggerFactory): void;
231
- /**
232
- * @description Updates the global logging configuration.
233
- * @summary Allows updating the global logging configuration with new settings.
234
- * @param {Partial<LoggingConfig>} config - The configuration options to apply.
235
- * @return {void}
236
- */
237
- static setConfig(config: Partial<LoggingConfig>): void;
238
- /**
239
- * @description Gets a copy of the current global logging configuration.
240
- * @summary Returns a copy of the current global logging configuration.
241
- * @return {LoggingConfig} A copy of the current configuration.
242
- */
243
- static getConfig(): typeof LoggedEnvironment;
244
- /**
245
- * @description Retrieves or creates the global logger instance.
246
- * @summary Returns the existing global logger or creates a new one if it doesn't exist.
247
- * @return {Logger} The global Logger instance.
248
- */
249
- static get(): Logger;
250
- /**
251
- * @description Logs a verbose message.
252
- * @summary Delegates the verbose logging to the global logger instance.
253
- * @param {StringLike} msg - The message to be logged.
254
- * @param {number|object} [verbosity] - The verbosity level or metadata object.
255
- * @param {object} [meta] - Optional metadata applied when a verbosity level is provided.
256
- * @return {void}
257
- */
258
- static verbose(msg: StringLike, verbosityOrMeta?: number | LogMeta, meta?: LogMeta): void;
259
- /**
260
- * @description Logs an info message.
261
- * @summary Delegates the info logging to the global logger instance.
262
- * @param {StringLike} msg - The message to be logged.
263
- * @param {object} [meta] - Optional metadata to include with the entry.
264
- * @return {void}
265
- */
266
- static info(msg: StringLike, meta?: LogMeta): void;
267
- /**
268
- * @description Logs a trace message.
269
- * @summary Delegates the trace logging to the global logger instance.
270
- * @param {StringLike} msg - The message to be logged.
271
- * @param {object} [meta] - Optional metadata to include with the entry.
272
- * @return {void}
273
- */
274
- static trace(msg: StringLike, meta?: LogMeta): void;
275
- /**
276
- * @description Logs a debug message.
277
- * @summary Delegates the debug logging to the global logger instance.
278
- * @param {StringLike} msg - The message to be logged.
279
- * @param {object} [meta] - Optional metadata to include with the entry.
280
- * @return {void}
281
- */
282
- static debug(msg: StringLike, meta?: LogMeta): void;
283
- /**
284
- * @description Logs a benchmark message.
285
- * @summary Delegates the benchmark logging to the global logger instance.
286
- * @param {StringLike} msg - The message to be logged.
287
- * @param {object} [meta] - Optional metadata to include with the entry.
288
- * @return {void}
289
- */
290
- static benchmark(msg: StringLike, meta?: LogMeta): void;
291
- /**
292
- * @description Logs a silly message.
293
- * @summary Delegates the silly logging to the global logger instance.
294
- * @param {StringLike} msg - The message to be logged.
295
- * @param {number|object} [verbosity] - The verbosity level or metadata object.
296
- * @param {object} [meta] - Optional metadata applied when a verbosity level is provided.
297
- * @return {void}
298
- */
299
- static silly(msg: StringLike, verbosityOrMeta?: number | LogMeta, meta?: LogMeta): void;
300
- /**
301
- * @description Logs a warning message.
302
- * @summary Delegates the warning logging to the global logger instance.
303
- * @param {StringLike} msg - The message to be logged.
304
- * @param {object} [meta] - Optional metadata to include with the entry.
305
- * @return {void}
306
- */
307
- static warn(msg: StringLike, meta?: LogMeta): void;
308
- /**
309
- * @description Logs an error message.
310
- * @summary Delegates the error logging to the global logger instance.
311
- * @param {StringLike | Error} msg - The message to be logged.
312
- * @param {Error|object} [e] - Optional error or metadata to include in the log.
313
- * @param {object} [meta] - Optional metadata to include with the entry when an error is supplied.
314
- * @return {void}
315
- */
316
- static error(msg: StringLike | Error, e?: Error | LogMeta, meta?: LogMeta): void;
317
- /**
318
- * @description Creates a logger for a specific object or context.
319
- * @summary Creates a new logger instance for the given object or context using the factory function.
320
- * @param {LoggingContext} object - The object, class, or context to create a logger for.
321
- * @param {Partial<LoggingConfig>} [config] - Optional configuration to override global settings.
322
- * @param {...any} args - Additional arguments to pass to the logger factory.
323
- * @return {Logger} A new logger instance for the specified object or context.
324
- */
325
- static for(object: LoggingContext, config?: Partial<LoggingConfig>, ...args: any[]): Logger;
326
- /**
327
- * @description Creates a logger for a specific reason or correlation context.
328
- * @summary Utility to quickly create a logger labeled with a free-form reason and optional identifier so that ad-hoc operations can be traced without tying the logger to a class or method name.
329
- * @param {string} reason - A textual reason or context label for this logger instance.
330
- * @param {string} [id] - Optional identifier to help correlate related log entries.
331
- * @return {Logger} A new logger instance labeled with the provided reason and id.
332
- */
333
- static because(reason: string, id?: string): Logger;
334
- private static baseContext;
335
- private static attachRootContext;
336
- private static ensureRoot;
337
- /**
338
- * @description Applies theme styling to text.
339
- * @summary Applies styling (colors, formatting) to text based on the theme configuration.
340
- * @param {string} text - The text to style.
341
- * @param type - The type of element to style (e.g., "class", "message", "logLevel").
342
- * @param {LogLevel} loggerLevel - The log level to use for styling.
343
- * @param {Theme} [template=DefaultTheme] - The theme to use for styling.
344
- * @return {string} The styled text.
345
- * @mermaid
346
- * sequenceDiagram
347
- * participant Caller
348
- * participant Theme as Logging.theme
349
- * participant Apply as apply function
350
- * participant Style as styled-string-builder
351
- *
352
- * Caller->>Theme: theme(text, type, loggerLevel)
353
- * Theme->>Theme: Check if styling is enabled
354
- * alt styling disabled
355
- * Theme-->>Caller: return original text
356
- * else styling enabled
357
- * Theme->>Theme: Get theme for type
358
- * alt theme not found
359
- * Theme-->>Caller: return original text
360
- * else theme found
361
- * Theme->>Theme: Determine actual theme based on log level
362
- * Theme->>Apply: Apply each style property
363
- * Apply->>Style: Apply colors and formatting
364
- * Style-->>Apply: Return styled text
365
- * Apply-->>Theme: Return styled text
366
- * Theme-->>Caller: Return final styled text
367
- * end
368
- * end
369
- */
370
- static theme(text: string, type: keyof Theme | keyof LogLevel, loggerLevel: LogLevel, template?: Theme): string;
371
- static register(descriptor: LogParameterDescriptor): import("./logParameters").LogParameterRegistry;
372
- static unregister(key: string): import("./logParameters").LogParameterRegistry;
373
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * @module Pino
3
- * @description This module provides an adapter for the Pino logger.
4
- * @summary This module exports the {@link PinoLogger} class.
5
- * @memberOf module:Logging
6
- */
7
- export * from "./pino";
@@ -1,29 +0,0 @@
1
- import { Logger as PinoBaseLogger } from "pino";
2
- import { MiniLogger } from "../logging";
3
- import { Logger, LoggerFactory, LogMeta, LoggingConfig, StringLike } from "../types";
4
- import { LogLevel } from "../constants";
5
- /**
6
- * @description A logger that is powered by the Pino logging library.
7
- * @summary This class extends {@link MiniLogger} and uses Pino as its underlying logging engine.
8
- * @param {string} [context] - The context (typically the class name) that this logger is associated with.
9
- * @param {Partial<LoggingConfig>} [conf] - Optional configuration to override global settings.
10
- * @param {PinoBaseLogger} [driver] - An optional, pre-existing Pino logger instance to use.
11
- * @class PinoLogger
12
- */
13
- export declare class PinoLogger extends MiniLogger implements Logger {
14
- protected pino: PinoBaseLogger;
15
- constructor(context?: string, conf?: Partial<LoggingConfig>, driver?: PinoBaseLogger);
16
- protected log(level: LogLevel, msg: StringLike | Error, error?: Error, meta?: LogMeta): void;
17
- fatal(msg: StringLike | Error, error?: Error, meta?: LogMeta): void;
18
- child(bindings?: Record<string, unknown>, options?: Record<string, unknown>): PinoLogger;
19
- flush(): void | Promise<void>;
20
- get level(): string | undefined;
21
- set level(value: string | undefined);
22
- }
23
- /**
24
- * @description A factory for creating {@link PinoLogger} instances.
25
- * @summary This factory function creates a new {@link PinoLogger} instance, and can optionally accept a pre-existing Pino logger instance.
26
- * @const {LoggerFactory} PinoFactory
27
- * @memberOf module:Logging
28
- */
29
- export declare const PinoFactory: LoggerFactory;