wikijs-fork/server/libs/winston-transports/bugsnag.js

21 lines
580 B
JavaScript
Raw Normal View History

2017-03-29 00:19:01 +00:00
'use strict'
const util = require('util')
const winston = require('winston')
const _ = require('lodash')
let BugsnagLogger = winston.transports.BugsnagLogger = function (options) {
this.name = 'bugsnagLogger'
this.level = options.level || 'warn'
this.bugsnag = require('bugsnag')
this.bugsnag.register(options.key)
}
util.inherits(BugsnagLogger, winston.Transport)
BugsnagLogger.prototype.log = function (level, msg, meta, callback) {
this.bugsnag.notify(new Error(msg), _.assignIn(meta, { severity: level }))
callback(null, true)
}
module.exports = BugsnagLogger