improve InternalConsole

This commit is contained in:
SrGooglo 2023-05-11 18:10:31 +02:00
parent 75f364d52e
commit c823b81dda

View File

@ -1,37 +1,36 @@
module.exports = class InternalConsole { module.exports = class InternalConsole {
static log = (...args) => { constructor(params = {}) {
if (!global.consoleSilent) { this.params = params
console.log(...args)
}
} }
static error = (...args) => { exec = (type, ...args) => {
if (!global.consoleSilent) { if (global.consoleSilent) {
console.error(...args) return false
} }
// fix unsupported types
switch (type) {
case "table": {
return console.table(...args)
}
}
if (this.params.server_name) {
args.unshift(`[${this.params.server_name}]`)
}
return console[type](...args)
} }
static warn = (...args) => { log = (...args) => this.exec("log", ...args)
if (!global.consoleSilent) {
console.warn(...args)
}
}
static info = (...args) => { error = (...args) => this.exec("error", ...args)
if (!global.consoleSilent) {
console.info(...args)
}
}
static debug = (...args) => { warn = (...args) => this.exec("warn", ...args)
if (!global.consoleSilent) {
console.debug(...args)
}
}
static table = (...args) => { info = (...args) => this.exec("info", ...args)
if (!global.consoleSilent) {
console.table(...args) debug = (...args) => this.exec("debug", ...args)
}
} table = (...args) => this.exec("table", ...args)
} }