This is a Hapi plugin to log all your response errors automatically using the request.log interface.
- just register the plugin
import HapiErrorLogger from 'hapi-error-logger';
server
.register([
{
plugin: HapiErrorLogger,
options: {
replyWithStack: true,
},
},
])
.then(() => {
// errors are now logged automatically via:
//
// request.log([ 'error' ], error);
});replyWithStackoptional, default:false, if set your response will have an error stack attached if available.
error.data.skipLogsoptional, default:false, if set this error response will not be logged
const Boom = require('boom');
// this is a handler definition
const handler = request => {
const err = Boom.badGateway('could not reach server XXX', {
skipLogs: true,
});
return err;
};- npm
npm prune && npm install
npm test