aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/logger.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/logger.ts')
-rw-r--r--server/helpers/logger.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index e0b904950..7968b5ec9 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -73,11 +73,39 @@ const logger = new winston.createLogger({
73 exitOnError: true 73 exitOnError: true
74}) 74})
75 75
76function bunyanLogFactory (level: string) {
77 return function () {
78 let meta = null
79 let args = [].concat(arguments)
80
81 if (arguments[ 0 ] instanceof Error) {
82 meta = arguments[ 0 ].toString()
83 args = Array.prototype.slice.call(arguments, 1)
84 args.push(meta)
85 } else if (typeof (args[ 0 ]) !== 'string') {
86 meta = arguments[ 0 ]
87 args = Array.prototype.slice.call(arguments, 1)
88 args.push(meta)
89 }
90
91 logger[ level ].apply(logger, args)
92 }
93}
94const bunyanLogger = {
95 trace: bunyanLogFactory('debug'),
96 debug: bunyanLogFactory('debug'),
97 info: bunyanLogFactory('info'),
98 warn: bunyanLogFactory('warn'),
99 error: bunyanLogFactory('error'),
100 fatal: bunyanLogFactory('error')
101}
102
76// --------------------------------------------------------------------------- 103// ---------------------------------------------------------------------------
77 104
78export { 105export {
79 timestampFormatter, 106 timestampFormatter,
80 labelFormatter, 107 labelFormatter,
81 consoleLoggerFormat, 108 consoleLoggerFormat,
82 logger 109 logger,
110 bunyanLogger
83} 111}