if (additionalInfos === '{}') additionalInfos = ''
else additionalInfos = ' ' + additionalInfos
- return `[${info.label}] ${new Date(info.timestamp).toISOString()} ${info.level}: ${info.message}${additionalInfos}`
+ return `[${info.label}] ${toTimeFormat(info.timestamp)} ${info.level}: ${info.message}${additionalInfos}`
})
const logger = new winston.createLogger({
logLevels[log.level](log)
})
+
+function toTimeFormat (time: string) {
+ const timestamp = Date.parse(time)
+
+ if (isNaN(timestamp) === true) return 'Unknown date'
+
+ return new Date(timestamp).toISOString()
+}
})
const timestampFormatter = winston.format.timestamp({
- format: 'YYYY-MM-dd HH:mm:ss.SSS'
+ format: 'YYYY-MM-DD HH:mm:ss.SSS'
})
const labelFormatter = winston.format.label({
label
maxsize: 5242880,
maxFiles: 5,
format: winston.format.combine(
- timestampFormatter,
+ winston.format.timestamp(),
labelFormatter,
winston.format.splat(),
jsonLoggerFormat