From 79f42aab5b56b76cee0b829b4ced2cb876bbd5fa Mon Sep 17 00:00:00 2001 From: jlchereau Date: Tue, 17 Apr 2018 14:28:08 +0100 Subject: [PATCH] Updated logger to show originalError to investigate errors https://github.com/Memba/Memba-Blog/issues/134 --- webapp/lib/logger.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/webapp/lib/logger.js b/webapp/lib/logger.js index 8547b0f47..9f9536f28 100644 --- a/webapp/lib/logger.js +++ b/webapp/lib/logger.js @@ -108,21 +108,19 @@ function format(entry, level) { if (entry.data) { ret.data = entry.data; } - // Error message and stack - if (entry.stack) { - if (entry.message) { - ret.error = entry.message; - } + // Error stack + if (entry.stack) { // entry is an error object + // ret.originalMessage = entry.message; // no need to repeat ret.stack = entry.stack; } else if (entry.error && entry.error.stack) { - if (entry.error.message) { - ret.error = entry.error.message; - } else if (entry.error.originalError && entry.error.originalError.message) { + if (entry.error.originalError) { // entry.error.originalError is not necessarily an instance of Error because we use deepExtend - // TODO: CHeck that this actually occurs - ret.error = entry.error.originalError.message; + ret.originalMessage = entry.error.originalError.message; + ret.stack = entry.error.originalError.stack; + } else { + ret.originalMessage = entry.error.message; + ret.stack = entry.error.stack; } - ret.stack = entry.error.stack; } // entry.date = (new Date()).toISOString(); // Note: such an entry is not only ready to print to console but also to be sent as JSON