diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-08 18:16:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-08 18:16:15 +0100 |
commit | 0647f472bc45d82a34e509434c112326499bbe17 (patch) | |
tree | ee1548a10d0c8eba1d3d3efb0d2ef003348aa59b /scripts/parse-log.ts | |
parent | dfecb9003600913f8c3130a87e5b403d6686a55f (diff) | |
download | PeerTube-0647f472bc45d82a34e509434c112326499bbe17.tar.gz PeerTube-0647f472bc45d82a34e509434c112326499bbe17.tar.zst PeerTube-0647f472bc45d82a34e509434c112326499bbe17.zip |
Fix logging timestamp
Diffstat (limited to 'scripts/parse-log.ts')
-rwxr-xr-x | scripts/parse-log.ts | 10 |
1 files changed, 9 insertions, 1 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 | } | ||