Skip to content

Commit

Permalink
Backport ignoreOptions support for v2 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
eoinsha committed Feb 14, 2018
1 parent b442c98 commit 74681cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function asReqValue (req) {
}
}

module.exports = {
register,
name: 'hapi-pino'
module.exports.register = register
module.exports.register.attributes = {
pkg: require('./package')
}
32 changes: 13 additions & 19 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,37 +723,31 @@ experiment('logging with request payload', () => {
})

experiment('ignore request logs for paths in ignorePaths', () => {
test('when path matches entry in ignorePaths, nothing should be logged', async () => {
test('when path matches entry in ignorePaths, nothing should be logged', (done) => {
const server = getServer()
let resolver
const done = new Promise((resolve, reject) => {
resolver = resolve
})
const stream = sink((data) => {
expect(data.req.url).to.not.equal('/ignored')
resolver()
done()
})
const logger = require('pino')(stream)
const plugin = {
plugin: Pino,
register: Pino.register,
options: {
instance: logger,
ignorePaths: ['/ignored']
}
}

await server.register(plugin)

await server.inject({
method: 'PUT',
url: '/ignored'
})

await server.inject({
method: 'PUT',
url: '/'

server.register(plugin, (err) => {
expect(err).to.be.undefined()
server.inject({
method: 'PUT',
url: '/ignored'
})
server.inject({
method: 'PUT',
url: '/'
})
})
await done
})
})

0 comments on commit 74681cd

Please sign in to comment.