Skip to content

Commit

Permalink
Fixup server rollbar logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Nason committed Nov 7, 2017
1 parent 243ee3d commit 7fe98f9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/util/server/rollbarLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import { bunyanLevelToRollbarLevelName } from '../common/rollbar';
*/
export default function ServerRollbarLogger({ token, codeVersion, environment }) {
// https://rollbar.com/docs/notifier/rollbar.js/#quick-start-server
const rollbar = new Rollbar({
this._rollbar = new Rollbar({
accessToken: token,
captureUncaught: true,
captureUnhandledRejections: true,
code_version: codeVersion,
environment,
});

return rollbar;
}

/**
Expand All @@ -37,11 +35,11 @@ ServerRollbarLogger.prototype.write = function (data = {}) {
const payload = Object.assign({ level: rollbarLevelName }, scopeData);

// https://rollbar.com/docs/notifier/rollbar.js/#rollbarlog-1
const logFn = Rollbar[rollbarLevelName];
const logFn = this._rollbar[rollbarLevelName];

if (isFunction(logFn)) {
logFn(data.msg, data.err, data.req, payload);
} else {
Rollbar.error(data.msg, data.err, data.req, payload);
this._rollbar.error(data.msg, data.err, data.req, payload);
}
};

0 comments on commit 7fe98f9

Please sign in to comment.