@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,373 @@
1
+ import { LoggerFactory, LoggingConfig, LoggingContext, LoggingFilter, LogMeta, StringLike, Theme, Logger } from "./types.js";
2
+ import { LogLevel } from "./constants.js";
3
+ import { LogParameterDescriptor } from "./logParameters.js";
4
+ import { LoggedEnvironment } from "./environment.js";
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.js").LogParameterRegistry;
372
+ static unregister(key: string): import("./logParameters.js").LogParameterRegistry;
373
+ }
@@ -0,0 +1,7 @@
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.cjs";
@@ -0,0 +1,7 @@
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.js";
@@ -0,0 +1,29 @@
1
+ import { Logger as PinoBaseLogger } from "pino";
2
+ import { MiniLogger } from "../logging.cjs";
3
+ import { Logger, LoggerFactory, LogMeta, LoggingConfig, StringLike } from "../types.cjs";
4
+ import { LogLevel } from "../constants.cjs";
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;
@@ -0,0 +1,29 @@
1
+ import { Logger as PinoBaseLogger } from "pino";
2
+ import { MiniLogger } from "../logging.js";
3
+ import { Logger, LoggerFactory, LogMeta, LoggingConfig, StringLike } from "../types.js";
4
+ import { LogLevel } from "../constants.js";
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;
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @description Pads the end of a string with a specified character.
3
+ * @summary This function extends the input string to a specified length by adding a padding character to the end. If the input string is already longer than the specified length, it is returned unchanged.
4
+ * @param {string} str - The input string to be padded.
5
+ * @param {number} length - The desired total length of the resulting string.
6
+ * @param {string} [char=" "] - The character to use for padding.
7
+ * @return {string} The padded string.
8
+ * @throws {Error} If the padding character is not exactly one character long.
9
+ * @function padEnd
10
+ * @memberOf module:Logging
11
+ */
12
+ export declare function padEnd(str: string, length: number, char?: string): string;
13
+ /**
14
+ * @description Replaces placeholders in a string with the provided values.
15
+ * @summary This function interpolates a string by replacing placeholders of the form `${variableName}` with the corresponding values from the provided object. If a placeholder does not have a corresponding value, it is left unchanged in the string.
16
+ * @param {string} input - The input string containing the placeholders to be replaced.
17
+ * @param {Record<string, (number|string)>} values - An object containing key-value pairs for the replacement.
18
+ * @param {string} [prefix="${"] - The prefix for the placeholders.
19
+ * @param {string} [suffix="}"] - The suffix for the placeholders.
20
+ * @param {string} [flags="g"] - The regular expression flags to use.
21
+ * @return {string} The interpolated string with the placeholders replaced by their corresponding values.
22
+ * @function patchPlaceholders
23
+ * @mermaid
24
+ * sequenceDiagram
25
+ * participant Caller
26
+ * participant patchString
27
+ * participant String.replace
28
+ * Caller->>patchString: Call with input and values
29
+ * patchString->>String.replace: Call with regex and replacement function
30
+ * String.replace->>patchString: Return replaced string
31
+ * patchString-->>Caller: Return patched string
32
+ * @memberOf module:Logging
33
+ */
34
+ export declare function patchPlaceholders(input: string, values: Record<string, number | string>, prefix?: string, suffix?: string, flags?: string): string;
35
+ /**
36
+ * @description Replaces occurrences of keys with their corresponding values in a string.
37
+ * @summary This function iterates through a set of key-value pairs and replaces all occurrences of each key in the input string with its corresponding value. It supports regular expression flags for customized replacement.
38
+ * @param {string} input - The input string in which the replacements will be made.
39
+ * @param {Record<string, (number|string)>} values - An object containing key-value pairs for the replacement.
40
+ * @param {string} [flags="g"] - The regular expression flags to control the replacement behavior.
41
+ * @return {string} The string with all the specified replacements applied.
42
+ * @function patchString
43
+ * @memberOf module:Logging
44
+ */
45
+ export declare function patchString(input: string, values: Record<string, number | string>, flags?: string): string;
46
+ /**
47
+ * @description Converts a string to camelCase.
48
+ * @summary This function transforms the input string into camelCase format, where words are joined without spaces and each word after the first starts with a capital letter.
49
+ * @param {string} text - The input string to be converted.
50
+ * @return {string} The input string converted to camelCase.
51
+ * @function toCamelCase
52
+ * @memberOf module:Logging
53
+ */
54
+ export declare function toCamelCase(text: string): string;
55
+ /**
56
+ * @description Converts a string to ENVIRONMENT_VARIABLE format.
57
+ * @summary This function transforms the input string into uppercase with words separated by underscores, which is a format that is typically used for environment variable names.
58
+ * @param {string} text - The input string to be converted.
59
+ * @return {string} The input string converted to ENVIRONMENT_VARIABLE format.
60
+ * @function toENVFormat
61
+ * @memberOf module:Logging
62
+ */
63
+ export declare function toENVFormat(text: string): string;
64
+ /**
65
+ * @description Converts a string to snake_case.
66
+ * @summary This function transforms the input string into lowercase with words separated by underscores.
67
+ * @param {string} text - The input string to be converted.
68
+ * @return {string} The input string converted to snake_case.
69
+ * @function toSnakeCase
70
+ * @memberOf module:Logging
71
+ */
72
+ export declare function toSnakeCase(text: string): string;
73
+ /**
74
+ * @description Converts a string to kebab-case.
75
+ * @summary This function transforms the input string into lowercase with words separated by hyphens.
76
+ * @param {string} text - The input string to be converted.
77
+ * @return {string} The input string converted to kebab-case.
78
+ * @function toKebabCase
79
+ * @memberOf module:Logging
80
+ */
81
+ export declare function toKebabCase(text: string): string;
82
+ /**
83
+ * @description Converts a string to PascalCase.
84
+ * @summary This function transforms the input string into PascalCase format, where words are joined without spaces and each word starts with a capital letter.
85
+ * @param {string} text - The input string to be converted.
86
+ * @return {string} The input string converted to PascalCase.
87
+ * @function toPascalCase
88
+ * @memberOf module:Logging
89
+ */
90
+ export declare function toPascalCase(text: string): string;
91
+ /**
92
+ * @description Escapes special characters in a string for use in a regular expression.
93
+ * @summary This function adds backslashes before characters that have a special meaning in regular expressions, which allows the string to be used as a literal match in a RegExp.
94
+ * @param {string} string - The string to escape for regular expression use.
95
+ * @return {string} The escaped string that is safe for use in regular expressions.
96
+ * @function escapeRegExp
97
+ * @memberOf module:Logging
98
+ */
99
+ export declare function escapeRegExp(string: string): string;
100
+ /**
101
+ * @description A utility function that provides string formatting functionality that is similar to C#'s string.format.
102
+ * @summary This function replaces placeholders in a string with the provided arguments.
103
+ * @param {string} string - The string to format.
104
+ * @param {...(string|number|Record<string, any>)} args - The arguments to use for formatting.
105
+ * @return {string} The formatted string.
106
+ * @function sf
107
+ * @memberOf module:Logging
108
+ */
109
+ export declare function sf(string: string, ...args: (string | number | Record<string, any>)[]): string;
110
+ /**
111
+ * @description A utility function that provides string formatting functionality that is similar to C#'s string.format.
112
+ * @summary This function is deprecated. Use {@link sf} instead.
113
+ * @see sf
114
+ * @deprecated
115
+ * @function stringFormat
116
+ * @memberOf module:Logging
117
+ */
118
+ export declare const stringFormat: typeof sf;