Last active
August 29, 2015 14:12
-
-
Save raine/b64912d79fd909f7b286 to your computer and use it in GitHub Desktop.
Shorter stack traces with bunyan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bunyan = require('lugg/node_modules/bunyan'); | |
var isDev = process.env.NODE_ENV === 'development'; | |
require('lugg').init({ | |
level: 'debug' | |
serializers: { | |
err: R.compose(isDev ? shortenStack : R.identity, bunyan.stdSerializers.err) | |
} | |
}); | |
var takeTenLines = R.compose(R.join('\n'), R.take(10), R.split('\n')); | |
function shortenStack(err) { | |
return err.stack === undefined ? err : R.mixin(err, { | |
stack: takeTenLines(err.stack) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment