node package manager

hapi-good-winston

hapi-good-winston

A good reporter to send and log events with winston

npm npm license

CircleCI Dependency Status

Issues PR

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();
server.connection();
 
// 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({
    register: require('good'),
    options,
}, (err) => {
 
    if (err) {
        return console.error(err);
    }
    server.start(() => {
        console.info(`Server started at ${server.info.uri}`);
    });
 
});

Todo

  • Adding custom log levels to offer the possibility of using winston's custom log levels
  • [] Filtering events
  • [] Adding message customization
  • [] Adding message templating

Links

License

MIT