https://github.com/softonic/hapi-access-logger
Hapi plugin to log all requests and responses
https://github.com/softonic/hapi-access-logger
Last synced: about 1 year ago
JSON representation
Hapi plugin to log all requests and responses
- Host: GitHub
- URL: https://github.com/softonic/hapi-access-logger
- Owner: softonic
- License: other
- Created: 2017-03-14T15:25:56.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-14T07:22:28.000Z (almost 4 years ago)
- Last Synced: 2025-03-18T07:11:19.809Z (about 1 year ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 8
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @softonic/hapi-access-logger
Hapi plugin to log finished requests and responses
## Installation
```bash
npm install @softonic/hapi-access-logger
```
## Usage
```js
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:
```bash
npm test
```
## Contribute
1. Fork it: `git clone https://github.com/softonic/hapi-access-logger.git`
2. Create your feature branch: `git checkout -b feature/my-new-feature`
3. Commit your changes: `git commit -am 'Added some feature'`
4. Check the build: `npm run build`
5. Push to the branch: `git push origin my-new-feature`
6. Submit a pull request :D