diff options
Diffstat (limited to 'server/helpers/logger.ts')
-rw-r--r-- | server/helpers/logger.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index bcd4885af..7d1d72f29 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -21,7 +21,7 @@ function keysExcluder (key, value) { | |||
21 | return excludedKeys[key] === true ? undefined : value | 21 | return excludedKeys[key] === true ? undefined : value |
22 | } | 22 | } |
23 | 23 | ||
24 | const loggerFormat = winston.format.printf(info => { | 24 | const consoleLoggerFormat = winston.format.printf(info => { |
25 | let additionalInfos = JSON.stringify(info, keysExcluder, 2) | 25 | let additionalInfos = JSON.stringify(info, keysExcluder, 2) |
26 | if (additionalInfos === '{}') additionalInfos = '' | 26 | if (additionalInfos === '{}') additionalInfos = '' |
27 | else additionalInfos = ' ' + additionalInfos | 27 | else additionalInfos = ' ' + additionalInfos |
@@ -30,6 +30,12 @@ const loggerFormat = winston.format.printf(info => { | |||
30 | return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` | 30 | return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` |
31 | }) | 31 | }) |
32 | 32 | ||
33 | const jsonLoggerFormat = winston.format.printf(info => { | ||
34 | if (info.message && info.message.stack !== undefined) info.message = info.message.stack | ||
35 | |||
36 | return JSON.stringify(info) | ||
37 | }) | ||
38 | |||
33 | const timestampFormatter = winston.format.timestamp({ | 39 | const timestampFormatter = winston.format.timestamp({ |
34 | format: 'YYYY-MM-dd HH:mm:ss.SSS' | 40 | format: 'YYYY-MM-dd HH:mm:ss.SSS' |
35 | }) | 41 | }) |
@@ -49,18 +55,18 @@ const logger = new winston.createLogger({ | |||
49 | timestampFormatter, | 55 | timestampFormatter, |
50 | labelFormatter, | 56 | labelFormatter, |
51 | winston.format.splat(), | 57 | winston.format.splat(), |
52 | winston.format.json() | 58 | jsonLoggerFormat |
53 | ) | 59 | ) |
54 | }), | 60 | }), |
55 | new winston.transports.Console({ | 61 | new winston.transports.Console({ |
56 | handleExceptions: true, | 62 | handleExcegiptions: true, |
57 | humanReadableUnhandledException: true, | 63 | humanReadableUnhandledException: true, |
58 | format: winston.format.combine( | 64 | format: winston.format.combine( |
59 | timestampFormatter, | 65 | timestampFormatter, |
60 | winston.format.splat(), | 66 | winston.format.splat(), |
61 | labelFormatter, | 67 | labelFormatter, |
62 | winston.format.colorize(), | 68 | winston.format.colorize(), |
63 | loggerFormat | 69 | consoleLoggerFormat |
64 | ) | 70 | ) |
65 | }) | 71 | }) |
66 | ], | 72 | ], |
@@ -72,6 +78,6 @@ const logger = new winston.createLogger({ | |||
72 | export { | 78 | export { |
73 | timestampFormatter, | 79 | timestampFormatter, |
74 | labelFormatter, | 80 | labelFormatter, |
75 | loggerFormat, | 81 | consoleLoggerFormat, |
76 | logger | 82 | logger |
77 | } | 83 | } |