Compare commits

..

2 Commits

Author SHA1 Message Date
3b3052fd1c
v1.2.5 2023-03-26 20:54:26 +03:00
991fb36011
loglevel helpers 2023-03-26 20:54:09 +03:00
3 changed files with 22 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@navy.gif/logger", "name": "@navy.gif/logger",
"version": "1.2.4", "version": "1.2.5",
"description": "Logging thing", "description": "Logging thing",
"main": "index.js", "main": "index.js",
"author": "Navy.gif", "author": "Navy.gif",

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])