From 6f73606cfbc884a480d01ef2524864c0f223f787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Fri, 8 Oct 2021 19:03:58 +0100 Subject: [PATCH] chore: log uncaught exceptions --- lib/logger.js | 11 +++++++++-- lib/pg-transport.js | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index d8c1a56e..78818ada 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -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: [ diff --git a/lib/pg-transport.js b/lib/pg-transport.js index 65f39494..3d757a46 100644 --- a/lib/pg-transport.js +++ b/lib/pg-transport.js @@ -36,4 +36,8 @@ module.exports = class CustomTransport extends Transport { callback() } + + logException (msg, meta, callback) { + this.log('error', msg, meta, callback) + } }