Added sentry.io logger option

This commit is contained in:
NGPixel 2017-03-29 21:49:30 -04:00
parent 4dd79170c5
commit d13085ac1b
5 changed files with 31 additions and 3 deletions

View File

@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Interactive setup
- Auth: GitHub and Slack authentication providers are now available
- Auth: LDAP authentication provider is now available
- Logs: Support for the logging services: Bugsnag, Loggly, Papertrail and Rollbar
- Logs: Support for the logging services: Bugsnag, Loggly, Papertrail, Rollbar and Sentry
### Changed
- Native Compilation Removal: Replaced farmhash with md5
@ -16,6 +16,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Sidebar: Contents is now Page Contents
- Sidebar: Start is now Top of Page
- UI: Content headers are now showing an anchor icon instead of a #
- Dev: Replaced Gulp with Fuse-box
### Fixed
- Auth: Authentication would fail if email has uppercase chars and provider callback is in lowercase

View File

@ -141,4 +141,5 @@ externalLogging:
loggly: false
papertrail: false
rollbar: false
sentry: false

View File

@ -60,5 +60,13 @@ module.exports = (isDebug) => {
})
}
if (appconfig.externalLogging.sentry) {
const sentryTransport = require('./winston-transports/sentry')
winston.add(sentryTransport, {
level: 'warn',
key: appconfig.externalLogging.sentry
})
}
return winston
}

View File

@ -0,0 +1,20 @@
'use strict'
const util = require('util')
const winston = require('winston')
let SentryLogger = winston.transports.RollbarLogger = function (options) {
this.name = 'sentryLogger'
this.level = options.level || 'warn'
this.raven = require('raven')
this.raven.config(options.key).install()
}
util.inherits(SentryLogger, winston.Transport)
SentryLogger.prototype.log = function (level, msg, meta, callback) {
level = (level === 'warn') ? 'warning' : level
this.raven.captureMessage(msg, { level, extra: meta })
callback(null, true)
}
module.exports = SentryLogger

View File

@ -212,8 +212,6 @@ server.on('error', (error) => {
server.on('listening', () => {
winston.info('[SERVER] HTTP/WS server started successfully! [RUNNING]')
winston.warn('Something went wrong!')
winston.error('An big error occured!')
})
// ----------------------------------------