diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-22 11:32:43 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-22 11:47:26 +0100 |
commit | 05e67d6206669b4a17e786038b1923e79bacb196 (patch) | |
tree | ea0eb0ed4ea6944f7bf847e1d4497893019d83ed /server/helpers | |
parent | 5a649344ffd0e8ac87ca1b573e57156d659f8b9d (diff) | |
download | PeerTube-05e67d6206669b4a17e786038b1923e79bacb196.tar.gz PeerTube-05e67d6206669b4a17e786038b1923e79bacb196.tar.zst PeerTube-05e67d6206669b4a17e786038b1923e79bacb196.zip |
Add logging for emails
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/logger.ts | 30 |
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 | ||
76 | function 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 | } | ||
94 | const 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 | ||
78 | export { | 105 | export { |
79 | timestampFormatter, | 106 | timestampFormatter, |
80 | labelFormatter, | 107 | labelFormatter, |
81 | consoleLoggerFormat, | 108 | consoleLoggerFormat, |
82 | logger | 109 | logger, |
110 | bunyanLogger | ||
83 | } | 111 | } |