hapi-smart-logs
v1.0.22
Published
Smart Logger for HapiJs latest version
Downloads
15
Maintainers
Readme
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();