2014-02-17 09:54:20 -05:00
|
|
|
bunyan = require('bunyan')
|
|
|
|
|
|
|
|
module.exports = Logger =
|
|
|
|
initialize: (name) ->
|
|
|
|
@logger = bunyan.createLogger
|
|
|
|
name: name
|
|
|
|
serializers: bunyan.stdSerializers
|
|
|
|
return @
|
2015-06-16 11:50:18 -04:00
|
|
|
|
2015-12-08 05:30:18 -05:00
|
|
|
initializeErrorReporting: (sentry_dsn, options) ->
|
2015-06-16 11:50:18 -04:00
|
|
|
raven = require "raven"
|
2015-12-08 05:30:18 -05:00
|
|
|
@raven = new raven.Client(sentry_dsn, options)
|
2015-06-16 11:50:18 -04:00
|
|
|
|
2014-02-17 09:54:20 -05:00
|
|
|
info : ()->
|
|
|
|
@logger.info.apply(@logger, arguments)
|
|
|
|
log : ()->
|
|
|
|
@logger.info.apply(@logger, arguments)
|
2015-06-16 11:50:18 -04:00
|
|
|
error: (attributes, args...)->
|
|
|
|
@logger.error(attributes, args...)
|
|
|
|
if @raven?
|
|
|
|
error = attributes.err or attributes.error
|
|
|
|
if error?
|
|
|
|
@raven.captureError(error, attributes)
|
2014-02-17 09:54:20 -05:00
|
|
|
err: ()->
|
|
|
|
@logger.error.apply(@logger, arguments)
|
|
|
|
warn: ()->
|
|
|
|
@logger.warn.apply(@logger, arguments)
|
|
|
|
|
|
|
|
Logger.initialize("default-sharelatex")
|