diff --git a/CHANGELOG.md b/CHANGELOG.md index 86896705..1238d827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/config.sample.yml b/config.sample.yml index 73c03592..a5b543bc 100644 --- a/config.sample.yml +++ b/config.sample.yml @@ -141,4 +141,5 @@ externalLogging: loggly: false papertrail: false rollbar: false + sentry: false diff --git a/libs/logger.js b/libs/logger.js index 41d7e3d1..3908ed59 100644 --- a/libs/logger.js +++ b/libs/logger.js @@ -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 } diff --git a/libs/winston-transports/sentry.js b/libs/winston-transports/sentry.js new file mode 100644 index 00000000..508132ef --- /dev/null +++ b/libs/winston-transports/sentry.js @@ -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 diff --git a/server.js b/server.js index abcac3a6..977504c0 100644 --- a/server.js +++ b/server.js @@ -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!') }) // ----------------------------------------