@softonic/hapi-access-logger
v5.0.0
Published
Hapi plugin to log all requests and responses
Downloads
278
Maintainers
Readme
@softonic/hapi-access-logger
Hapi plugin to log finished requests and responses
Installation
npm install @softonic/hapi-access-logger
Usage
import HapiAccessLogger from '@softonic/hapi-access-logger';
await server.register({
plugin: HapiAccessLogger,
options: {
logger: bunyan.createLogger({ name: "myapp" }),
// whitelistHeaders and blacklistHeaders should not be used together
whitelistRequestHeaders: [ 'host', 'accept', 'content-type' ],
blacklistRequestHeaders: [ 'authorization' ],
whitelistResponseHeaders: [ 'content-type' ],
blacklistResponseHeaders: [ 'set-cookie' ],
isLoggableRequest: request => get(request, 'route.settings.tags', []).includes('page')
},
});
Testing
Clone the repository and execute:
npm test
Contribute
- Fork it:
git clone https://github.com/softonic/hapi-access-logger.git
- Create your feature branch:
git checkout -b feature/my-new-feature
- Commit your changes:
git commit -am 'Added some feature'
- Check the build:
npm run build
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D