mirror of https://github.com/requarks/wiki
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.
21 lines
586 B
21 lines
586 B
8 years ago
|
'use strict'
|
||
|
|
||
|
const util = require('util')
|
||
|
const winston = require('winston')
|
||
|
const _ = require('lodash')
|
||
|
|
||
|
let RollbarLogger = winston.transports.RollbarLogger = function (options) {
|
||
|
this.name = 'rollbarLogger'
|
||
|
this.level = options.level || 'warn'
|
||
|
this.rollbar = require('rollbar')
|
||
|
this.rollbar.init(options.key)
|
||
|
}
|
||
|
util.inherits(RollbarLogger, winston.Transport)
|
||
|
|
||
|
RollbarLogger.prototype.log = function (level, msg, meta, callback) {
|
||
|
this.rollbar.handleErrorWithPayloadData(new Error(msg), _.assignIn(meta, { level }))
|
||
|
callback(null, true)
|
||
|
}
|
||
|
|
||
|
module.exports = RollbarLogger
|