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
|
|
|
|
|
|
|
initializeErrorReporting: (sentry_dsn) ->
|
|
|
|
raven = require "raven"
|
|
|
|
@raven = new raven.Client(sentry_dsn)
|
|
|
|
|
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")
|