1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Add logging for emails

This commit is contained in:
Chocobozzz 2018-03-22 11:32:43 +01:00
parent 5a649344ff
commit 05e67d6206
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 43 additions and 12 deletions

View file

@ -73,11 +73,39 @@ const logger = new winston.createLogger({
exitOnError: true
})
function bunyanLogFactory (level: string) {
return function () {
let meta = null
let args = [].concat(arguments)
if (arguments[ 0 ] instanceof Error) {
meta = arguments[ 0 ].toString()
args = Array.prototype.slice.call(arguments, 1)
args.push(meta)
} else if (typeof (args[ 0 ]) !== 'string') {
meta = arguments[ 0 ]
args = Array.prototype.slice.call(arguments, 1)
args.push(meta)
}
logger[ level ].apply(logger, args)
}
}
const bunyanLogger = {
trace: bunyanLogFactory('debug'),
debug: bunyanLogFactory('debug'),
info: bunyanLogFactory('info'),
warn: bunyanLogFactory('warn'),
error: bunyanLogFactory('error'),
fatal: bunyanLogFactory('error')
}
// ---------------------------------------------------------------------------
export {
timestampFormatter,
labelFormatter,
consoleLoggerFormat,
logger
logger,
bunyanLogger
}