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
580 B

  1. 'use strict'
  2. const util = require('util')
  3. const winston = require('winston')
  4. const _ = require('lodash')
  5. let BugsnagLogger = winston.transports.BugsnagLogger = function (options) {
  6. this.name = 'bugsnagLogger'
  7. this.level = options.level || 'warn'
  8. this.bugsnag = require('bugsnag')
  9. this.bugsnag.register(options.key)
  10. }
  11. util.inherits(BugsnagLogger, winston.Transport)
  12. BugsnagLogger.prototype.log = function (level, msg, meta, callback) {
  13. this.bugsnag.notify(new Error(msg), _.assignIn(meta, { severity: level }))
  14. callback(null, true)
  15. }
  16. module.exports = BugsnagLogger