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

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