You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
578 B

  1. 'use strict'
  2. const util = require('util')
  3. const winston = require('winston')
  4. let SentryLogger = winston.transports.RollbarLogger = function (options) {
  5. this.name = 'sentryLogger'
  6. this.level = options.level || 'warn'
  7. this.raven = require('raven')
  8. this.raven.config(options.key).install()
  9. }
  10. util.inherits(SentryLogger, winston.Transport)
  11. SentryLogger.prototype.log = function (level, msg, meta, callback) {
  12. level = (level === 'warn') ? 'warning' : level
  13. this.raven.captureMessage(msg, { level, extra: meta })
  14. callback(null, true)
  15. }
  16. module.exports = SentryLogger