mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-01 21:09:17 -06:00
Add sql trace in error log on sequelize error
This commit is contained in:
parent
d6ca951b3c
commit
328e607d32
@ -166,7 +166,10 @@ app.use(function (err, req, res, next) {
|
||||
error = err.stack || err.message || err
|
||||
}
|
||||
|
||||
logger.error('Error in controller.', { err: error })
|
||||
// Sequelize error
|
||||
const sql = err.parent ? err.parent.sql : undefined
|
||||
|
||||
logger.error('Error in controller.', { err: error, sql })
|
||||
return res.status(err.status || 500).end()
|
||||
})
|
||||
|
||||
|
@ -22,7 +22,13 @@ function loggerReplacer (key: string, value: any) {
|
||||
}
|
||||
|
||||
const consoleLoggerFormat = winston.format.printf(info => {
|
||||
let additionalInfos = JSON.stringify(info.meta || info.err, loggerReplacer, 2)
|
||||
const obj = {
|
||||
meta: info.meta,
|
||||
err: info.err,
|
||||
sql: info.sql
|
||||
}
|
||||
|
||||
let additionalInfos = JSON.stringify(obj, loggerReplacer, 2)
|
||||
if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = ''
|
||||
else additionalInfos = ' ' + additionalInfos
|
||||
|
||||
|
@ -31,6 +31,8 @@ function cacheRoute (lifetimeArg: string | number) {
|
||||
logger.error('Cannot cache route.', { err })
|
||||
return done(err)
|
||||
})
|
||||
} else {
|
||||
done()
|
||||
}
|
||||
|
||||
return sendSave(body)
|
||||
@ -52,7 +54,7 @@ function cacheRoute (lifetimeArg: string | number) {
|
||||
return done()
|
||||
})
|
||||
} catch (err) {
|
||||
logger.error('Cannot serve cached route.', err)
|
||||
logger.error('Cannot serve cached route.', { err })
|
||||
return next()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user