diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-26 15:54:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-26 16:04:14 +0200 |
commit | d5b7d9110dd637a7f67ce9e430145314812a8df1 (patch) | |
tree | d019ef5fe68b14d7e5ad11953b6c1f4811669ce6 /server/helpers/logger.ts | |
parent | 0dcf9a14be3f8668fe5ee65cf0365d457b4d1499 (diff) | |
download | PeerTube-d5b7d9110dd637a7f67ce9e430145314812a8df1.tar.gz PeerTube-d5b7d9110dd637a7f67ce9e430145314812a8df1.tar.zst PeerTube-d5b7d9110dd637a7f67ce9e430145314812a8df1.zip |
Fix error logging
Diffstat (limited to 'server/helpers/logger.ts')
-rw-r--r-- | server/helpers/logger.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 7968b5ec9..d92381a2c 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -18,7 +18,11 @@ const excludedKeys = { | |||
18 | label: true | 18 | label: true |
19 | } | 19 | } |
20 | function keysExcluder (key, value) { | 20 | function keysExcluder (key, value) { |
21 | return excludedKeys[key] === true ? undefined : value | 21 | if (excludedKeys[key] === true) return undefined |
22 | |||
23 | if (key === 'err') return value.stack | ||
24 | |||
25 | return value | ||
22 | } | 26 | } |
23 | 27 | ||
24 | const consoleLoggerFormat = winston.format.printf(info => { | 28 | const consoleLoggerFormat = winston.format.printf(info => { |
@@ -30,8 +34,14 @@ const consoleLoggerFormat = winston.format.printf(info => { | |||
30 | return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` | 34 | return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` |
31 | }) | 35 | }) |
32 | 36 | ||
33 | const jsonLoggerFormat = winston.format.printf(info => { | 37 | const jsonLoggerFormat = winston.format.printf(infoArg => { |
34 | if (info.message && info.message.stack !== undefined) info.message = info.message.stack | 38 | let info = infoArg.err |
39 | ? Object.assign({}, infoArg, { err: infoArg.err.stack }) | ||
40 | : infoArg | ||
41 | |||
42 | if (infoArg.message && infoArg.message.stack !== undefined) { | ||
43 | info = Object.assign({}, info, { message: infoArg.message.stack }) | ||
44 | } | ||
35 | 45 | ||
36 | return JSON.stringify(info) | 46 | return JSON.stringify(info) |
37 | }) | 47 | }) |