navi-hey 0.4.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.
- package/bin/navi.js +9 -0
- package/lib/exceptions/AppError.js +13 -0
- package/lib/exceptions/ClientNotFound.js +16 -0
- package/lib/exceptions/ConfigurationFileNotFound.js +10 -0
- package/lib/exceptions/ConfigurationFileNotProvided.js +10 -0
- package/lib/exceptions/InvalidResponseBody.js +19 -0
- package/lib/exceptions/ItemNotFound.js +16 -0
- package/lib/exceptions/LockedByOtherWorker.js +14 -0
- package/lib/exceptions/MissingActionResource.js +13 -0
- package/lib/exceptions/MissingClientsConfig.js +14 -0
- package/lib/exceptions/MissingMappingVariable.js +17 -0
- package/lib/exceptions/MissingResourceConfig.js +14 -0
- package/lib/exceptions/MissingTopLevelConfgKey.js +15 -0
- package/lib/exceptions/NullResponse.js +13 -0
- package/lib/exceptions/RequestFailed.js +16 -0
- package/lib/exceptions/ResourceNotFound.js +16 -0
- package/lib/factories/Factory.js +79 -0
- package/lib/factories/JobFactory.js +82 -0
- package/lib/factories/WorkerFactory.js +35 -0
- package/lib/models/ActionEnqueuer.js +34 -0
- package/lib/models/ActionProcessingJob.js +51 -0
- package/lib/models/ActionsEnqueuer.js +42 -0
- package/lib/models/Config.js +68 -0
- package/lib/models/Job.js +87 -0
- package/lib/models/ParametersMapper.js +43 -0
- package/lib/models/PathResolver.js +77 -0
- package/lib/models/PathSegmentTraverser.js +82 -0
- package/lib/models/Resource.js +47 -0
- package/lib/models/ResourceRequest.js +80 -0
- package/lib/models/ResourceRequestAction.js +73 -0
- package/lib/models/ResourceRequestJob.js +61 -0
- package/lib/models/ResponseParser.js +36 -0
- package/lib/models/ResponseWrapper.js +86 -0
- package/lib/models/WebConfig.js +15 -0
- package/lib/models/Worker.js +57 -0
- package/lib/models/WorkersConfig.js +18 -0
- package/lib/registry/ClientRegistry.js +92 -0
- package/lib/registry/JobRegistry.js +125 -0
- package/lib/registry/JobRegistryInstance.js +149 -0
- package/lib/registry/NamedRegistry.js +73 -0
- package/lib/registry/ResourceRegistry.js +91 -0
- package/lib/registry/WorkersRegistry.js +106 -0
- package/lib/registry/WorkersRegistryInstance.js +139 -0
- package/lib/server/RequestHandler.js +15 -0
- package/lib/server/RouteRegister.js +27 -0
- package/lib/server/Router.js +44 -0
- package/lib/server/StatsRequestHandler.js +31 -0
- package/lib/server/WebServer.js +45 -0
- package/lib/services/Application.js +113 -0
- package/lib/services/ArgumentsParser.js +36 -0
- package/lib/services/Client.js +108 -0
- package/lib/services/ConfigLoader.js +75 -0
- package/lib/services/ConfigParser.js +131 -0
- package/lib/services/Engine.js +67 -0
- package/lib/services/WorkersAllocator.js +74 -0
- package/lib/utils/EnvResolver.js +53 -0
- package/lib/utils/PromiseAggregator.js +37 -0
- package/lib/utils/ResourceRequestCollector.js +35 -0
- package/lib/utils/collections/Collection.js +17 -0
- package/lib/utils/collections/IdentifyableCollection.js +86 -0
- package/lib/utils/collections/Queue.js +45 -0
- package/lib/utils/collections/SortedArrayMerger.js +84 -0
- package/lib/utils/collections/SortedArraySearcher.js +101 -0
- package/lib/utils/collections/SortedCollection.js +169 -0
- package/lib/utils/generators/IdGenerator.js +79 -0
- package/lib/utils/generators/IncrementalIdGenerator.js +25 -0
- package/lib/utils/generators/UUidGenerator.js +49 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/logging/BaseLogger.js +93 -0
- package/lib/utils/logging/BufferedLogger.js +91 -0
- package/lib/utils/logging/ConsoleLogger.js +19 -0
- package/lib/utils/logging/Log.js +70 -0
- package/lib/utils/logging/LogBuffer.js +101 -0
- package/lib/utils/logging/LogFactory.js +32 -0
- package/lib/utils/logging/Logger.js +134 -0
- package/lib/utils/logging/LoggerGroup.js +100 -0
- package/package.json +78 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseLogger } from './BaseLogger.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Logger that writes output to the browser/Node.js console.
|
|
5
|
+
* @author darthjee
|
|
6
|
+
*/
|
|
7
|
+
class ConsoleLogger extends BaseLogger {
|
|
8
|
+
/**
|
|
9
|
+
* Writes a message to the console at the given level.
|
|
10
|
+
* @param {string} level - One of 'debug', 'info', 'warn', 'error'.
|
|
11
|
+
* @param {string} message - The message to output.
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
_output(level, message) {
|
|
15
|
+
console[level](message); // eslint-disable-line no-console
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { ConsoleLogger };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single log entry with id, level, message and timestamp.
|
|
3
|
+
* @author darthjee
|
|
4
|
+
*/
|
|
5
|
+
class Log {
|
|
6
|
+
#id;
|
|
7
|
+
#level;
|
|
8
|
+
#message;
|
|
9
|
+
#timestamp;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Log instance.
|
|
13
|
+
* @param {number} id - Unique incremental identifier for this log.
|
|
14
|
+
* @param {string} level - The log level (debug, info, warn, error).
|
|
15
|
+
* @param {string} message - The log message.
|
|
16
|
+
*/
|
|
17
|
+
constructor(id, level, message) {
|
|
18
|
+
this.#id = id;
|
|
19
|
+
this.#level = level;
|
|
20
|
+
this.#message = message;
|
|
21
|
+
this.#timestamp = new Date();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Gets the log ID.
|
|
26
|
+
* @returns {number} The log ID.
|
|
27
|
+
*/
|
|
28
|
+
get id() {
|
|
29
|
+
return this.#id;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the log level.
|
|
34
|
+
* @returns {string} The log level.
|
|
35
|
+
*/
|
|
36
|
+
get level() {
|
|
37
|
+
return this.#level;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Gets the log message.
|
|
42
|
+
* @returns {string} The log message.
|
|
43
|
+
*/
|
|
44
|
+
get message() {
|
|
45
|
+
return this.#message;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Gets the log timestamp.
|
|
50
|
+
* @returns {Date} The timestamp when the log was created.
|
|
51
|
+
*/
|
|
52
|
+
get timestamp() {
|
|
53
|
+
return this.#timestamp;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Converts the log to a plain object.
|
|
58
|
+
* @returns {object} Plain object representation of the log.
|
|
59
|
+
*/
|
|
60
|
+
toJSON() {
|
|
61
|
+
return {
|
|
62
|
+
id: this.#id,
|
|
63
|
+
level: this.#level,
|
|
64
|
+
message: this.#message,
|
|
65
|
+
timestamp: this.#timestamp.toISOString()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { Log };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { LogFactory } from './LogFactory.js';
|
|
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
|
+
* @returns {import('./Log.js').Log} The created log entry.
|
|
29
|
+
*/
|
|
30
|
+
add(level, message) {
|
|
31
|
+
const log = this.#factory.build(level, message);
|
|
32
|
+
|
|
33
|
+
this.#logs.push(log);
|
|
34
|
+
|
|
35
|
+
if (this.#logs.length > this.#retention) {
|
|
36
|
+
this.#logs.shift();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return log;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets all logs in the buffer.
|
|
44
|
+
* @returns {Array<Log>} Array of log entries.
|
|
45
|
+
*/
|
|
46
|
+
getLogs() {
|
|
47
|
+
return [...this.#logs];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets a specific log by ID.
|
|
52
|
+
* @param {number} id - The log ID to find.
|
|
53
|
+
* @returns {Log|undefined} The log entry or undefined if not found.
|
|
54
|
+
*/
|
|
55
|
+
getLogById(id) {
|
|
56
|
+
return this.#logs.find(log => log.id === id);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Gets logs filtered by level.
|
|
61
|
+
* @param {string} level - The log level to filter by.
|
|
62
|
+
* @returns {Array<Log>} Array of log entries matching the level.
|
|
63
|
+
*/
|
|
64
|
+
getLogsByLevel(level) {
|
|
65
|
+
return this.#logs.filter(log => log.level === level);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Clears all logs from the buffer.
|
|
70
|
+
* @returns {void}
|
|
71
|
+
*/
|
|
72
|
+
clear() {
|
|
73
|
+
this.#logs = [];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Gets the current number of logs in the buffer.
|
|
78
|
+
* @returns {number} The number of logs.
|
|
79
|
+
*/
|
|
80
|
+
get size() {
|
|
81
|
+
return this.#logs.length;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Gets the retention limit.
|
|
86
|
+
* @returns {number} The maximum number of logs to retain.
|
|
87
|
+
*/
|
|
88
|
+
get retention() {
|
|
89
|
+
return this.#retention;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Converts all logs to JSON array.
|
|
94
|
+
* @returns {Array<object>} Array of log objects.
|
|
95
|
+
*/
|
|
96
|
+
toJSON() {
|
|
97
|
+
return this.#logs.map(log => log.toJSON());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { LogBuffer };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Log } from './Log.js';
|
|
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
|
+
* @returns {Log} The created log entry.
|
|
25
|
+
*/
|
|
26
|
+
build(level, message) {
|
|
27
|
+
const id = this.#idGenerator.generate();
|
|
28
|
+
return new Log(id, level, message);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { LogFactory };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ConsoleLogger } from './ConsoleLogger.js';
|
|
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
|
+
* @returns {void}
|
|
46
|
+
*/
|
|
47
|
+
static debug(message) {
|
|
48
|
+
this.default().debug(message);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Logs an info message using the default logger instance.
|
|
53
|
+
* @param {string} message - The message to log.
|
|
54
|
+
* @returns {void}
|
|
55
|
+
*/
|
|
56
|
+
static info(message) {
|
|
57
|
+
this.default().info(message);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Logs a warn message using the default logger instance.
|
|
62
|
+
* @param {string} message - The message to log.
|
|
63
|
+
* @returns {void}
|
|
64
|
+
*/
|
|
65
|
+
static warn(message) {
|
|
66
|
+
this.default().warn(message);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Logs an error message using the default logger instance.
|
|
71
|
+
* @param {string} message - The message to log.
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
static error(message) {
|
|
75
|
+
this.default().error(message);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Suppresses or restores log output on the default logger instance.
|
|
80
|
+
* @param {boolean} [value=true] - When true, all log output is suppressed.
|
|
81
|
+
* @returns {void}
|
|
82
|
+
*/
|
|
83
|
+
static suppress(value = true) {
|
|
84
|
+
this.default().suppress(value);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Sets the log level threshold on the default logger instance.
|
|
89
|
+
* @param {string} level - The new log level ('debug', 'info', 'warn', 'error', 'silent').
|
|
90
|
+
* @returns {void}
|
|
91
|
+
*/
|
|
92
|
+
static setLevel(level) {
|
|
93
|
+
this.default().setLevel(level);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resets the default logger group so a new one is created on the next call to default().
|
|
98
|
+
* Useful in tests to ensure a clean singleton state.
|
|
99
|
+
* @returns {void}
|
|
100
|
+
*/
|
|
101
|
+
static reset() {
|
|
102
|
+
this.#loggerGroup = null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Replaces the default logger group with a new LoggerGroup containing the provided logger.
|
|
107
|
+
* @param {BaseLogger} logger - The logger instance to use in the new group.
|
|
108
|
+
* @returns {void}
|
|
109
|
+
*/
|
|
110
|
+
static setLogger(logger) {
|
|
111
|
+
this.#loggerGroup = new LoggerGroup([logger]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Adds a logger to the default logger group.
|
|
116
|
+
* @param {BaseLogger} logger - The logger instance to add.
|
|
117
|
+
* @returns {void}
|
|
118
|
+
*/
|
|
119
|
+
static addLogger(logger) {
|
|
120
|
+
this.default().addLogger(logger);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Ensures the default LoggerGroup instance exists, creating one with a ConsoleLogger if needed.
|
|
125
|
+
* @returns {void}
|
|
126
|
+
*/
|
|
127
|
+
static #ensureLoggerGroup() {
|
|
128
|
+
if (!this.#loggerGroup) {
|
|
129
|
+
this.#loggerGroup = new LoggerGroup([new ConsoleLogger()]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { Logger };
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
debug(message) {
|
|
51
|
+
this.#loggers.forEach(logger => logger.debug(message));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Broadcasts an info message to all loggers in the group.
|
|
56
|
+
* @param {string} message - The message to log.
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
info(message) {
|
|
60
|
+
this.#loggers.forEach(logger => logger.info(message));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Broadcasts a warn message to all loggers in the group.
|
|
65
|
+
* @param {string} message - The message to log.
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
warn(message) {
|
|
69
|
+
this.#loggers.forEach(logger => logger.warn(message));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Broadcasts an error message to all loggers in the group.
|
|
74
|
+
* @param {string} message - The message to log.
|
|
75
|
+
* @returns {void}
|
|
76
|
+
*/
|
|
77
|
+
error(message) {
|
|
78
|
+
this.#loggers.forEach(logger => logger.error(message));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Suppresses or restores log output on all loggers in the group.
|
|
83
|
+
* @param {boolean} [value=true] - When true, all log output is suppressed.
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
suppress(value = true) {
|
|
87
|
+
this.#loggers.forEach(logger => logger.suppress(value));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Sets the log level threshold on all loggers in the group.
|
|
92
|
+
* @param {string} level - The new log level ('debug', 'info', 'warn', 'error', 'silent').
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
95
|
+
setLevel(level) {
|
|
96
|
+
this.#loggers.forEach(logger => logger.setLevel(level));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { LoggerGroup };
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "navi-hey",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"description": "Navi cache warmer CLI",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"navi-hey": "bin/navi.js"
|
|
9
|
+
},
|
|
10
|
+
"files": ["bin", "lib"],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"spec": "npx jasmine spec/**/*.js",
|
|
13
|
+
"test": "npx c8 jasmine spec/**/*.js",
|
|
14
|
+
"coverage": "npx c8 --reporter=lcov jasmine spec/**/*.js",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"lint_fix": "eslint . --fix",
|
|
17
|
+
"lint_report": "eslint . --format html --output-file report/eslint-report.html",
|
|
18
|
+
"report": "jscpd lib spec --reporters console,html --output ./report/jscpd",
|
|
19
|
+
"docs": "jsdoc -c jsdoc.json",
|
|
20
|
+
"check_docs": "jsdoc -c jsdoc.json --pedantic"
|
|
21
|
+
},
|
|
22
|
+
"author": "darthjee",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"axios": "^1.13.0",
|
|
26
|
+
"express": "5.2.1",
|
|
27
|
+
"yaml": "^2.8.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@eslint/js": "^8.0.0",
|
|
31
|
+
"c8": "11.0.0",
|
|
32
|
+
"eslint": "^8.0.1",
|
|
33
|
+
"eslint-config-standard": "^17.0.0",
|
|
34
|
+
"eslint-plugin-complexity": "^1.0.2",
|
|
35
|
+
"eslint-plugin-import": "^2.26.0",
|
|
36
|
+
"eslint-plugin-jasmine": "^4.1.3",
|
|
37
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
38
|
+
"eslint-plugin-n": "^15.3.0",
|
|
39
|
+
"eslint-plugin-promise": "^6.0.1",
|
|
40
|
+
"eslint-plugin-react": "^7.37.5",
|
|
41
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
42
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
43
|
+
"eslint-plugin-sort-class-members": "1.22.1",
|
|
44
|
+
"globals": "^16.5.0",
|
|
45
|
+
"jasmine": "^5.0.0",
|
|
46
|
+
"jscpd": "4.0.8",
|
|
47
|
+
"jsdoc": "4.0.5"
|
|
48
|
+
},
|
|
49
|
+
"jasmine": {
|
|
50
|
+
"spec_dir": "spec",
|
|
51
|
+
"spec_files": [
|
|
52
|
+
"**/*[sS]pec.js"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"c8": {
|
|
56
|
+
"reporter": [
|
|
57
|
+
"text",
|
|
58
|
+
"html"
|
|
59
|
+
],
|
|
60
|
+
"extension": [
|
|
61
|
+
".js"
|
|
62
|
+
],
|
|
63
|
+
"include": [
|
|
64
|
+
"lib/**/*.js"
|
|
65
|
+
],
|
|
66
|
+
"exclude": [
|
|
67
|
+
"spec/**",
|
|
68
|
+
"coverage/**",
|
|
69
|
+
"report/**"
|
|
70
|
+
],
|
|
71
|
+
"all": true,
|
|
72
|
+
"check-coverage": false,
|
|
73
|
+
"branches": 80,
|
|
74
|
+
"functions": 80,
|
|
75
|
+
"lines": 80,
|
|
76
|
+
"statements": 80
|
|
77
|
+
}
|
|
78
|
+
}
|