hapi-smart-logs

1.0.22 • Public • Published

hapi-smart-logs

Enables smart logging for a hapijs app based on config.

Default Options:

{
    reverseProxyIPHeaders: ['x-real-ip'],
    timestamp: false,
    logSlowRequests: false,
    requestLevel: 'short'
}

Example:

'use strict'

const Hapi = require('hapi');

const server = Hapi.server({
    host: 'localhost',
    port: 3000
});

server.route({
    method: 'GET',
    path: '/hello',
    handler: function(request, h) {
        return h.response({greeting: "Hello there!"});
    }
});

const start = async function() {
    try {
        await server.register({
            plugin: require('hapi-smart-logs'),
            options: {
                reverseProxyIPHeaders: 'X-Forwarded-For'
            }
        })

        await server.start();
    } catch(err) {
        console.log(err);
        process.exit(1);
    }
};

start();

Package Sidebar

Install

npm i hapi-smart-logs

Weekly Downloads

3

Version

1.0.22

License

ISC

Unpacked Size

19 kB

Total Files

10

Last publish

Collaborators

  • shahabahmadkhan