Skip to content

Commit

Permalink
Updated logger to show originalError to investigate errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jlchereau committed Apr 17, 2018
1 parent 5d6595f commit 3ada85c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions webapp/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ada85c

Please sign in to comment.