hapi-bunny

2.0.0 • Public • Published

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 server = new Hapi.Server()
server.connection({port: 3000});

// Add the route
'use strict';

const Hapi = require('hapi');
const server = new Hapi.Server();

server.route({
	method: 'GET',
	path: '/',
	handler: function (request, reply) {
		// 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 reply();
	}
});

server.register(require('hapi-bunny'), (err) => {
	if (err) {
		throw err;
	}

	// 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');

	server.start((err) => {
		if (err) {
			throw err;
		}
	});
});

License

MIT

Package Sidebar

Install

npm i hapi-bunny

Weekly Downloads

2

Version

2.0.0

License

MIT

Last publish

Collaborators

  • m1ome