Changing more loggings levels.

refs #135
This commit is contained in:
softsimon 2020-10-13 16:58:48 +07:00
parent 3d374fd9d9
commit b98b979dc8
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -75,25 +75,6 @@ class Logger {
})(this);
}
private tag() {
let e, stack, stacklevel, tag;
stacklevel = 4;
try {
const err = new Error().stack;
if (err) {
stack = err.replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@').split('\n');
tag = stack[stacklevel].split(' ')[1];
tag = '(' + tag.split('/').reverse()[0];
} else {
tag = '';
}
} catch (_error) {
e = _error;
tag = '';
}
return tag;
}
private msg(priority, msg) {
let consolemsg, prionum, syslogmsg;
if (typeof msg === 'string' && msg.length > 0) {
@ -102,8 +83,7 @@ class Logger {
}
}
prionum = Logger.priorities[priority] || Logger.priorities.info;
const tag = this.tag();
syslogmsg = `<${(this.fac * 8 + prionum)}> ${this.name}[${process.pid}]: ${tag}: ${priority.toUpperCase()} ${msg}`;
syslogmsg = `<${(this.fac * 8 + prionum)}> ${this.name}[${process.pid}]: ${priority.toUpperCase()} ${msg}`;
consolemsg = `${this.ts()} [${process.pid}] ${priority.toUpperCase()}: ${msg}`;
this.syslog(syslogmsg);