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

Fix error logging

This commit is contained in:
Chocobozzz 2018-03-26 15:54:13 +02:00
parent 0dcf9a14be
commit d5b7d9110d
No known key found for this signature in database
GPG key ID: 583A612D890159BE
24 changed files with 57 additions and 41 deletions

View file

@ -18,7 +18,11 @@ const excludedKeys = {
label: true
}
function keysExcluder (key, value) {
return excludedKeys[key] === true ? undefined : value
if (excludedKeys[key] === true) return undefined
if (key === 'err') return value.stack
return value
}
const consoleLoggerFormat = winston.format.printf(info => {
@ -30,8 +34,14 @@ const consoleLoggerFormat = winston.format.printf(info => {
return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
})
const jsonLoggerFormat = winston.format.printf(info => {
if (info.message && info.message.stack !== undefined) info.message = info.message.stack
const jsonLoggerFormat = winston.format.printf(infoArg => {
let info = infoArg.err
? Object.assign({}, infoArg, { err: infoArg.err.stack })
: infoArg
if (infoArg.message && infoArg.message.stack !== undefined) {
info = Object.assign({}, info, { message: infoArg.message.stack })
}
return JSON.stringify(info)
})