Skip to content

m1ome/hapi-bunny

Repository files navigation

Hapi-Bunny

Build Status Coverage Status Dependency Status

Hapi plugin for the Bunyan logger. It logs in JSON for easy post-processing.

Installation

npm install --save hapi-bunny

Usage

'use strict';

const Hapi = require('hapi');
const HapiBunny = require('.');

const server = Hapi.server({port: 3050});

server.route({
  method: 'GET',
  path: '/',
  handler: (request, h) => {
    // `request.log` is Hapi standard way of logging
    request.log(['a', 'b'], 'Request into hello world');

    // You can also use a bunyan instance
    request.logger.info('In handler %s', request.path);

    return h.response('hello!');
  }
});

async function startup() {
  await server.register(HapiBunny);

  // The logger is available in server.app
  server.app.logger.warn('Bunyan is registered');

  // Also as a decorated API
  server.logger().info('another way for accessing it');

  // And through Hapi standard logging system
  server.log(['subsystem'], 'one more way for accessing it');

  await server.start();
}

startup();

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published