A good reporter to send and log events with winston
Clone or download
Latest commit 3084c50 May 16, 2018

README.md

hapi-good-winston

A good reporter to send and log events with winston

npm npm license

CircleCI Dependency Status

Issues PR

Disclaimer

Hapi-good-winston 2 only support good >= 8 and hapi >= 17

  • Use 1.* for version prior to hapi v17

Installation

$ npm install --save hapi-good-winston

Usage

import { Server } from 'hapi';
import winston from 'winston';
import goodWinston from 'hapi-good-winston';

const server = new Server();

// Set winston minimum log level to debug
winston.level = 'debug';

 // Only the 'response' and 'error' event levels will be overwritten
const goodWinstonOptions = {
    levels: {
        response: 'debug',
        error: 'info',
    }
};

const options = {
    reporters: {
        // Simple and straight forward usage
        winston: [goodWinston(winston)],

        // Adding some customization configuration
        winstonWithLogLevels: [goodWinston(winston, goodWinstonOptions)],

        // This example simply illustrates auto loading and instantiation made by good
        winston2: [{
            module: 'hapi-good-winston',
            name: 'goodWinston',
            args: [winston, goodWinstonOptions],
        }],
    },
};

server.register({
    plugin: require('good'),
    options,
}, (err) => {

    if (err) {
        return console.error(err);
    }
    server.start(() => {
        console.info(`Server started at ${server.info.uri}`);
    });

});

Links

License

MIT