Check for error instances #20

Merged
merged 2 commits into from Nov 15, 2012

Projects

None yet

2 participants

@danmilon

Picking up from the discussion at #6 (took me some time!)

Checks if attrs.error is an Error instance, and replaces it with the stacktrace as a string or the message if there is no stack attached.

Also there's a test case.

@tj tj and 1 other commented on an outdated diff Nov 14, 2012
@@ -30,6 +30,21 @@ describe('Jog', function(){
var log = new Jog(store);
log.info('something happened');
})
+
+ it('should handle error instances', function (done){
+ var err = new Error('BOOM')
+
+ var store = {
+ add: function(obj){
+ obj.error.should.equal(err.stack);
+ obj.x.should.equal('y');
+ done();
+ }
+ };
+
+ var log = new Jog(store);
+ log.error('something happened', { error: err, x: 'y' });
@tj
tj Nov 14, 2012

might be nice to also support log.error('request', err) directly, expanding to { message: m, stack: s }, both would be nice then you could just --type error --map message and get a nice list

@danmilon
danmilon Nov 14, 2012

How would --type error work with log.error('request', err)? (type equals request)

@tj
tj Nov 14, 2012

oops sorry --level error

@danmilon

And you can do -s error --map error.message

@tj tj merged commit 0de0f72 into tj:master Nov 15, 2012
@danmilon danmilon referenced this pull request Nov 15, 2012
Closed

handling Error instances #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment