overleaf/libraries/logger/logging-manager.coffee
2015-12-08 10:30:18 +00:00

29 lines
741 B
CoffeeScript

bunyan = require('bunyan')
module.exports = Logger =
initialize: (name) ->
@logger = bunyan.createLogger
name: name
serializers: bunyan.stdSerializers
return @
initializeErrorReporting: (sentry_dsn, options) ->
raven = require "raven"
@raven = new raven.Client(sentry_dsn, options)
info : ()->
@logger.info.apply(@logger, arguments)
log : ()->
@logger.info.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: ()->
@logger.warn.apply(@logger, arguments)
Logger.initialize("default-sharelatex")