hapi-smart-logs

1.0.23 • 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

1

Version

1.0.23

License

ISC

Unpacked Size

18.8 kB

Total Files

10

Last publish

Collaborators

  • shahabahmadkhan