content-security-toolkit 1.0.1 → 1.0.2

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 (58) hide show
  1. package/README.md +22 -0
  2. package/dist/core/mediator/handlers/baseEventHandler.d.ts +65 -0
  3. package/dist/core/mediator/handlers/baseEventHandler.js +99 -0
  4. package/dist/core/mediator/handlers/index.d.ts +9 -0
  5. package/dist/core/mediator/handlers/index.js +34 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +1 -0
  8. package/dist/otel.d.ts +24 -0
  9. package/dist/otel.js +87 -0
  10. package/dist/strategies/AbstractStrategy.mediator.d.ts +162 -0
  11. package/dist/strategies/AbstractStrategy.mediator.js +349 -0
  12. package/dist/strategies/DevToolsStrategy copy.d.ts +85 -0
  13. package/dist/strategies/DevToolsStrategy copy.js +362 -0
  14. package/dist/strategies/DevToolsStrategy-detectorManager.d.ts +70 -0
  15. package/dist/strategies/DevToolsStrategy-detectorManager.js +309 -0
  16. package/dist/strategies/DevToolsStrategy-simple.d.ts +75 -0
  17. package/dist/strategies/DevToolsStrategy-simple.js +366 -0
  18. package/dist/strategies/StrategyRegistry.d.ts +133 -0
  19. package/dist/strategies/StrategyRegistry.js +379 -0
  20. package/dist/utils/base/LoggableComponent.d.ts +62 -0
  21. package/dist/utils/base/LoggableComponent.js +95 -0
  22. package/dist/utils/debuggerDetector/debuggerDetectionWorker.d.ts +6 -0
  23. package/dist/utils/debuggerDetector/debuggerDetectionWorker.js +24 -0
  24. package/dist/utils/debuggerDetector/debuggerDetector.d.ts +55 -0
  25. package/dist/utils/debuggerDetector/debuggerDetector.js +158 -0
  26. package/dist/utils/debuggerDetector/firefoxDetector.d.ts +8 -0
  27. package/dist/utils/debuggerDetector/firefoxDetector.js +64 -0
  28. package/dist/utils/detection.d.ts +29 -0
  29. package/dist/utils/detection.js +267 -0
  30. package/dist/utils/detectors/debuggerDetectionWorker.d.ts +6 -0
  31. package/dist/utils/detectors/debuggerDetectionWorker.js +24 -0
  32. package/dist/utils/detectors/firefoxDetector.d.ts +8 -0
  33. package/dist/utils/detectors/firefoxDetector.js +64 -0
  34. package/dist/utils/logging/LogLevel.d.ts +21 -0
  35. package/dist/utils/logging/LogLevel.js +46 -0
  36. package/dist/utils/logging/LoggingConfig.d.ts +68 -0
  37. package/dist/utils/logging/LoggingConfig.js +64 -0
  38. package/dist/utils/logging/LoggingFactory.d.ts +22 -0
  39. package/dist/utils/logging/LoggingFactory.js +61 -0
  40. package/dist/utils/logging/LoggingService.d.ts +235 -0
  41. package/dist/utils/logging/LoggingService.js +385 -0
  42. package/dist/utils/logging/SimpleLoggingService.d.ts +39 -0
  43. package/dist/utils/logging/SimpleLoggingService.js +58 -0
  44. package/dist/utils/logging/advanced/LogLevel.d.ts +21 -0
  45. package/dist/utils/logging/advanced/LogLevel.js +46 -0
  46. package/dist/utils/logging/advanced/LoggingConfig.d.ts +68 -0
  47. package/dist/utils/logging/advanced/LoggingConfig.js +64 -0
  48. package/dist/utils/logging/advanced/LoggingFactory.d.ts +22 -0
  49. package/dist/utils/logging/advanced/LoggingFactory.js +61 -0
  50. package/dist/utils/logging/advanced/LoggingService.d.ts +235 -0
  51. package/dist/utils/logging/advanced/LoggingService.js +385 -0
  52. package/dist/utils/protectedContentManager-simple.d.ts +86 -0
  53. package/dist/utils/protectedContentManager-simple.js +180 -0
  54. package/dist/utils/securityOverlayManager-observer-pause.d.ts +283 -0
  55. package/dist/utils/securityOverlayManager-observer-pause.js +878 -0
  56. package/dist/utils/securityOverlayManager-simple.d.ts +197 -0
  57. package/dist/utils/securityOverlayManager-simple.js +552 -0
  58. package/package.json +1 -1
@@ -0,0 +1,385 @@
1
+ import { LogLevel, getLogLevelName } from "./LogLevel";
2
+ /**
3
+ * Advanced logging service with context tracking, filtering, and performance measurement
4
+ */
5
+ export class LoggingService {
6
+ /**
7
+ * Create a new LoggingService
8
+ * @param options Configuration options
9
+ */
10
+ constructor(options) {
11
+ // Context tracking
12
+ this.contextStack = [];
13
+ this.contextDepth = 0;
14
+ // Component filtering
15
+ this.enabledComponents = null;
16
+ // Level focusing
17
+ this.focusedLevel = null;
18
+ // Console group tracking
19
+ this.groupDepth = 0;
20
+ this.componentName = options.componentName;
21
+ this.currentLevel = options.level ?? LogLevel.INFO;
22
+ this.enabled = options.enabled ?? true;
23
+ this.useColors = options.useColors ?? true;
24
+ this.includeTimestamps = options.includeTimestamps ?? true;
25
+ this.includeComponentName = options.includeComponentName ?? true;
26
+ }
27
+ /**
28
+ * Set the current log level threshold
29
+ * @param level New log level
30
+ */
31
+ setLevel(level) {
32
+ this.currentLevel = level;
33
+ }
34
+ /**
35
+ * Get the current log level
36
+ * @returns The current log level
37
+ */
38
+ getLevel() {
39
+ return this.currentLevel;
40
+ }
41
+ /**
42
+ * Get the current log level name
43
+ * @returns The current log level name
44
+ */
45
+ getLevelName() {
46
+ return getLogLevelName(this.currentLevel);
47
+ }
48
+ /**
49
+ * Enable or disable logging
50
+ * @param enabled Whether logging should be enabled
51
+ */
52
+ setEnabled(enabled) {
53
+ this.enabled = enabled;
54
+ }
55
+ /**
56
+ * Check if logging is enabled
57
+ * @returns Whether logging is enabled
58
+ */
59
+ isEnabled() {
60
+ return this.enabled;
61
+ }
62
+ /**
63
+ * Set components to show logs for
64
+ * @param components Array of component names to enable, or null to enable all
65
+ */
66
+ setEnabledComponents(components) {
67
+ if (components === null) {
68
+ this.enabledComponents = null;
69
+ }
70
+ else {
71
+ this.enabledComponents = new Set(components);
72
+ }
73
+ }
74
+ /**
75
+ * Focus on a specific log level
76
+ * @param level Level to focus on, or null to show all levels
77
+ */
78
+ focusLevel(level) {
79
+ this.focusedLevel = level;
80
+ }
81
+ /**
82
+ * Increase context depth (call when entering a loop or nested function)
83
+ * @param contextName Optional name for the context
84
+ * @returns A function that exits this context when called
85
+ */
86
+ enterContext(contextName = "context") {
87
+ this.contextDepth++;
88
+ const context = {
89
+ name: contextName,
90
+ startTime: performance.now(),
91
+ depth: this.contextDepth,
92
+ };
93
+ this.contextStack.push(context);
94
+ this.trace(`Entering ${contextName}`);
95
+ // Return a function that exits this context
96
+ return () => {
97
+ this.exitContext();
98
+ };
99
+ }
100
+ /**
101
+ * Decrease context depth (call when exiting a loop or nested function)
102
+ */
103
+ exitContext() {
104
+ if (this.contextStack.length > 0) {
105
+ const context = this.contextStack.pop();
106
+ this.contextDepth = Math.max(0, this.contextDepth - 1);
107
+ const duration = performance.now() - context.startTime;
108
+ this.trace(`Exiting ${context.name} (took ${duration.toFixed(2)}ms)`);
109
+ }
110
+ }
111
+ /**
112
+ * Execute a function within a named context
113
+ * @param contextName Name for the context
114
+ * @param fn Function to execute
115
+ * @returns The result of the function
116
+ */
117
+ withContext(contextName, fn) {
118
+ const exitFn = this.enterContext(contextName);
119
+ try {
120
+ return fn();
121
+ }
122
+ finally {
123
+ exitFn();
124
+ }
125
+ }
126
+ /**
127
+ * Execute an async function within a named context
128
+ * @param contextName Name for the context
129
+ * @param fn Async function to execute
130
+ * @returns Promise resolving to the result of the function
131
+ */
132
+ async withContextAsync(contextName, fn) {
133
+ const exitFn = this.enterContext(contextName);
134
+ try {
135
+ return await fn();
136
+ }
137
+ finally {
138
+ exitFn();
139
+ }
140
+ }
141
+ /**
142
+ * Start a console group
143
+ * @param label Label for the group
144
+ * @param collapsed Whether the group should be collapsed
145
+ */
146
+ startGroup(label, collapsed = false) {
147
+ if (!this.shouldLog(LogLevel.INFO))
148
+ return;
149
+ this.groupDepth++;
150
+ if (collapsed) {
151
+ console.groupCollapsed(this.formatMessage(LogLevel.INFO, label));
152
+ }
153
+ else {
154
+ console.group(this.formatMessage(LogLevel.INFO, label));
155
+ }
156
+ }
157
+ /**
158
+ * End the current console group
159
+ */
160
+ endGroup() {
161
+ if (this.groupDepth > 0) {
162
+ console.groupEnd();
163
+ this.groupDepth--;
164
+ }
165
+ }
166
+ /**
167
+ * Execute a function within a console group
168
+ * @param label Label for the group
169
+ * @param fn Function to execute
170
+ * @param collapsed Whether the group should be collapsed
171
+ * @returns The result of the function
172
+ */
173
+ group(label, fn, collapsed = false) {
174
+ this.startGroup(label, collapsed);
175
+ try {
176
+ return fn();
177
+ }
178
+ finally {
179
+ this.endGroup();
180
+ }
181
+ }
182
+ /**
183
+ * Execute an async function within a console group
184
+ * @param label Label for the group
185
+ * @param fn Async function to execute
186
+ * @param collapsed Whether the group should be collapsed
187
+ * @returns Promise resolving to the result of the function
188
+ */
189
+ async groupAsync(label, fn, collapsed = false) {
190
+ this.startGroup(label, collapsed);
191
+ try {
192
+ return await fn();
193
+ }
194
+ finally {
195
+ this.endGroup();
196
+ }
197
+ }
198
+ /**
199
+ * Measure the execution time of a function
200
+ * @param label Label for the timing
201
+ * @param fn Function to measure
202
+ * @returns Object containing the result and duration
203
+ */
204
+ time(label, fn) {
205
+ const start = performance.now();
206
+ const result = fn();
207
+ const duration = performance.now() - start;
208
+ this.info(`${label} took ${duration.toFixed(2)}ms`);
209
+ return { result, duration };
210
+ }
211
+ /**
212
+ * Measure the execution time of an async function
213
+ * @param label Label for the timing
214
+ * @param fn Async function to measure
215
+ * @returns Promise resolving to an object containing the result and duration
216
+ */
217
+ async timeAsync(label, fn) {
218
+ const start = performance.now();
219
+ const result = await fn();
220
+ const duration = performance.now() - start;
221
+ this.info(`${label} took ${duration.toFixed(2)}ms`);
222
+ return { result, duration };
223
+ }
224
+ /**
225
+ * Log with automatic level adjustment based on context depth
226
+ * @param message Message to log
227
+ * @param args Additional arguments to log
228
+ */
229
+ logWithContext(message, ...args) {
230
+ // Adjust level based on nesting - deeper nesting means more detailed level
231
+ const adjustedLevel = Math.min(LogLevel.VERBOSE, LogLevel.INFO + this.contextDepth);
232
+ this.log(adjustedLevel, message, ...args);
233
+ }
234
+ /**
235
+ * Main logging method
236
+ * @param level Log level
237
+ * @param message Message to log
238
+ * @param args Additional arguments to log
239
+ */
240
+ log(level, message, ...args) {
241
+ if (!this.shouldLog(level))
242
+ return;
243
+ const formattedMessage = this.formatMessage(level, message);
244
+ switch (level) {
245
+ case LogLevel.ERROR:
246
+ console.error(formattedMessage, ...args);
247
+ break;
248
+ case LogLevel.WARN:
249
+ console.warn(formattedMessage, ...args);
250
+ break;
251
+ default:
252
+ console.log(formattedMessage, ...args);
253
+ break;
254
+ }
255
+ }
256
+ /**
257
+ * Log an error message
258
+ * @param message Error message
259
+ * @param args Additional arguments to log
260
+ */
261
+ error(message, ...args) {
262
+ this.log(LogLevel.ERROR, message, ...args);
263
+ }
264
+ /**
265
+ * Log a warning message
266
+ * @param message Warning message
267
+ * @param args Additional arguments to log
268
+ */
269
+ warn(message, ...args) {
270
+ this.log(LogLevel.WARN, message, ...args);
271
+ }
272
+ /**
273
+ * Log an info message
274
+ * @param message Info message
275
+ * @param args Additional arguments to log
276
+ */
277
+ info(message, ...args) {
278
+ this.log(LogLevel.INFO, message, ...args);
279
+ }
280
+ /**
281
+ * Log a debug message
282
+ * @param message Debug message
283
+ * @param args Additional arguments to log
284
+ */
285
+ debug(message, ...args) {
286
+ this.log(LogLevel.DEBUG, message, ...args);
287
+ }
288
+ /**
289
+ * Log a trace message
290
+ * @param message Trace message
291
+ * @param args Additional arguments to log
292
+ */
293
+ trace(message, ...args) {
294
+ this.log(LogLevel.TRACE, message, ...args);
295
+ }
296
+ /**
297
+ * Log a verbose message
298
+ * @param message Verbose message
299
+ * @param args Additional arguments to log
300
+ */
301
+ verbose(message, ...args) {
302
+ this.log(LogLevel.VERBOSE, message, ...args);
303
+ }
304
+ /**
305
+ * Check if a message should be logged
306
+ * @param level Log level of the message
307
+ * @returns Whether the message should be logged
308
+ */
309
+ shouldLog(level) {
310
+ // Always log errors and warnings, otherwise respect enabled flag
311
+ if (!this.enabled && level > LogLevel.WARN)
312
+ return false;
313
+ // If we're focusing on a specific level, only log messages at that level
314
+ if (this.focusedLevel !== null) {
315
+ return level === this.focusedLevel || level <= LogLevel.WARN;
316
+ }
317
+ // Otherwise, respect the level threshold
318
+ if (level > this.currentLevel && level > LogLevel.WARN)
319
+ return false;
320
+ // Check if component is enabled
321
+ if (this.enabledComponents !== null && !this.enabledComponents.has(this.componentName)) {
322
+ // Still allow errors and warnings
323
+ return level <= LogLevel.WARN;
324
+ }
325
+ return true;
326
+ }
327
+ /**
328
+ * Format a log message
329
+ * @param level Log level
330
+ * @param message Message to format
331
+ * @returns Formatted message
332
+ */
333
+ formatMessage(level, message) {
334
+ const parts = [];
335
+ // Add timestamp if enabled
336
+ if (this.includeTimestamps) {
337
+ parts.push(this.getTimestamp());
338
+ }
339
+ // Add level prefix
340
+ parts.push(this.getLevelPrefix(level));
341
+ // Add component name if enabled
342
+ if (this.includeComponentName) {
343
+ parts.push(this.componentName);
344
+ }
345
+ // Add indentation based on context depth
346
+ const indentation = " ".repeat(this.contextDepth);
347
+ // Combine all parts
348
+ return `${parts.join(" ")}: ${indentation}${message}`;
349
+ }
350
+ /**
351
+ * Get the current timestamp as a string
352
+ * @returns Formatted timestamp
353
+ */
354
+ getTimestamp() {
355
+ const now = new Date();
356
+ return `[${now.toISOString()}]`;
357
+ }
358
+ /**
359
+ * Get prefix for log level
360
+ * @param level Log level
361
+ * @returns Formatted prefix
362
+ */
363
+ getLevelPrefix(level) {
364
+ if (!this.useColors) {
365
+ return `[${getLogLevelName(level)}]`;
366
+ }
367
+ // Use colors for different levels
368
+ switch (level) {
369
+ case LogLevel.ERROR:
370
+ return "\x1b[31m[ERROR]\x1b[0m"; // Red
371
+ case LogLevel.WARN:
372
+ return "\x1b[33m[WARN]\x1b[0m"; // Yellow
373
+ case LogLevel.INFO:
374
+ return "\x1b[36m[INFO]\x1b[0m"; // Cyan
375
+ case LogLevel.DEBUG:
376
+ return "\x1b[32m[DEBUG]\x1b[0m"; // Green
377
+ case LogLevel.TRACE:
378
+ return "\x1b[35m[TRACE]\x1b[0m"; // Magenta
379
+ case LogLevel.VERBOSE:
380
+ return "\x1b[90m[VERBOSE]\x1b[0m"; // Gray
381
+ default:
382
+ return `[${getLogLevelName(level)}]`;
383
+ }
384
+ }
385
+ }
@@ -0,0 +1,39 @@
1
+ export declare class SimpleLoggingService {
2
+ private componentName;
3
+ private debugMode;
4
+ /**
5
+ * Create a new SimpleLoggingService
6
+ * for consistent logging across the toolkit
7
+ * @param componentName Name of the component for log prefixing
8
+ * @param debugMode Whether debug mode is enabled
9
+ */
10
+ constructor(componentName: string, debugMode?: boolean);
11
+ /**
12
+ * Log a debug message if debug mode is enabled
13
+ * @param message Message to log
14
+ * @param args Additional arguments to log
15
+ */
16
+ log(message: string, ...args: unknown[]): void;
17
+ /**
18
+ * Log a warning message
19
+ * @param message Warning message
20
+ * @param args Additional arguments to log
21
+ */
22
+ warn(message: string, ...args: unknown[]): void;
23
+ /**
24
+ * Log an error message
25
+ * @param message Error message
26
+ * @param args Additional arguments to log
27
+ */
28
+ error(message: string, ...args: unknown[]): void;
29
+ /**
30
+ * Set debug mode
31
+ * @param enabled Whether debug mode should be enabled
32
+ */
33
+ setDebugMode(enabled: boolean): void;
34
+ /**
35
+ * Get current debug mode
36
+ * @returns Whether debug mode is enabled
37
+ */
38
+ isDebugEnabled(): boolean;
39
+ }
@@ -0,0 +1,58 @@
1
+ export class SimpleLoggingService {
2
+ /**
3
+ * Create a new SimpleLoggingService
4
+ * for consistent logging across the toolkit
5
+ * @param componentName Name of the component for log prefixing
6
+ * @param debugMode Whether debug mode is enabled
7
+ */
8
+ constructor(componentName, debugMode = false) {
9
+ this.componentName = componentName;
10
+ this.debugMode = debugMode;
11
+ }
12
+ /**
13
+ * Log a debug message if debug mode is enabled
14
+ * @param message Message to log
15
+ * @param args Additional arguments to log
16
+ */
17
+ log(message, ...args) {
18
+ if (this.debugMode) {
19
+ console.log(`${this.componentName}: ${message}`, ...args);
20
+ }
21
+ }
22
+ /**
23
+ * Log a warning message
24
+ * @param message Warning message
25
+ * @param args Additional arguments to log
26
+ */
27
+ warn(message, ...args) {
28
+ if (this.debugMode) {
29
+ console.warn(`${this.componentName}: ${message}`, ...args);
30
+ }
31
+ else {
32
+ // In non-debug mode, only log the message without args for brevity
33
+ console.warn(`${this.componentName}: ${message}`);
34
+ }
35
+ }
36
+ /**
37
+ * Log an error message
38
+ * @param message Error message
39
+ * @param args Additional arguments to log
40
+ */
41
+ error(message, ...args) {
42
+ console.error(`${this.componentName}: ${message}`, ...args);
43
+ }
44
+ /**
45
+ * Set debug mode
46
+ * @param enabled Whether debug mode should be enabled
47
+ */
48
+ setDebugMode(enabled) {
49
+ this.debugMode = enabled;
50
+ }
51
+ /**
52
+ * Get current debug mode
53
+ * @returns Whether debug mode is enabled
54
+ */
55
+ isDebugEnabled() {
56
+ return this.debugMode;
57
+ }
58
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Enum defining log severity levels
3
+ */
4
+ export declare enum LogLevel {
5
+ ERROR = 0,// Always shown, represents errors that need immediate attention
6
+ WARN = 1,// Important issues that don't break functionality but need attention
7
+ INFO = 2,// General information about application flow
8
+ DEBUG = 3,// Detailed information useful for debugging
9
+ TRACE = 4,// Very detailed information, including loop iterations, function entries/exits
10
+ VERBOSE = 5
11
+ }
12
+ /**
13
+ * Map of log level names to their enum values
14
+ */
15
+ export declare const LOG_LEVEL_MAP: Record<string, LogLevel>;
16
+ /**
17
+ * Get the name of a log level
18
+ * @param level The log level
19
+ * @returns The name of the log level
20
+ */
21
+ export declare function getLogLevelName(level: LogLevel): string;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Enum defining log severity levels
3
+ */
4
+ export var LogLevel;
5
+ (function (LogLevel) {
6
+ LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
7
+ LogLevel[LogLevel["WARN"] = 1] = "WARN";
8
+ LogLevel[LogLevel["INFO"] = 2] = "INFO";
9
+ LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
10
+ LogLevel[LogLevel["TRACE"] = 4] = "TRACE";
11
+ LogLevel[LogLevel["VERBOSE"] = 5] = "VERBOSE";
12
+ })(LogLevel || (LogLevel = {}));
13
+ /**
14
+ * Map of log level names to their enum values
15
+ */
16
+ export const LOG_LEVEL_MAP = {
17
+ error: LogLevel.ERROR,
18
+ warn: LogLevel.WARN,
19
+ info: LogLevel.INFO,
20
+ debug: LogLevel.DEBUG,
21
+ trace: LogLevel.TRACE,
22
+ verbose: LogLevel.VERBOSE,
23
+ };
24
+ /**
25
+ * Get the name of a log level
26
+ * @param level The log level
27
+ * @returns The name of the log level
28
+ */
29
+ export function getLogLevelName(level) {
30
+ switch (level) {
31
+ case LogLevel.ERROR:
32
+ return "ERROR";
33
+ case LogLevel.WARN:
34
+ return "WARN";
35
+ case LogLevel.INFO:
36
+ return "INFO";
37
+ case LogLevel.DEBUG:
38
+ return "DEBUG";
39
+ case LogLevel.TRACE:
40
+ return "TRACE";
41
+ case LogLevel.VERBOSE:
42
+ return "VERBOSE";
43
+ default:
44
+ return "UNKNOWN";
45
+ }
46
+ }
@@ -0,0 +1,68 @@
1
+ import { LogLevel } from "./LogLevel";
2
+ /**
3
+ * Global logging configuration
4
+ */
5
+ export interface LoggingConfig {
6
+ /**
7
+ * Default log level for all components
8
+ * @default LogLevel.INFO
9
+ */
10
+ defaultLevel: LogLevel;
11
+ /**
12
+ * Component-specific log levels
13
+ */
14
+ componentLevels: Record<string, LogLevel>;
15
+ /**
16
+ * Whether to use colors in console output
17
+ * @default true
18
+ */
19
+ useColors: boolean;
20
+ /**
21
+ * Whether to include timestamps in logs
22
+ * @default true
23
+ */
24
+ includeTimestamps: boolean;
25
+ /**
26
+ * Whether to include component names in logs
27
+ * @default true
28
+ */
29
+ includeComponentName: boolean;
30
+ /**
31
+ * Components to enable logging for (null means all)
32
+ */
33
+ enabledComponents: string[] | null;
34
+ /**
35
+ * Level to focus on (null means all levels)
36
+ */
37
+ focusedLevel: LogLevel | null;
38
+ }
39
+ /**
40
+ * Default logging configuration
41
+ */
42
+ export declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
43
+ /**
44
+ * Get the current logging configuration
45
+ * @returns The current logging configuration
46
+ */
47
+ export declare function getLoggingConfig(): LoggingConfig;
48
+ /**
49
+ * Update the logging configuration
50
+ * @param config New configuration (partial)
51
+ */
52
+ export declare function updateLoggingConfig(config: Partial<LoggingConfig>): void;
53
+ /**
54
+ * Reset the logging configuration to defaults
55
+ */
56
+ export declare function resetLoggingConfig(): void;
57
+ /**
58
+ * Get the log level for a specific component
59
+ * @param componentName Component name
60
+ * @returns The log level for the component
61
+ */
62
+ export declare function getComponentLogLevel(componentName: string): LogLevel;
63
+ /**
64
+ * Set the log level for a specific component
65
+ * @param componentName Component name
66
+ * @param level Log level
67
+ */
68
+ export declare function setComponentLogLevel(componentName: string, level: LogLevel): void;
@@ -0,0 +1,64 @@
1
+ import { LogLevel } from "./LogLevel";
2
+ /**
3
+ * Default logging configuration
4
+ */
5
+ export const DEFAULT_LOGGING_CONFIG = {
6
+ defaultLevel: LogLevel.INFO,
7
+ componentLevels: {},
8
+ useColors: true,
9
+ includeTimestamps: true,
10
+ includeComponentName: true,
11
+ enabledComponents: null,
12
+ focusedLevel: null,
13
+ };
14
+ /**
15
+ * Current global logging configuration
16
+ */
17
+ let currentConfig = { ...DEFAULT_LOGGING_CONFIG };
18
+ /**
19
+ * Get the current logging configuration
20
+ * @returns The current logging configuration
21
+ */
22
+ export function getLoggingConfig() {
23
+ return { ...currentConfig };
24
+ }
25
+ /**
26
+ * Update the logging configuration
27
+ * @param config New configuration (partial)
28
+ */
29
+ export function updateLoggingConfig(config) {
30
+ currentConfig = {
31
+ ...currentConfig,
32
+ ...config,
33
+ // Merge component levels
34
+ componentLevels: {
35
+ ...currentConfig.componentLevels,
36
+ ...(config.componentLevels || {}),
37
+ },
38
+ };
39
+ console.log("Updated logging configuration:", currentConfig);
40
+ }
41
+ /**
42
+ * Reset the logging configuration to defaults
43
+ */
44
+ export function resetLoggingConfig() {
45
+ currentConfig = { ...DEFAULT_LOGGING_CONFIG };
46
+ console.log("Reset logging configuration to defaults");
47
+ }
48
+ /**
49
+ * Get the log level for a specific component
50
+ * @param componentName Component name
51
+ * @returns The log level for the component
52
+ */
53
+ export function getComponentLogLevel(componentName) {
54
+ return currentConfig.componentLevels[componentName] || currentConfig.defaultLevel;
55
+ }
56
+ /**
57
+ * Set the log level for a specific component
58
+ * @param componentName Component name
59
+ * @param level Log level
60
+ */
61
+ export function setComponentLogLevel(componentName, level) {
62
+ currentConfig.componentLevels[componentName] = level;
63
+ console.log(`Set log level for ${componentName} to ${LogLevel[level]}`);
64
+ }
@@ -0,0 +1,22 @@
1
+ import { LoggingService } from "./LoggingService";
2
+ /**
3
+ * Factory for creating LoggingService instances
4
+ */
5
+ export declare class LoggingFactory {
6
+ private static instances;
7
+ /**
8
+ * Get a LoggingService instance for a component
9
+ * @param componentName Component name
10
+ * @returns LoggingService instance
11
+ */
12
+ static getLogger(componentName: string): LoggingService;
13
+ /**
14
+ * Update all existing logger instances with current configuration
15
+ */
16
+ static updateAllLoggers(): void;
17
+ /**
18
+ * Get all registered logger instances
19
+ * @returns Map of component names to logger instances
20
+ */
21
+ static getAllLoggers(): Map<string, LoggingService>;
22
+ }