@nu-art/logger 0.401.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.
package/Logger.d.ts ADDED
@@ -0,0 +1,237 @@
1
+ import { LogLevel, LogParam } from './types.js';
2
+ import { DebugFlag } from './debug-flags.js';
3
+ /**
4
+ * Base logging class that provides structured logging with debug flag integration.
5
+ *
6
+ * Logger instances are associated with a DebugFlag that controls:
7
+ * - Whether logging is enabled for this logger
8
+ * - The minimum log level that will be output
9
+ *
10
+ * Logging is filtered at two levels:
11
+ * 1. Debug flag must be enabled (`_DEBUG_FLAG.isEnabled()`)
12
+ * 2. Log level must meet the minimum threshold (`_DEBUG_FLAG.canLog(level)`)
13
+ *
14
+ * If either check fails, the log message is silently dropped.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * class MyService extends Logger {
19
+ * constructor() {
20
+ * super('MyService');
21
+ * }
22
+ *
23
+ * doSomething() {
24
+ * this.logInfo('Doing something');
25
+ * this.logDebug('Debug details');
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ export declare class Logger {
31
+ /** Logging tag/identifier for this logger */
32
+ readonly tag: string;
33
+ /** Default enabled state for new debug flags */
34
+ static defaultFlagState: boolean;
35
+ /** Debug flag that controls logging for this instance */
36
+ protected readonly _DEBUG_FLAG: DebugFlag;
37
+ /**
38
+ * Creates a new Logger instance.
39
+ *
40
+ * Automatically creates a DebugFlag with the tag name. The flag is enabled
41
+ * by default (controlled by `Logger.defaultFlagState`).
42
+ *
43
+ * @param tag - Optional tag name. If not provided, uses the class name
44
+ */
45
+ constructor(tag?: string);
46
+ /**
47
+ * Sets the minimum log level for this logger.
48
+ *
49
+ * Only log messages at or above this level will be output. Lower-level
50
+ * messages are silently dropped.
51
+ *
52
+ * @param minLevel - Minimum log level (Verbose < Debug < Info < Warning < Error)
53
+ */
54
+ setMinLevel(minLevel: LogLevel): void;
55
+ /**
56
+ * Changes the logging tag and updates the associated debug flag.
57
+ *
58
+ * @param tag - New tag name
59
+ */
60
+ protected setTag(tag: string): void;
61
+ /**
62
+ * Logs a verbose-level message (lowest priority, most detailed).
63
+ */
64
+ logVerbose(...toLog: LogParam[]): void;
65
+ /**
66
+ * Logs a debug-level message (development/debugging information).
67
+ */
68
+ logDebug(...toLog: LogParam[]): void;
69
+ /**
70
+ * Logs an info-level message (general informational messages).
71
+ */
72
+ logInfo(...toLog: LogParam[]): void;
73
+ /**
74
+ * Logs a warning-level message (potential issues that don't stop execution).
75
+ */
76
+ logWarning(...toLog: LogParam[]): void;
77
+ /**
78
+ * Logs an error-level message (errors that may affect functionality).
79
+ */
80
+ logError(...toLog: LogParam[]): void;
81
+ /**
82
+ * Logs a verbose-level message with bold formatting.
83
+ */
84
+ logVerboseBold(...toLog: LogParam[]): void;
85
+ /**
86
+ * Logs a debug-level message with bold formatting.
87
+ */
88
+ logDebugBold(...toLog: LogParam[]): void;
89
+ /**
90
+ * Logs an info-level message with bold formatting.
91
+ */
92
+ logInfoBold(...toLog: LogParam[]): void;
93
+ /**
94
+ * Logs a warning-level message with bold formatting.
95
+ */
96
+ logWarningBold(...toLog: LogParam[]): void;
97
+ /**
98
+ * Logs an error-level message with bold formatting.
99
+ */
100
+ logErrorBold(...toLog: LogParam[]): void;
101
+ /**
102
+ * Core logging method that performs the actual log output.
103
+ *
104
+ * Checks if logging is enabled and the level meets the threshold before
105
+ * delegating to the BeLogged system. If either check fails, the message
106
+ * is silently dropped.
107
+ *
108
+ * @param level - Log level (Verbose, Debug, Info, Warning, Error)
109
+ * @param bold - Whether to apply bold formatting
110
+ * @param toLog - Array of values to log (can be strings, objects, etc.)
111
+ */
112
+ log(level: LogLevel, bold: boolean, toLog: LogParam[]): void;
113
+ /**
114
+ * Checks if a log message at the given level should be printed.
115
+ *
116
+ * Returns false if:
117
+ * - The debug flag is not enabled, OR
118
+ * - The log level is below the minimum threshold
119
+ *
120
+ * @param level - Log level to check
121
+ * @returns true if the message should be logged, false otherwise
122
+ */
123
+ private assertCanPrint;
124
+ }
125
+ /**
126
+ * Static logging utility class for use cases where instance-based logging isn't needed.
127
+ *
128
+ * Provides the same logging interface as Logger but with static methods that require
129
+ * a tag parameter for each log call. Useful for utility functions or standalone code
130
+ * that doesn't have a class instance.
131
+ *
132
+ * All static loggers share a single debug flag named 'StaticLogger'.
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * function utilityFunction() {
137
+ * StaticLogger.logInfo('UtilityFunction', 'Processing data');
138
+ * StaticLogger.logError('UtilityFunction', 'Error occurred', error);
139
+ * }
140
+ * ```
141
+ */
142
+ export declare abstract class StaticLogger {
143
+ /** Shared debug flag for all static logging */
144
+ protected static readonly _DEBUG_FLAG: any;
145
+ /**
146
+ * Sets the minimum log level for static logging.
147
+ *
148
+ * @param minLevel - Minimum log level
149
+ */
150
+ static setMinLevel(minLevel: LogLevel): void;
151
+ /**
152
+ * Logs a verbose-level message with the given tag.
153
+ *
154
+ * @param tag - Tag identifier for this log message
155
+ * @param toLog - Values to log
156
+ */
157
+ static logVerbose(tag: string, ...toLog: LogParam[]): void;
158
+ /**
159
+ * Logs a debug-level message with the given tag.
160
+ *
161
+ * @param tag - Tag identifier for this log message
162
+ * @param toLog - Values to log
163
+ */
164
+ static logDebug(tag: string, ...toLog: LogParam[]): void;
165
+ /**
166
+ * Logs an info-level message with the given tag.
167
+ *
168
+ * @param tag - Tag identifier for this log message
169
+ * @param toLog - Values to log
170
+ */
171
+ static logInfo(tag: string, ...toLog: LogParam[]): void;
172
+ /**
173
+ * Logs a warning-level message with the given tag.
174
+ *
175
+ * @param tag - Tag identifier for this log message
176
+ * @param toLog - Values to log
177
+ */
178
+ static logWarning(tag: string, ...toLog: LogParam[]): void;
179
+ /**
180
+ * Logs an error-level message with the given tag.
181
+ *
182
+ * @param tag - Tag identifier for this log message
183
+ * @param toLog - Values to log
184
+ */
185
+ static logError(tag: string, ...toLog: LogParam[]): void;
186
+ /**
187
+ * Logs a verbose-level message with bold formatting.
188
+ *
189
+ * @param tag - Tag identifier for this log message
190
+ * @param toLog - Values to log
191
+ */
192
+ static logVerboseBold(tag: string, ...toLog: LogParam[]): void;
193
+ /**
194
+ * Logs a debug-level message with bold formatting.
195
+ *
196
+ * @param tag - Tag identifier for this log message
197
+ * @param toLog - Values to log
198
+ */
199
+ static logDebugBold(tag: string, ...toLog: LogParam[]): void;
200
+ /**
201
+ * Logs an info-level message with bold formatting.
202
+ *
203
+ * @param tag - Tag identifier for this log message
204
+ * @param toLog - Values to log
205
+ */
206
+ static logInfoBold(tag: string, ...toLog: LogParam[]): void;
207
+ /**
208
+ * Logs a warning-level message with bold formatting.
209
+ *
210
+ * @param tag - Tag identifier for this log message
211
+ * @param toLog - Values to log
212
+ */
213
+ static logWarningBold(tag: string, ...toLog: LogParam[]): void;
214
+ /**
215
+ * Logs an error-level message with bold formatting.
216
+ *
217
+ * @param tag - Tag identifier for this log message
218
+ * @param toLog - Values to log
219
+ */
220
+ static logErrorBold(tag: string, ...toLog: LogParam[]): void;
221
+ /**
222
+ * Core static logging method.
223
+ *
224
+ * @param tag - Tag identifier for this log message
225
+ * @param level - Log level
226
+ * @param bold - Whether to apply bold formatting
227
+ * @param toLog - Array of values to log
228
+ */
229
+ static log(tag: string, level: LogLevel, bold: boolean, toLog: LogParam[]): void;
230
+ /**
231
+ * Checks if a log message at the given level should be printed.
232
+ *
233
+ * @param level - Log level to check
234
+ * @returns true if the message should be logged, false otherwise
235
+ */
236
+ private static assertCanPrint;
237
+ }
package/Logger.js ADDED
@@ -0,0 +1,316 @@
1
+ /*
2
+ * @nu-art/logger - Flexible logging infrastructure with multiple output targets
3
+ * Copyright (C) 2024 Adam van der Kruk aka TacB0sS
4
+ * Licensed under the Apache License, Version 2.0
5
+ */
6
+ import { LogLevel } from './types.js';
7
+ import { BeLogged } from './BeLogged.js';
8
+ import { DebugFlags } from './debug-flags.js';
9
+ /**
10
+ * Base logging class that provides structured logging with debug flag integration.
11
+ *
12
+ * Logger instances are associated with a DebugFlag that controls:
13
+ * - Whether logging is enabled for this logger
14
+ * - The minimum log level that will be output
15
+ *
16
+ * Logging is filtered at two levels:
17
+ * 1. Debug flag must be enabled (`_DEBUG_FLAG.isEnabled()`)
18
+ * 2. Log level must meet the minimum threshold (`_DEBUG_FLAG.canLog(level)`)
19
+ *
20
+ * If either check fails, the log message is silently dropped.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * class MyService extends Logger {
25
+ * constructor() {
26
+ * super('MyService');
27
+ * }
28
+ *
29
+ * doSomething() {
30
+ * this.logInfo('Doing something');
31
+ * this.logDebug('Debug details');
32
+ * }
33
+ * }
34
+ * ```
35
+ */
36
+ export class Logger {
37
+ /** Logging tag/identifier for this logger */
38
+ tag;
39
+ /** Default enabled state for new debug flags */
40
+ static defaultFlagState = true;
41
+ /** Debug flag that controls logging for this instance */
42
+ _DEBUG_FLAG;
43
+ /**
44
+ * Creates a new Logger instance.
45
+ *
46
+ * Automatically creates a DebugFlag with the tag name. The flag is enabled
47
+ * by default (controlled by `Logger.defaultFlagState`).
48
+ *
49
+ * @param tag - Optional tag name. If not provided, uses the class name
50
+ */
51
+ constructor(tag) {
52
+ this.tag = tag ?? this.constructor['name'];
53
+ this._DEBUG_FLAG = DebugFlags.createFlag(this.tag);
54
+ this._DEBUG_FLAG.enable(Logger.defaultFlagState);
55
+ }
56
+ /**
57
+ * Sets the minimum log level for this logger.
58
+ *
59
+ * Only log messages at or above this level will be output. Lower-level
60
+ * messages are silently dropped.
61
+ *
62
+ * @param minLevel - Minimum log level (Verbose < Debug < Info < Warning < Error)
63
+ */
64
+ setMinLevel(minLevel) {
65
+ this._DEBUG_FLAG.setMinLevel(minLevel);
66
+ }
67
+ /**
68
+ * Changes the logging tag and updates the associated debug flag.
69
+ *
70
+ * @param tag - New tag name
71
+ */
72
+ setTag(tag) {
73
+ // @ts-ignore
74
+ this['tag'] = tag;
75
+ this._DEBUG_FLAG.rename(tag);
76
+ }
77
+ /**
78
+ * Logs a verbose-level message (lowest priority, most detailed).
79
+ */
80
+ logVerbose(...toLog) {
81
+ this.log(LogLevel.Verbose, false, toLog);
82
+ }
83
+ /**
84
+ * Logs a debug-level message (development/debugging information).
85
+ */
86
+ logDebug(...toLog) {
87
+ this.log(LogLevel.Debug, false, toLog);
88
+ }
89
+ /**
90
+ * Logs an info-level message (general informational messages).
91
+ */
92
+ logInfo(...toLog) {
93
+ this.log(LogLevel.Info, false, toLog);
94
+ }
95
+ /**
96
+ * Logs a warning-level message (potential issues that don't stop execution).
97
+ */
98
+ logWarning(...toLog) {
99
+ this.log(LogLevel.Warning, false, toLog);
100
+ }
101
+ /**
102
+ * Logs an error-level message (errors that may affect functionality).
103
+ */
104
+ logError(...toLog) {
105
+ this.log(LogLevel.Error, false, toLog);
106
+ }
107
+ /**
108
+ * Logs a verbose-level message with bold formatting.
109
+ */
110
+ logVerboseBold(...toLog) {
111
+ this.log(LogLevel.Verbose, true, toLog);
112
+ }
113
+ /**
114
+ * Logs a debug-level message with bold formatting.
115
+ */
116
+ logDebugBold(...toLog) {
117
+ this.log(LogLevel.Debug, true, toLog);
118
+ }
119
+ /**
120
+ * Logs an info-level message with bold formatting.
121
+ */
122
+ logInfoBold(...toLog) {
123
+ this.log(LogLevel.Info, true, toLog);
124
+ }
125
+ /**
126
+ * Logs a warning-level message with bold formatting.
127
+ */
128
+ logWarningBold(...toLog) {
129
+ this.log(LogLevel.Warning, true, toLog);
130
+ }
131
+ /**
132
+ * Logs an error-level message with bold formatting.
133
+ */
134
+ logErrorBold(...toLog) {
135
+ this.log(LogLevel.Error, true, toLog);
136
+ }
137
+ /**
138
+ * Core logging method that performs the actual log output.
139
+ *
140
+ * Checks if logging is enabled and the level meets the threshold before
141
+ * delegating to the BeLogged system. If either check fails, the message
142
+ * is silently dropped.
143
+ *
144
+ * @param level - Log level (Verbose, Debug, Info, Warning, Error)
145
+ * @param bold - Whether to apply bold formatting
146
+ * @param toLog - Array of values to log (can be strings, objects, etc.)
147
+ */
148
+ log(level, bold, toLog) {
149
+ if (!this.assertCanPrint(level))
150
+ return;
151
+ // @ts-ignore
152
+ BeLogged.logImpl(this.tag, level, bold, toLog);
153
+ }
154
+ /**
155
+ * Checks if a log message at the given level should be printed.
156
+ *
157
+ * Returns false if:
158
+ * - The debug flag is not enabled, OR
159
+ * - The log level is below the minimum threshold
160
+ *
161
+ * @param level - Log level to check
162
+ * @returns true if the message should be logged, false otherwise
163
+ */
164
+ assertCanPrint(level) {
165
+ if (!this._DEBUG_FLAG.isEnabled())
166
+ return false;
167
+ return this._DEBUG_FLAG.canLog(level);
168
+ }
169
+ }
170
+ /**
171
+ * Static logging utility class for use cases where instance-based logging isn't needed.
172
+ *
173
+ * Provides the same logging interface as Logger but with static methods that require
174
+ * a tag parameter for each log call. Useful for utility functions or standalone code
175
+ * that doesn't have a class instance.
176
+ *
177
+ * All static loggers share a single debug flag named 'StaticLogger'.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * function utilityFunction() {
182
+ * StaticLogger.logInfo('UtilityFunction', 'Processing data');
183
+ * StaticLogger.logError('UtilityFunction', 'Error occurred', error);
184
+ * }
185
+ * ```
186
+ */
187
+ export class StaticLogger {
188
+ /** Shared debug flag for all static logging */
189
+ static _DEBUG_FLAG = DebugFlags.createFlag('StaticLogger');
190
+ static {
191
+ StaticLogger._DEBUG_FLAG.enable(Logger.defaultFlagState);
192
+ }
193
+ /**
194
+ * Sets the minimum log level for static logging.
195
+ *
196
+ * @param minLevel - Minimum log level
197
+ */
198
+ static setMinLevel(minLevel) {
199
+ this._DEBUG_FLAG.setMinLevel(minLevel);
200
+ }
201
+ /**
202
+ * Logs a verbose-level message with the given tag.
203
+ *
204
+ * @param tag - Tag identifier for this log message
205
+ * @param toLog - Values to log
206
+ */
207
+ static logVerbose(tag, ...toLog) {
208
+ this.log(tag, LogLevel.Verbose, false, toLog);
209
+ }
210
+ /**
211
+ * Logs a debug-level message with the given tag.
212
+ *
213
+ * @param tag - Tag identifier for this log message
214
+ * @param toLog - Values to log
215
+ */
216
+ static logDebug(tag, ...toLog) {
217
+ this.log(tag, LogLevel.Debug, false, toLog);
218
+ }
219
+ /**
220
+ * Logs an info-level message with the given tag.
221
+ *
222
+ * @param tag - Tag identifier for this log message
223
+ * @param toLog - Values to log
224
+ */
225
+ static logInfo(tag, ...toLog) {
226
+ this.log(tag, LogLevel.Info, false, toLog);
227
+ }
228
+ /**
229
+ * Logs a warning-level message with the given tag.
230
+ *
231
+ * @param tag - Tag identifier for this log message
232
+ * @param toLog - Values to log
233
+ */
234
+ static logWarning(tag, ...toLog) {
235
+ this.log(tag, LogLevel.Warning, false, toLog);
236
+ }
237
+ /**
238
+ * Logs an error-level message with the given tag.
239
+ *
240
+ * @param tag - Tag identifier for this log message
241
+ * @param toLog - Values to log
242
+ */
243
+ static logError(tag, ...toLog) {
244
+ this.log(tag, LogLevel.Error, false, toLog);
245
+ }
246
+ /**
247
+ * Logs a verbose-level message with bold formatting.
248
+ *
249
+ * @param tag - Tag identifier for this log message
250
+ * @param toLog - Values to log
251
+ */
252
+ static logVerboseBold(tag, ...toLog) {
253
+ this.log(tag, LogLevel.Verbose, true, toLog);
254
+ }
255
+ /**
256
+ * Logs a debug-level message with bold formatting.
257
+ *
258
+ * @param tag - Tag identifier for this log message
259
+ * @param toLog - Values to log
260
+ */
261
+ static logDebugBold(tag, ...toLog) {
262
+ this.log(tag, LogLevel.Debug, true, toLog);
263
+ }
264
+ /**
265
+ * Logs an info-level message with bold formatting.
266
+ *
267
+ * @param tag - Tag identifier for this log message
268
+ * @param toLog - Values to log
269
+ */
270
+ static logInfoBold(tag, ...toLog) {
271
+ this.log(tag, LogLevel.Info, true, toLog);
272
+ }
273
+ /**
274
+ * Logs a warning-level message with bold formatting.
275
+ *
276
+ * @param tag - Tag identifier for this log message
277
+ * @param toLog - Values to log
278
+ */
279
+ static logWarningBold(tag, ...toLog) {
280
+ this.log(tag, LogLevel.Warning, true, toLog);
281
+ }
282
+ /**
283
+ * Logs an error-level message with bold formatting.
284
+ *
285
+ * @param tag - Tag identifier for this log message
286
+ * @param toLog - Values to log
287
+ */
288
+ static logErrorBold(tag, ...toLog) {
289
+ this.log(tag, LogLevel.Error, true, toLog);
290
+ }
291
+ /**
292
+ * Core static logging method.
293
+ *
294
+ * @param tag - Tag identifier for this log message
295
+ * @param level - Log level
296
+ * @param bold - Whether to apply bold formatting
297
+ * @param toLog - Array of values to log
298
+ */
299
+ static log(tag, level, bold, toLog) {
300
+ if (!this.assertCanPrint(level))
301
+ return;
302
+ // @ts-ignore
303
+ BeLogged.logImpl(tag, level, bold, toLog);
304
+ }
305
+ /**
306
+ * Checks if a log message at the given level should be printed.
307
+ *
308
+ * @param level - Log level to check
309
+ * @returns true if the message should be logged, false otherwise
310
+ */
311
+ static assertCanPrint(level) {
312
+ if (!this._DEBUG_FLAG.isEnabled())
313
+ return false;
314
+ return this._DEBUG_FLAG.canLog(level);
315
+ }
316
+ }
@@ -0,0 +1,145 @@
1
+ import { LogLevel } from './types.js';
2
+ /**
3
+ * Represents a debug flag that controls logging for a specific logger tag.
4
+ *
5
+ * Each DebugFlag controls two aspects of logging:
6
+ * 1. **Enabled state**: Whether logging is active for this flag
7
+ * 2. **Minimum log level**: The lowest log level that will be output
8
+ *
9
+ * DebugFlags are automatically registered with the DebugFlags singleton when created.
10
+ * They are typically created automatically by Logger instances using the logger's tag.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Created automatically by Logger
15
+ * const logger = new Logger('MyService');
16
+ * // logger._DEBUG_FLAG is a DebugFlag with key 'MyService'
17
+ *
18
+ * // Or manually
19
+ * const flag = DebugFlags.createFlag('CustomTag', LogLevel.Debug);
20
+ * flag.enable();
21
+ * flag.setMinLevel(LogLevel.Warning);
22
+ * ```
23
+ */
24
+ export declare class DebugFlag {
25
+ /** Default minimum log level for new debug flags */
26
+ static DefaultLogLevel: LogLevel;
27
+ /** Unique identifier for this debug flag (typically matches logger tag) */
28
+ private key;
29
+ /** Minimum log level that will be output when this flag is enabled */
30
+ private minLogLevel;
31
+ /**
32
+ * Creates a new DebugFlag and automatically registers it with DebugFlags.
33
+ *
34
+ * @param key - Unique identifier for this flag
35
+ * @param minLogLevel - Minimum log level (defaults to DebugFlag.DefaultLogLevel)
36
+ */
37
+ private constructor();
38
+ /**
39
+ * Sets the minimum log level for this flag.
40
+ *
41
+ * Only log messages at or above this level will be output when the flag is enabled.
42
+ *
43
+ * @param minLogLevel - Minimum log level (Verbose < Debug < Info < Warning < Error)
44
+ */
45
+ setMinLevel(minLogLevel: LogLevel): void;
46
+ /**
47
+ * Renames this debug flag (updates the key).
48
+ *
49
+ * Useful when a logger's tag changes. Updates the registration in DebugFlags.
50
+ *
51
+ * @param newKey - New key/identifier for this flag
52
+ */
53
+ rename(newKey: string): void;
54
+ /**
55
+ * Gets the unique key/identifier for this flag.
56
+ */
57
+ getKey(): string;
58
+ /**
59
+ * Enables or disables this debug flag.
60
+ *
61
+ * When disabled, all logging for this flag is suppressed regardless of log level.
62
+ * When enabled, logging is controlled by the minimum log level.
63
+ *
64
+ * @param enable - If true, enables the flag. If false, disables it. Defaults to true.
65
+ */
66
+ enable(enable?: boolean): void;
67
+ /**
68
+ * Checks if this debug flag is currently enabled.
69
+ *
70
+ * @returns true if enabled, false otherwise
71
+ */
72
+ isEnabled(): boolean;
73
+ /**
74
+ * Checks if a log message at the given level should be output.
75
+ *
76
+ * Returns true if:
77
+ * - The flag is enabled, AND
78
+ * - The log level is at or above the minimum log level
79
+ *
80
+ * @param level - Log level to check
81
+ * @returns true if the message should be logged, false otherwise
82
+ */
83
+ canLog(level: LogLevel): boolean;
84
+ /**
85
+ * Enables this flag by adding it to the active flags list.
86
+ */
87
+ private _enable;
88
+ /**
89
+ * Disables this flag by removing it from the active flags list.
90
+ */
91
+ private _disable;
92
+ }
93
+ /**
94
+ * Singleton manager for all debug flags in the application.
95
+ *
96
+ * Maintains a registry of all DebugFlag instances and tracks which flags are
97
+ * currently active (enabled). Provides factory methods for creating flags.
98
+ *
99
+ * DebugFlags are used throughout the application to control logging granularity
100
+ * - you can enable/disable logging for specific modules or services by toggling
101
+ * their associated debug flags.
102
+ */
103
+ export declare class DebugFlags {
104
+ /** Singleton instance of DebugFlags */
105
+ static readonly instance: DebugFlags;
106
+ /** Registry of all debug flags, keyed by their identifier */
107
+ readonly AllDebugFlags: {
108
+ [k: string]: DebugFlag;
109
+ };
110
+ /** List of keys for currently enabled (active) debug flags */
111
+ readonly ActiveDebugFlags: string[];
112
+ /**
113
+ * Private constructor enforces singleton pattern.
114
+ */
115
+ private constructor();
116
+ /**
117
+ * Creates a new DebugFlag and registers it.
118
+ *
119
+ * This is the only way to create DebugFlag instances (constructor is private).
120
+ * The flag is automatically registered in AllDebugFlags.
121
+ *
122
+ * @param key - Unique identifier for the flag
123
+ * @param minLogLevel - Minimum log level (defaults to DebugFlag.DefaultLogLevel)
124
+ * @returns The newly created DebugFlag
125
+ */
126
+ static createFlag(key: string, minLogLevel?: LogLevel): any;
127
+ /**
128
+ * Registers a debug flag in the AllDebugFlags registry.
129
+ *
130
+ * Called automatically when a DebugFlag is created. Should not be called directly.
131
+ *
132
+ * @param flag - DebugFlag to register
133
+ */
134
+ static add(flag: DebugFlag): void;
135
+ /**
136
+ * Renames a debug flag by updating its key in the registry.
137
+ *
138
+ * Moves the flag from the old key to the new key in AllDebugFlags.
139
+ * Also updates the flag's internal key via the flag's rename method.
140
+ *
141
+ * @param previousKey - Current key of the flag
142
+ * @param newKey - New key for the flag
143
+ */
144
+ static rename(previousKey: string, newKey: string): void;
145
+ }