Unverified Commit 862c67df authored by Junwei Sun's avatar Junwei Sun Committed by GitHub
Browse files

hotfix: fix time format issue (#4108)

parent a6069165
......@@ -75,15 +75,17 @@ export class Logger {
return;
}
// `time.toLocaleString('sv')` trick does not work for Windows
const isoTime = new Date(new Date().toLocaleString() + ' UTC').toISOString();
const time = isoTime.slice(0, 10) + ' ' + isoTime.slice(11, 19);
const zeroPad = (num: number): string => num.toString().padStart(2, '0');
const now = new Date();
const date = now.getFullYear() + '-' + zeroPad(now.getMonth() + 1) + '-' + zeroPad(now.getDate());
const time = zeroPad(now.getHours()) + ':' + zeroPad(now.getMinutes()) + ':' + zeroPad(now.getSeconds());
const datetime = date + ' ' + time;
const levelName = levelNames.has(level) ? levelNames.get(level) : level.toString();
const message = args.map(arg => (typeof arg === 'string' ? arg : util.inspect(arg))).join(' ');
const record = `[${time}] ${levelName} (${this.name}) ${message}\n`;
const record = `[${datetime}] ${levelName} (${this.name}) ${message}\n`;
if (logFile === undefined) {
console.log(record);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment