diff options
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 | }) |