Skip to content

Commit

Permalink
fix(LogCollector): Add stack trace to errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Aug 24, 2023
1 parent 1db0885 commit 0cb769a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/LogCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ logLevel /* timestamp, arg2, arg3, arg4... */) {
for (var i = 1, len = arguments.length; i < len; i++) {
var arg = arguments[i];

if (this.stringifyObjects && typeof arg === 'object') {
if (arg instanceof Error) {
msg += arg.toString() + ': ' + arg.stack;
} else if (this.stringifyObjects && typeof arg === 'object') {
// NOTE: We were trying to stringify all error logs before but because of a bug that we were getting the keys
// of the log levels which are all with upper case and comparing it with the keys which are all lower case we
// were never actually strinfying the error logs. That's why I've removed the check for error logs here.
// NOTE: The non-enumerable properties of the objects wouldn't be included in the string after JSON.strigify.
// For example Error instance will be translated to '{}'. So I think we have to eventually do something better
// For example Map instance will be translated to '{}'. So I think we have to eventually do something better
// for parsing the arguments. But since this option for strigify is part of the public interface and I think
// it could be useful in some cases I will it for now.
msg += this.stringify(arg);
Expand Down

0 comments on commit 0cb769a

Please sign in to comment.