[mirotalk] - add util

This commit is contained in:
Miroslav Pejic
2022-08-09 18:21:08 +02:00
parent fc68692b9c
commit 3b7188466e
+16 -5
View File
@@ -1,5 +1,12 @@
'use strict';
const util = require('util');
const options = {
depth: null,
colors: true,
};
/**
* Log colors
*/
@@ -58,7 +65,11 @@ module.exports = class Logger {
if (this.debugOn) {
this.timeEnd = performance.now();
this.timeElapsedMs = this.getFormatTime(Math.floor(this.timeEnd - this.timeStart));
console.debug('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, op, this.timeElapsedMs);
console.debug(
'[' + this.getDataTime() + '] [' + this.appName + '] ' + msg,
util.inspect(op, options),
this.timeElapsedMs,
);
this.timeStart = performance.now();
}
}
@@ -70,7 +81,7 @@ module.exports = class Logger {
* @returns
*/
log(msg, op = '') {
console.log('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, op);
console.log('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, util.inspect(op, options));
}
/**
@@ -80,7 +91,7 @@ module.exports = class Logger {
* @returns
*/
info(msg, op = '') {
console.info('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, op);
console.info('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, util.inspect(op, options));
}
/**
@@ -90,7 +101,7 @@ module.exports = class Logger {
* @returns
*/
warn(msg, op = '') {
console.warn('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, op);
console.warn('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, util.inspect(op, options));
}
/**
@@ -100,7 +111,7 @@ module.exports = class Logger {
* @returns
*/
error(msg, op = '') {
console.error('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, op);
console.error('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, util.inspect(op, options));
}
/**