Skip to content

Commit

Permalink
check err.stack on record
Browse files Browse the repository at this point in the history
  • Loading branch information
isRuslan committed Sep 28, 2016
1 parent 10b811c commit 9845cbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Record(name, level, args) {
}
this.exception = isErr;
this.uncaughtException = isErr ? trace[UNCAUGHT_SYMBOL] : undefined;
this.stack = trace ? stack(trace) : undefined;
this.stack = trace && trace.stack ? stack(trace) : undefined;

}

Expand Down
13 changes: 13 additions & 0 deletions test/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ module.exports = {
assert(obj[0].fileName);
assert.equal(record.exception, true);
},
'should be with empty stack if NONE err.stack': function(){
var a = new Logger(unique());
a.propagate = false;
var spyA = spy();
a.addHandler({ handle: spyA, level: 0 });

var error = new Error('foo');
delete error.stack;
a.error(error);

var record = spyA.getLastArgs()[0];
assert.equal(record.stack, undefined);
},
'ALL should receive all levels': function() {
var a = new Logger(unique());
a.propagate = false;
Expand Down

0 comments on commit 9845cbb

Please sign in to comment.