Permalink
Browse files

attrs can be just an Error

  • Loading branch information...
1 parent d7bb299 commit 0b87fad3e4016480f6260c862f66a60f0bf29b29 @danmilon danmilon committed Nov 15, 2012
Showing with 11 additions and 6 deletions.
  1. +6 −2 lib/jog.js
  2. +5 −4 test/jog.js
View
@@ -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
@@ -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();
})
})

0 comments on commit 0b87fad

Please sign in to comment.