Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

attrs can be just an Error

  • Loading branch information...
commit 0b87fad3e4016480f6260c862f66a60f0bf29b29 1 parent d7bb299
Dan Milon authored
Showing with 11 additions and 6 deletions.
  1. +6 −2 lib/jog.js
  2. +5 −4 test/jog.js
View
8 lib/jog.js
@@ -100,8 +100,12 @@ Jog.prototype.write = function(level, type, attrs){
}
// check for Error
- if (attrs.error instanceof Error) {
- attrs.error = attrs.error.stack || attrs.error.message;
+ var err = attrs.error || attrs
+ if (err instanceof Error) {
+ attrs.error = {
+ stack: err.stack,
+ message: err.message
+ };
}
// add it to the store
View
9 test/jog.js
@@ -36,14 +36,15 @@ describe('Jog', function(){
var store = {
add: function(obj){
- obj.error.should.equal(err.stack);
- obj.x.should.equal('y');
- done();
+ obj.error.stack.should.equal(err.stack);
+ obj.error.message.should.equal(err.message);
}
};
var log = new Jog(store);
- log.error('something happened', { error: err, x: 'y' });
+ log.error('something happened', { error: err });
+ log.error('even worse', err);
+ done();
})
})
Please sign in to comment.
Something went wrong with that request. Please try again.