Skip to content

A Hapi.js plugin for passing all logging through bunyan.

License

Notifications You must be signed in to change notification settings

edyn/hapi-bunyan-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A Hapi.js plugin for passing all logging through bunyan.

Resources

License

Stars

Watchers

Forks

Packages

No packages published