hapi-bunyan-plugin

1.2.0 • Public • Published

Hapi Bunyan Plugin

Integrates bunyan with Hapi.js by wiring a bunyan Logger instance into the published server events.

Allows structured json logging of the Hapi.Server generated log messages. Using server.log() and request.log() will be routed through the bunyan Logger as well.

Usage

var Hapi = require('hapi'),
    HapiBunyan = require('hapi-bunyan'),
    bunyan = require('bunyan');

var server = new Hapi.Server(),
    log = bunyan.createLogger({
        name: 'my-application',
        level: 'debug'
    });

server.connection({ port: 8000 });

server.register({
    register: HapiBunyan,
    options: {
        log: log
    }
});

// other server configuration, routes, etc.

server.start();

Configuration

The options object used when registering the plugin takes the following properties:

  • log - the bunyan Logger instance. (required)
  • logInternal - boolean value, defaults to false. Set to true to enable logging of Hapi.Server internal events.

License

MIT. See LICENSE.txt.

/hapi-bunyan-plugin/

    Package Sidebar

    Install

    npm i hapi-bunyan-plugin

    Weekly Downloads

    1

    Version

    1.2.0

    License

    MIT

    Last publish

    Collaborators

    • larrymyers