loglevel helpers

This commit is contained in:
Erik 2023-03-26 20:54:09 +03:00
parent 0c155c365e
commit 991fb36011
Signed by: Navy.gif
GPG Key ID: 2532FBBB61C65A68
2 changed files with 21 additions and 0 deletions

View File

@ -36,6 +36,10 @@ class LoggerClient {
return this.#_logLevel; return this.#_logLevel;
} }
get logLevels () {
return Object.keys(this.#_logLevelMapping);
}
setLogLevel (level = 'info') { setLogLevel (level = 'info') {
if (typeof level === 'number') if (typeof level === 'number')
this.#_logLevel = level; this.#_logLevel = level;

View File

@ -54,6 +54,23 @@ class MasterLogger {
} }
get logLevel () {
return this.#_logLevel;
}
get logLevels () {
return Object.keys(this.#_logLevelMapping);
}
setLogLevel (level = 'info') {
if (typeof level === 'number')
this.#_logLevel = level;
else if (typeof level === 'string')
this.#_logLevel = this.#_logLevelMapping[level.toLowerCase()];
else
throw new Error(`Invalid log level type, expected string or number, got ${typeof level}`);
}
attach (shard) { attach (shard) {
shard.on('message', (msg) => { shard.on('message', (msg) => {
if (!msg[this.#_guard]) if (!msg[this.#_guard])