3.0.1 • Published 4 years ago

hapi-good-winston v3.0.1

Weekly downloads
2,123
License
MIT
Repository
github
Last release
4 years ago

hapi-good-winston

A good reporter to send and log events with winston

npm npm license

CircleCI Dependency Status

Issues PR

Disclaimer

  • Use v3.* for hapi >= 18

  • Use v2.* for version prior to hapi v18

  • Use v1.* 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 logger = winston.createLogger({
    level: 'info',
    format: winston.format.json(),
    transports: [new winston.transports.Console()],
});

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 = {
    ops: {
        interval: 1000,
    },
    reporters: {
        // Simple and straight forward usage
        winston: [goodWinston(logger)],
        // Adding some customization configuration
        winstonWithLogLevels: [goodWinston(logger, goodWinstonOptions)],
        // This example simply illustrates auto loading and instantiation made by good
        winston2: [
            {
                module: 'hapi-good-winston',
                name: 'goodWinston',
                args: [logger, goodWinstonOptions],
            },
        ],
    },
};

server
    .register({
        plugin: require('good'),
        options,
    })
    .then(() => {
        return server.start();
    })
    .then(() => {
        console.info(`Server started at ${server.info.uri}`);
    });

Links

License

MIT

3.0.1

4 years ago

3.0.0

5 years ago

2.1.0

5 years ago

2.0.1

6 years ago

1.1.4

6 years ago

2.0.0-rc1

6 years ago

2.0.0

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago