diff options
-rwxr-xr-x | scripts/parse-log.ts | 10 | ||||
-rw-r--r-- | server/helpers/logger.ts | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index 9429512b7..2c5ef696d 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts | |||
@@ -21,7 +21,7 @@ const loggerFormat = winston.format.printf((info) => { | |||
21 | if (additionalInfos === '{}') additionalInfos = '' | 21 | if (additionalInfos === '{}') additionalInfos = '' |
22 | else additionalInfos = ' ' + additionalInfos | 22 | else additionalInfos = ' ' + additionalInfos |
23 | 23 | ||
24 | return `[${info.label}] ${new Date(info.timestamp).toISOString()} ${info.level}: ${info.message}${additionalInfos}` | 24 | return `[${info.label}] ${toTimeFormat(info.timestamp)} ${info.level}: ${info.message}${additionalInfos}` |
25 | }) | 25 | }) |
26 | 26 | ||
27 | const logger = new winston.createLogger({ | 27 | const logger = new winston.createLogger({ |
@@ -61,3 +61,11 @@ rl.on('line', line => { | |||
61 | 61 | ||
62 | logLevels[log.level](log) | 62 | logLevels[log.level](log) |
63 | }) | 63 | }) |
64 | |||
65 | function toTimeFormat (time: string) { | ||
66 | const timestamp = Date.parse(time) | ||
67 | |||
68 | if (isNaN(timestamp) === true) return 'Unknown date' | ||
69 | |||
70 | return new Date(timestamp).toISOString() | ||
71 | } | ||
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index a4e5b58a4..e0b904950 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -37,7 +37,7 @@ const jsonLoggerFormat = winston.format.printf(info => { | |||
37 | }) | 37 | }) |
38 | 38 | ||
39 | const timestampFormatter = winston.format.timestamp({ | 39 | const timestampFormatter = winston.format.timestamp({ |
40 | format: 'YYYY-MM-dd HH:mm:ss.SSS' | 40 | format: 'YYYY-MM-DD HH:mm:ss.SSS' |
41 | }) | 41 | }) |
42 | const labelFormatter = winston.format.label({ | 42 | const labelFormatter = winston.format.label({ |
43 | label | 43 | label |
@@ -52,7 +52,7 @@ const logger = new winston.createLogger({ | |||
52 | maxsize: 5242880, | 52 | maxsize: 5242880, |
53 | maxFiles: 5, | 53 | maxFiles: 5, |
54 | format: winston.format.combine( | 54 | format: winston.format.combine( |
55 | timestampFormatter, | 55 | winston.format.timestamp(), |
56 | labelFormatter, | 56 | labelFormatter, |
57 | winston.format.splat(), | 57 | winston.format.splat(), |
58 | jsonLoggerFormat | 58 | jsonLoggerFormat |