navi-hey 1.2.0 → 1.2.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/lib/common/utils/EnvResolver.js +26 -0
- package/lib/common/utils/env_resolver/EnvStringResolver.js +52 -0
- package/lib/common/utils/logging/BaseLogger.js +98 -0
- package/lib/common/utils/logging/BufferedLogger.js +100 -0
- package/lib/common/utils/logging/ConsoleLogger.js +20 -0
- package/lib/common/utils/logging/Log.js +82 -0
- package/lib/common/utils/logging/LogBuffer.js +122 -0
- package/lib/common/utils/logging/LogBufferCollection.js +56 -0
- package/lib/common/utils/logging/LogContext.js +51 -0
- package/lib/common/utils/logging/LogFactory.js +33 -0
- package/lib/common/utils/logging/LogFilter.js +34 -0
- package/lib/common/utils/logging/Logger.js +138 -0
- package/lib/common/utils/logging/LoggerGroup.js +104 -0
- package/lib/models/configs/Link.js +36 -0
- package/lib/models/configs/WebConfig.js +5 -1
- package/lib/server/Router.js +2 -0
- package/lib/server/handlers/LinksRequestHandler.js +32 -0
- package/lib/services/ConfigLoader.js +3 -3
- package/lib/utils/logging/BaseLogger.js +1 -98
- package/lib/utils/logging/BufferedLogger.js +1 -100
- package/lib/utils/logging/ConsoleLogger.js +1 -20
- package/lib/utils/logging/Log.js +1 -82
- package/lib/utils/logging/LogBuffer.js +1 -122
- package/lib/utils/logging/LogBufferCollection.js +1 -56
- package/lib/utils/logging/LogContext.js +1 -51
- package/lib/utils/logging/LogFactory.js +1 -33
- package/lib/utils/logging/LogFilter.js +1 -34
- package/lib/utils/logging/Logger.js +1 -138
- package/lib/utils/logging/LoggerGroup.js +1 -104
- package/package.json +1 -1
- package/static/assets/index-CX_uXu4Q.js +11 -0
- package/static/favicon.png +0 -0
- package/static/index.html +2 -1
- package/lib/utils/EnvResolver.js +0 -75
- package/static/assets/index-D5tOOLpl.js +0 -11
|
@@ -1,122 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* LogBuffer manages a limited collection of log entries with automatic retention.
|
|
5
|
-
* When the retention limit is reached, the oldest logs are automatically discarded.
|
|
6
|
-
* @author darthjee
|
|
7
|
-
*/
|
|
8
|
-
class LogBuffer {
|
|
9
|
-
#logs;
|
|
10
|
-
#retention;
|
|
11
|
-
#factory;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new LogBuffer instance.
|
|
15
|
-
* @param {number} [retention=100] - Maximum number of logs to retain.
|
|
16
|
-
*/
|
|
17
|
-
constructor(retention = 100) {
|
|
18
|
-
this.#logs = [];
|
|
19
|
-
this.#retention = retention;
|
|
20
|
-
this.#factory = new LogFactory();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Adds a new log entry to the buffer.
|
|
25
|
-
* If retention limit is reached, removes the oldest log.
|
|
26
|
-
* @param {string} level - The log level.
|
|
27
|
-
* @param {string} message - The log message.
|
|
28
|
-
* @param {object} [attributes={}] - Optional structured metadata for the log entry.
|
|
29
|
-
* @returns {import('./Log.js').Log} The created log entry.
|
|
30
|
-
*/
|
|
31
|
-
add(level, message, attributes = {}) {
|
|
32
|
-
const log = this.#factory.build(level, message, attributes);
|
|
33
|
-
|
|
34
|
-
this.#logs.unshift(log);
|
|
35
|
-
|
|
36
|
-
if (this.#logs.length > this.#retention) {
|
|
37
|
-
this.#logs.pop();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return log;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Gets all logs in the buffer.
|
|
45
|
-
* @returns {Array<Log>} Array of log entries.
|
|
46
|
-
*/
|
|
47
|
-
getLogs() {
|
|
48
|
-
return [...this.#logs].reverse();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Gets a specific log by ID.
|
|
53
|
-
* @param {number} id - The log ID to find.
|
|
54
|
-
* @returns {Log|undefined} The log entry or undefined if not found.
|
|
55
|
-
*/
|
|
56
|
-
getLogById(id) {
|
|
57
|
-
return this.#logs.find(log => log.id === id);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Gets logs filtered by level.
|
|
62
|
-
* @param {string} level - The log level to filter by.
|
|
63
|
-
* @returns {Array<Log>} Array of log entries matching the level.
|
|
64
|
-
*/
|
|
65
|
-
getLogsByLevel(level) {
|
|
66
|
-
return this.#logs.filter(log => log.level === level).reverse();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Appends an existing Log instance to the buffer, respecting the retention limit.
|
|
71
|
-
* @param {import('./Log.js').Log} log - The Log instance to append.
|
|
72
|
-
* @returns {void}
|
|
73
|
-
*/
|
|
74
|
-
push(log) {
|
|
75
|
-
this.#logs.unshift(log);
|
|
76
|
-
if (this.#logs.length > this.#retention) {
|
|
77
|
-
this.#logs.pop();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Returns the most recently added log, or undefined if the buffer is empty.
|
|
83
|
-
* @returns {import('./Log.js').Log|undefined} The most recently added log entry, or undefined.
|
|
84
|
-
*/
|
|
85
|
-
get latestLog() {
|
|
86
|
-
return this.#logs[0];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Clears all logs from the buffer.
|
|
91
|
-
* @returns {void}
|
|
92
|
-
*/
|
|
93
|
-
clear() {
|
|
94
|
-
this.#logs = [];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Gets the current number of logs in the buffer.
|
|
99
|
-
* @returns {number} The number of logs.
|
|
100
|
-
*/
|
|
101
|
-
get size() {
|
|
102
|
-
return this.#logs.length;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Gets the retention limit.
|
|
107
|
-
* @returns {number} The maximum number of logs to retain.
|
|
108
|
-
*/
|
|
109
|
-
get retention() {
|
|
110
|
-
return this.#retention;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Converts all logs to JSON array.
|
|
115
|
-
* @returns {Array<object>} Array of log objects.
|
|
116
|
-
*/
|
|
117
|
-
toJSON() {
|
|
118
|
-
return [...this.#logs].reverse().map(log => log.toJSON());
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export { LogBuffer };
|
|
1
|
+
export * from '../../common/utils/logging/LogBuffer.js';
|
|
@@ -1,56 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { EngineEvents } from '../../services/EngineEvents.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* LogBufferCollection manages a keyed map of LogBuffer instances.
|
|
6
|
-
* Buffers are created on first use and cleared automatically when the engine stops.
|
|
7
|
-
* @author darthjee
|
|
8
|
-
*/
|
|
9
|
-
class LogBufferCollection {
|
|
10
|
-
#buffers;
|
|
11
|
-
#retention;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {number} [retention=100] - Maximum number of logs to retain per buffer.
|
|
15
|
-
*/
|
|
16
|
-
constructor(retention = 100) {
|
|
17
|
-
this.#buffers = new Map();
|
|
18
|
-
this.#retention = retention;
|
|
19
|
-
EngineEvents.on('stop', () => this.clear());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Appends an existing Log instance to the buffer for the given key.
|
|
24
|
-
* Lazily creates the buffer on first use.
|
|
25
|
-
* @param {string|number} key - The key identifying the buffer (e.g. jobId or workerId).
|
|
26
|
-
* @param {import('./Log.js').Log} log - The Log instance to append.
|
|
27
|
-
* @returns {void}
|
|
28
|
-
*/
|
|
29
|
-
push(key, log) {
|
|
30
|
-
if (!this.#buffers.has(key)) {
|
|
31
|
-
this.#buffers.set(key, new LogBuffer(this.#retention));
|
|
32
|
-
}
|
|
33
|
-
this.#buffers.get(key).push(log);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns all logs for the given key in chronological order (oldest first).
|
|
38
|
-
* Returns an empty array if no buffer exists for that key.
|
|
39
|
-
* @param {string|number} key - The key to look up.
|
|
40
|
-
* @returns {Array<import('./Log.js').Log>} Array of log entries for the given key, oldest first.
|
|
41
|
-
*/
|
|
42
|
-
getLogs(key) {
|
|
43
|
-
if (!this.#buffers.has(key)) return [];
|
|
44
|
-
return this.#buffers.get(key).getLogs();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Removes all per-key buffers.
|
|
49
|
-
* @returns {void}
|
|
50
|
-
*/
|
|
51
|
-
clear() {
|
|
52
|
-
this.#buffers = new Map();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { LogBufferCollection };
|
|
1
|
+
export * from '../../common/utils/logging/LogBufferCollection.js';
|
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* LogContext wraps a fixed set of attributes and forwards log calls to LogRegistry
|
|
5
|
-
* with those attributes merged into every entry.
|
|
6
|
-
* @author darthjee
|
|
7
|
-
*/
|
|
8
|
-
class LogContext {
|
|
9
|
-
#attributes;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {object} attributes Fixed attributes to include on every log entry (e.g. workerId, jobId).
|
|
13
|
-
*/
|
|
14
|
-
constructor(attributes) {
|
|
15
|
-
this.#attributes = attributes;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {string} message The log message.
|
|
20
|
-
* @param {object} [attrs={}] Additional per-call attributes merged with context attributes.
|
|
21
|
-
*/
|
|
22
|
-
debug(message, attrs = {}) {
|
|
23
|
-
LogRegistry.debug(message, { ...this.#attributes, ...attrs });
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {string} message The log message.
|
|
28
|
-
* @param {object} [attrs={}] Additional per-call attributes merged with context attributes.
|
|
29
|
-
*/
|
|
30
|
-
info(message, attrs = {}) {
|
|
31
|
-
LogRegistry.info(message, { ...this.#attributes, ...attrs });
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {string} message The log message.
|
|
36
|
-
* @param {object} [attrs={}] Additional per-call attributes merged with context attributes.
|
|
37
|
-
*/
|
|
38
|
-
warn(message, attrs = {}) {
|
|
39
|
-
LogRegistry.warn(message, { ...this.#attributes, ...attrs });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param {string} message The log message.
|
|
44
|
-
* @param {object} [attrs={}] Additional per-call attributes merged with context attributes.
|
|
45
|
-
*/
|
|
46
|
-
error(message, attrs = {}) {
|
|
47
|
-
LogRegistry.error(message, { ...this.#attributes, ...attrs });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { LogContext };
|
|
1
|
+
export * from '../../common/utils/logging/LogContext.js';
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { IncrementalIdGenerator } from '../generators/IncrementalIdGenerator.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* LogFactory creates Log instances with automatically assigned incremental IDs.
|
|
6
|
-
* @author darthjee
|
|
7
|
-
*/
|
|
8
|
-
class LogFactory {
|
|
9
|
-
#idGenerator;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new LogFactory instance.
|
|
13
|
-
* @param {object} [params={}] - Construction parameters.
|
|
14
|
-
* @param {IncrementalIdGenerator} [params.idGenerator] - The id generator to use.
|
|
15
|
-
*/
|
|
16
|
-
constructor({ idGenerator = new IncrementalIdGenerator() } = {}) {
|
|
17
|
-
this.#idGenerator = idGenerator;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Builds a new Log entry with an auto-assigned id.
|
|
22
|
-
* @param {string} level - The log level.
|
|
23
|
-
* @param {string} message - The log message.
|
|
24
|
-
* @param {object} [attributes={}] - Optional structured metadata for the log entry.
|
|
25
|
-
* @returns {Log} The created log entry.
|
|
26
|
-
*/
|
|
27
|
-
build(level, message, attributes = {}) {
|
|
28
|
-
const id = this.#idGenerator.generate();
|
|
29
|
-
return new Log(id, level, message, attributes);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { LogFactory };
|
|
1
|
+
export * from '../../common/utils/logging/LogFactory.js';
|
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Filters a list of log entries based on query options.
|
|
3
|
-
* @author darthjee
|
|
4
|
-
*/
|
|
5
|
-
class LogFilter {
|
|
6
|
-
#logs;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {Array<import('./Log.js').Log>} logs - The full list of logs to filter (oldest first).
|
|
10
|
-
*/
|
|
11
|
-
constructor(logs) {
|
|
12
|
-
this.#logs = logs;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Returns the filtered log list.
|
|
17
|
-
* @param {object} [options={}] - Filter options.
|
|
18
|
-
* @param {number|string} [options.lastId] - When provided, returns only logs newer than this ID.
|
|
19
|
-
* Returns an empty array if the ID is not found.
|
|
20
|
-
* @returns {Array<import('./Log.js').Log>} Filtered array of log entries.
|
|
21
|
-
*/
|
|
22
|
-
filter({ lastId } = {}) {
|
|
23
|
-
if (lastId === undefined) return this.#logs;
|
|
24
|
-
|
|
25
|
-
const id = parseInt(lastId, 10);
|
|
26
|
-
const index = this.#logs.findIndex(log => log.id === id);
|
|
27
|
-
|
|
28
|
-
if (index === -1) return [];
|
|
29
|
-
|
|
30
|
-
return this.#logs.slice(index + 1);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { LogFilter };
|
|
1
|
+
export * from '../../common/utils/logging/LogFilter.js';
|
|
@@ -1,138 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { LoggerGroup } from './LoggerGroup.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Static facade for the default LoggerGroup singleton.
|
|
6
|
-
* All instance-level log logic lives in BaseLogger / ConsoleLogger / LoggerGroup.
|
|
7
|
-
*
|
|
8
|
-
* @example <caption>Basic logging (default ConsoleLogger)</caption>
|
|
9
|
-
* Logger.info('Server started');
|
|
10
|
-
* Logger.warn('Low memory');
|
|
11
|
-
* Logger.error('Request failed');
|
|
12
|
-
*
|
|
13
|
-
* @example <caption>Swap to a custom logger</caption>
|
|
14
|
-
* Logger.setLogger(myCustomLogger);
|
|
15
|
-
* Logger.info('Now routed through myCustomLogger');
|
|
16
|
-
*
|
|
17
|
-
* @example <caption>Add an extra log destination</caption>
|
|
18
|
-
* const buffered = new BufferedLogger();
|
|
19
|
-
* Logger.addLogger(buffered);
|
|
20
|
-
* Logger.info('Goes to console and buffered logger');
|
|
21
|
-
*
|
|
22
|
-
* @example <caption>Suppress all output</caption>
|
|
23
|
-
* Logger.suppress();
|
|
24
|
-
* Logger.info('This will not be printed');
|
|
25
|
-
* Logger.suppress(false); // restore output
|
|
26
|
-
*
|
|
27
|
-
* @author darthjee
|
|
28
|
-
*/
|
|
29
|
-
class Logger {
|
|
30
|
-
static #loggerGroup;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Returns the default LoggerGroup instance (singleton).
|
|
34
|
-
* Initialized with a ConsoleLogger on first access.
|
|
35
|
-
* @returns {LoggerGroup} The default logger group instance.
|
|
36
|
-
*/
|
|
37
|
-
static default() {
|
|
38
|
-
this.#ensureLoggerGroup();
|
|
39
|
-
return this.#loggerGroup;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Logs a debug message using the default logger instance.
|
|
44
|
-
* @param {string} message - The message to log.
|
|
45
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
46
|
-
* @returns {void}
|
|
47
|
-
*/
|
|
48
|
-
static debug(message, attributes = {}) {
|
|
49
|
-
this.default().debug(message, attributes);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Logs an info message using the default logger instance.
|
|
54
|
-
* @param {string} message - The message to log.
|
|
55
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
56
|
-
* @returns {void}
|
|
57
|
-
*/
|
|
58
|
-
static info(message, attributes = {}) {
|
|
59
|
-
this.default().info(message, attributes);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Logs a warn message using the default logger instance.
|
|
64
|
-
* @param {string} message - The message to log.
|
|
65
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
66
|
-
* @returns {void}
|
|
67
|
-
*/
|
|
68
|
-
static warn(message, attributes = {}) {
|
|
69
|
-
this.default().warn(message, attributes);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Logs an error message using the default logger instance.
|
|
74
|
-
* @param {string} message - The message to log.
|
|
75
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
76
|
-
* @returns {void}
|
|
77
|
-
*/
|
|
78
|
-
static error(message, attributes = {}) {
|
|
79
|
-
this.default().error(message, attributes);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Suppresses or restores log output on the default logger instance.
|
|
84
|
-
* @param {boolean} [value=true] - When true, all log output is suppressed.
|
|
85
|
-
* @returns {void}
|
|
86
|
-
*/
|
|
87
|
-
static suppress(value = true) {
|
|
88
|
-
this.default().suppress(value);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Sets the log level threshold on the default logger instance.
|
|
93
|
-
* @param {string} level - The new log level ('debug', 'info', 'warn', 'error', 'silent').
|
|
94
|
-
* @returns {void}
|
|
95
|
-
*/
|
|
96
|
-
static setLevel(level) {
|
|
97
|
-
this.default().setLevel(level);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Resets the default logger group so a new one is created on the next call to default().
|
|
102
|
-
* Useful in tests to ensure a clean singleton state.
|
|
103
|
-
* @returns {void}
|
|
104
|
-
*/
|
|
105
|
-
static reset() {
|
|
106
|
-
this.#loggerGroup = null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Replaces the default logger group with a new LoggerGroup containing the provided logger.
|
|
111
|
-
* @param {BaseLogger} logger - The logger instance to use in the new group.
|
|
112
|
-
* @returns {void}
|
|
113
|
-
*/
|
|
114
|
-
static setLogger(logger) {
|
|
115
|
-
this.#loggerGroup = new LoggerGroup([logger]);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Adds a logger to the default logger group.
|
|
120
|
-
* @param {BaseLogger} logger - The logger instance to add.
|
|
121
|
-
* @returns {void}
|
|
122
|
-
*/
|
|
123
|
-
static addLogger(logger) {
|
|
124
|
-
this.default().addLogger(logger);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Ensures the default LoggerGroup instance exists, creating one with a ConsoleLogger if needed.
|
|
129
|
-
* @returns {void}
|
|
130
|
-
*/
|
|
131
|
-
static #ensureLoggerGroup() {
|
|
132
|
-
if (!this.#loggerGroup) {
|
|
133
|
-
this.#loggerGroup = new LoggerGroup([new ConsoleLogger()]);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export { Logger };
|
|
1
|
+
export * from '../../common/utils/logging/Logger.js';
|
|
@@ -1,104 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* LoggerGroup broadcasts log messages to multiple Logger instances.
|
|
3
|
-
* Useful for sending the same log output to multiple destinations (console, web, file, etc.).
|
|
4
|
-
* @author darthjee
|
|
5
|
-
*/
|
|
6
|
-
class LoggerGroup {
|
|
7
|
-
#loggers;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new LoggerGroup instance.
|
|
11
|
-
* @param {Array<Logger>} [loggers=[]] - Array of Logger instances to broadcast to.
|
|
12
|
-
*/
|
|
13
|
-
constructor(loggers = []) {
|
|
14
|
-
this.#loggers = loggers;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Adds a logger to the group.
|
|
19
|
-
* @param {Logger} logger - The Logger instance to add.
|
|
20
|
-
* @returns {LoggerGroup} This instance for method chaining.
|
|
21
|
-
*/
|
|
22
|
-
addLogger(logger) {
|
|
23
|
-
this.#loggers.push(logger);
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Removes a logger from the group.
|
|
29
|
-
* @param {Logger} logger - The Logger instance to remove.
|
|
30
|
-
* @returns {LoggerGroup} This instance for method chaining.
|
|
31
|
-
*/
|
|
32
|
-
removeLogger(logger) {
|
|
33
|
-
this.#loggers = this.#loggers.filter(l => l !== logger);
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Returns all loggers in the group.
|
|
39
|
-
* @returns {Array<Logger>} Array of Logger instances.
|
|
40
|
-
*/
|
|
41
|
-
getLoggers() {
|
|
42
|
-
return [...this.#loggers];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Broadcasts a debug message to all loggers in the group.
|
|
47
|
-
* @param {string} message - The message to log.
|
|
48
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
49
|
-
* @returns {void}
|
|
50
|
-
*/
|
|
51
|
-
debug(message, attributes = {}) {
|
|
52
|
-
this.#loggers.forEach(logger => logger.debug(message, attributes));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Broadcasts an info message to all loggers in the group.
|
|
57
|
-
* @param {string} message - The message to log.
|
|
58
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
59
|
-
* @returns {void}
|
|
60
|
-
*/
|
|
61
|
-
info(message, attributes = {}) {
|
|
62
|
-
this.#loggers.forEach(logger => logger.info(message, attributes));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Broadcasts a warn message to all loggers in the group.
|
|
67
|
-
* @param {string} message - The message to log.
|
|
68
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
69
|
-
* @returns {void}
|
|
70
|
-
*/
|
|
71
|
-
warn(message, attributes = {}) {
|
|
72
|
-
this.#loggers.forEach(logger => logger.warn(message, attributes));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Broadcasts an error message to all loggers in the group.
|
|
77
|
-
* @param {string} message - The message to log.
|
|
78
|
-
* @param {object} [attributes={}] - Optional structured metadata.
|
|
79
|
-
* @returns {void}
|
|
80
|
-
*/
|
|
81
|
-
error(message, attributes = {}) {
|
|
82
|
-
this.#loggers.forEach(logger => logger.error(message, attributes));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Suppresses or restores log output on all loggers in the group.
|
|
87
|
-
* @param {boolean} [value=true] - When true, all log output is suppressed.
|
|
88
|
-
* @returns {void}
|
|
89
|
-
*/
|
|
90
|
-
suppress(value = true) {
|
|
91
|
-
this.#loggers.forEach(logger => logger.suppress(value));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Sets the log level threshold on all loggers in the group.
|
|
96
|
-
* @param {string} level - The new log level ('debug', 'info', 'warn', 'error', 'silent').
|
|
97
|
-
* @returns {void}
|
|
98
|
-
*/
|
|
99
|
-
setLevel(level) {
|
|
100
|
-
this.#loggers.forEach(logger => logger.setLevel(level));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export { LoggerGroup };
|
|
1
|
+
export * from '../../common/utils/logging/LoggerGroup.js';
|