chore: log uncaught exceptions

This commit is contained in:
André Sá 2021-10-08 19:03:58 +01:00
parent ff474ee507
commit 6f73606cfb
2 changed files with 13 additions and 2 deletions

View file

@ -5,10 +5,17 @@ const options = require('./options')
const logger = new winston.Logger({
level: options.logLevel,
transports: [
new (winston.transports.Console)({ timestamp: true, colorize: true }),
new (winston.transports.Console)({
timestamp: true,
colorize: true,
handleExceptions: true,
humanReadableUnhandledException: true
}),
new Postgres({
connectionString: options.postgresql,
tableName: 'server_logs'
tableName: 'server_logs',
handleExceptions: true,
humanReadableUnhandledException: true
})
],
rewriters: [

View file

@ -36,4 +36,8 @@ module.exports = class CustomTransport extends Transport {
callback()
}
logException (msg, meta, callback) {
this.log('error', msg, meta, callback)
}
}