[mirotalksfu] - add colors log

هذا الالتزام موجود في:
Miroslav Pejic
2022-08-08 20:43:15 +02:00
الأصل 3c879b1a58
التزام d790daa697

عرض الملف

@@ -1,15 +1,48 @@
'use strict';
const Log = {
// mode
reset: '\x1b[0m',
bright: '\x1b[1m',
dim: '\x1b[2m',
underscore: '\x1b[4m',
blink: '\x1b[5m',
reverse: '\x1b[7m',
hidden: '\x1b[8m',
// Foreground (text) colors
fg: {
black: '\x1b[30m',
red: '\x1b[31m',
green: '\x1b[32m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
magenta: '\x1b[35m',
cyan: '\x1b[36m',
white: '\x1b[37m',
crimson: '\x1b[38m',
},
// Background colors
bg: {
black: '\x1b[40m',
red: '\x1b[41m',
green: '\x1b[42m',
yellow: '\x1b[43m',
blue: '\x1b[44m',
magenta: '\x1b[45m',
cyan: '\x1b[46m',
white: '\x1b[47m',
crimson: '\x1b[48m',
},
};
module.exports = class Logger {
constructor(appName, debugOn = true) {
if (appName) this.appName = appName;
else this.appName = 'mirotalksfu';
this.appName = Log.fg.yellow + appName + Log.reset;
this.debugOn = debugOn;
}
debug(msg, op = '') {
if (this.debugOn === false) return;
console.debug('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, op);
if (this.debugOn) console.debug('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, op);
}
log(msg, op = '') {
@@ -29,6 +62,6 @@ module.exports = class Logger {
}
getDataTime() {
return new Date().toISOString().replace(/T/, ' ').replace(/Z/, '');
return Log.fg.cyan + new Date().toISOString().replace(/T/, ' ').replace(/Z/, '') + Log.reset;
}
};