[mirotalksfu] - add timeZone

هذا الالتزام موجود في:
Miroslav Pejic
2024-02-22 11:34:35 +01:00
الأصل cf8a450f6e
التزام 0e33b1210f

عرض الملف

@@ -26,7 +26,7 @@ module.exports = class Logger {
this.timeEnd = Date.now(); this.timeEnd = Date.now();
this.timeElapsedMs = this.getFormatTime(Math.floor(this.timeEnd - this.timeStart)); this.timeElapsedMs = this.getFormatTime(Math.floor(this.timeEnd - this.timeStart));
console.debug( console.debug(
'[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, '[' + this.getDateTime() + '] [' + this.appName + '] ' + msg,
util.inspect(op, options), util.inspect(op, options),
this.timeElapsedMs, this.timeElapsedMs,
); );
@@ -35,32 +35,35 @@ module.exports = class Logger {
} }
log(msg, op = '') { log(msg, op = '') {
console.log('[' + this.getDataTime() + '] [' + this.appName + '] ' + msg, util.inspect(op, options)); console.log('[' + this.getDateTime() + '] [' + this.appName + '] ' + msg, util.inspect(op, options));
} }
info(msg, op = '') { info(msg, op = '') {
console.info( console.info(
'[' + this.getDataTime() + '] [' + this.appName + '] ' + colors.green(msg), '[' + this.getDateTime() + '] [' + this.appName + '] ' + colors.green(msg),
util.inspect(op, options), util.inspect(op, options),
); );
} }
warn(msg, op = '') { warn(msg, op = '') {
console.warn( console.warn(
'[' + this.getDataTime() + '] [' + this.appName + '] ' + colors.yellow(msg), '[' + this.getDateTime() + '] [' + this.appName + '] ' + colors.yellow(msg),
util.inspect(op, options), util.inspect(op, options),
); );
} }
error(msg, op = '') { error(msg, op = '') {
console.error( console.error(
'[' + this.getDataTime() + '] [' + this.appName + '] ' + colors.red(msg), '[' + this.getDateTime() + '] [' + this.appName + '] ' + colors.red(msg),
util.inspect(op, options), util.inspect(op, options),
); );
} }
getDataTime() { getDateTime() {
return colors.cyan(new Date().toISOString().replace(/T/, ' ').replace(/Z/, '')); const options = {
timeZone: process.env.TZ || 'UTC',
};
return colors.cyan(new Date().toLocaleString('en-US', options));
} }
getFormatTime(ms) { getFormatTime(ms) {