overleaf/libraries/logger/logging-manager.coffee

33 lines
879 B
CoffeeScript
Raw Normal View History

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?
tags = {}
for key, value of attributes
tags[key] = value if key.match(/_id/) and typeof value == 'string'
@raven.captureError(error, tags: tags, extra: 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")