rollover

1.0.0 • Public • Published

rollover

Current Version Build Status via Travis CI Dependencies

belly-button-style

rollover

rollover, is a hapi 17+ plugin used for Rollbar reporting.

Basic Usage

'use strict';
const Hapi = require('hapi');
const Rollover = require('rollover');
const server = Hapi.server();
 
await server.register([
  { plugin: Rollover, options: { rollbar: your_rollbar_token } }
]);
 
server.route([
  {
    method: 'GET',
    path: '/foo',
    handler (request, h) {
      request.log(['log'], 'request.log() -> rollbar.log()');
      request.log(['log', 'error'], 'request.log() -> rollbar.error()');
      throw new Error('throw_err');
    }
  }
]);

Live Testing

By default rollover's test suite mocks calls to the Rollbar service. To make real Rollbar calls in the test suite, use the following command:

ROLLOVER_ROLLBAR_TOKEN=your_rollbar_token npm test

Plugin Options

rollover supports the following configuration options during plugin registration.

  • rollbar - Rollbar configuration that is passed directly to the Rollbar() constructor. This option is required.
  • reportErrorResponses (Boolean) - When true, a hapi onPreResponse handler is created which sends Error responses to Rollbar. Defaults to true.
  • reportRequestLogs (Boolean) - When true, a hapi 'request' event handler is created which sends request.log() data to Rollbar. The Rollbar report level can be controlled via the request.log() tags 'critical', 'error', 'warning', 'info', and 'debug'. If none of these tags are provided, Rollbar's default log level is used. Defaults to true.
  • reportServerLogs (Boolean) - When true, a hapi server 'log' event handler is created which sends server.log() data to Rollbar. The Rollbar report level can be controlled via the request.log() tags 'critical', 'error', 'warning', 'info', and 'debug'. If none of these tags are provided, Rollbar's default log level is used. Defaults to true.
  • silenceRollbarLogger (Boolean) - When true, Rollbar's console logger is silenced. Defaults to true.
  • exposedName (String) - rollover exposes a Rollbar instance, making it possible to implement custom usage throughout an application. By default, this instance is exposed on the hapi server as server.plugins.rollover.rollbar. This option allows the name to be changed to something other than rollbar.

Package Sidebar

Install

npm i rollover

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • cjihrig