Send errors to Sentry if configured

This commit is contained in:
James Allen 2015-06-16 16:50:18 +01:00
parent 5637678b48
commit 90e6c85e54
2 changed files with 15 additions and 5 deletions

View file

@ -6,12 +6,21 @@ module.exports = Logger =
name: name
serializers: bunyan.stdSerializers
return @
initializeErrorReporting: (sentry_dsn) ->
raven = require "raven"
@raven = new raven.Client(sentry_dsn)
info : ()->
@logger.info.apply(@logger, arguments)
log : ()->
@logger.info.apply(@logger, arguments)
error: ()->
@logger.error.apply(@logger, arguments)
error: (attributes, args...)->
@logger.error(attributes, args...)
if @raven?
error = attributes.err or attributes.error
if error?
@raven.captureError(error, attributes)
err: ()->
@logger.error.apply(@logger, arguments)
warn: ()->

View file

@ -8,7 +8,8 @@
},
"version": "1.0.0",
"dependencies": {
"bunyan": "1.3.6",
"coffee-script": "1.4.0",
"bunyan": "1.3.6"
"raven": "^0.8.0"
}
}