hapi-error-logger
Version:
60 lines (43 loc) • 1.27 kB
Markdown
[](https://travis-ci.org/blogfoster/hapi-error-logger)
[](https://david-dm.org/blogfoster/hapi-error-logger)
This is a Hapi plugin to log all your response errors automatically using the `request.log` interface.
- just register the plugin
```javascript
import HapiErrorLogger from 'hapi-error-logger';
server
.register([
{
plugin: HapiErrorLogger,
options: {
replyWithStack: true,
},
},
])
.then(() => {
// errors are now logged automatically via:
//
// request.log([ 'error' ], error);
});
```
- `replyWithStack` _optional_, default: `false`, if set your response will have an error stack attached if available.
- `error.data.skipLogs` _optional_, default: `false`, if set this error response will not be logged
```js
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
```bash
npm prune && npm install
npm test
```