Skip to content

Commit

Permalink
Merge 6ac8a77 into 0c5d6d4
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Nov 20, 2018
2 parents 0c5d6d4 + 6ac8a77 commit 0374bb5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -55,7 +55,9 @@ async function start () {
await server.register({
plugin: require('.'),
options: {
prettyPrint: process.env.NODE_ENV !== 'production'
prettyPrint: process.env.NODE_ENV !== 'production',
// Redact Authorization headers, see https://getpino.io/#/docs/redaction
redact: ['req.headers.authorization']
}
})

Expand Down Expand Up @@ -131,6 +133,8 @@ events"](#hapievents) section.
```
- `[ignorePaths]` - Takes an array of string routes and disables logging for each. Useful for health checks or any route that does not need logging. E.g `['/health']`
- `[level]` - Set the minumum level that Pino should log out. See [Level](https://github.com/pinojs/pino/blob/master/docs/api.md#level). For example, `{level: 'debug'}` would configure Pino to output all `debug` or higher events.
- `[redact]` - Path to be redacted in the log lines. See the [log redaction](https://getpino.io/#/docs/redaction) docs for more details.

<a name="serverdecorations"></a>
### Server Decorations

Expand Down
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -18,11 +18,11 @@
],
"license": "MIT",
"devDependencies": {
"code": "^5.2.0",
"code": "^5.2.3",
"coveralls": "^3.0.2",
"flush-write-stream": "^1.0.3",
"hapi": "^17.5.4",
"lab": "^16.0.0",
"hapi": "^17.7.0",
"lab": "^16.1.0",
"make-promises-safe": "^1.1.0",
"pre-commit": "^1.1.2",
"split2": "^3.0.0",
Expand All @@ -31,8 +31,8 @@
"dependencies": {
"abstract-logging": "^1.0.0",
"hoek": "^5.0.4",
"pino": "^5.5.0",
"pino-pretty": "^2.1.0"
"pino": "^5.8.1",
"pino-pretty": "^2.2.3"
},
"repository": {
"type": "git",
Expand Down
31 changes: 31 additions & 0 deletions test.js
Expand Up @@ -1098,3 +1098,34 @@ experiment('logging with logRouteTags option enabled', () => {
await done
})
})

experiment('log redact', () => {
test('authorization headers', async () => {
const server = getServer()
let done
const finish = new Promise(function (resolve, reject) {
done = resolve
})
const stream = sink((data) => {
expect(data.req.headers.authorization).to.equal('[Redacted]')
done()
})
const plugin = {
plugin: Pino,
options: {
stream,
redact: ['req.headers.authorization']
}
}

await server.register(plugin)
await server.inject({
method: 'GET',
url: '/something',
headers: {
authorization: 'Bearer 123'
}
})
await finish
})
})

0 comments on commit 0374bb5

Please sign in to comment.