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.

32 lines
854 B

  1. const util = require('util')
  2. const winston = require('winston')
  3. // ------------------------------------
  4. // Sentry
  5. // ------------------------------------
  6. module.exports = {
  7. key: 'sentry',
  8. title: 'Sentry',
  9. props: ['key'],
  10. init (logger, conf) {
  11. let SentryLogger = winston.transports.SentryLogger = function (options) {
  12. this.name = 'sentryLogger'
  13. this.level = options.level || 'warn'
  14. this.raven = require('raven')
  15. this.raven.config(options.key).install()
  16. }
  17. util.inherits(SentryLogger, winston.Transport)
  18. SentryLogger.prototype.log = function (level, msg, meta, callback) {
  19. level = (level === 'warn') ? 'warning' : level
  20. this.raven.captureMessage(msg, { level, extra: meta })
  21. callback(null, true)
  22. }
  23. logger.add(SentryLogger, {
  24. level: 'warn',
  25. key: conf.key
  26. })
  27. }
  28. }