Skip to content

FlexShopper/hapi-good-winston

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A good reporter to send and log events with winston

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%