Skip to content

Commit

Permalink
Merge branch 'master' into v17
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Oct 27, 2017
2 parents 91bf2fc + a1c0f15 commit 23715b7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ server.register(require('hapi-pino'), (err) => {
process.exit(1)
}

// the logger is available in server.app
server.app.logger.warn('Pino is registered')

// also as a decorated API
// The logger is available as a decorated API
server.logger().info('another way for accessing it')

// and through Hapi standard logging system
Expand Down Expand Up @@ -143,7 +140,7 @@ server.log(['info'], {hello: 'world'})
* `'log'`, to support logging via the Hapi `server.log()` and
`request.log()` methods, see `tags` and `allTags` options.
* `'onPostStart'`, to log when the server is started
* `'onPostStopt'`, to log when the server is stopped
* `'onPostStop'`, to log when the server is stopped

## Acknowledgements

Expand Down
3 changes: 0 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ async function register (server, options, nex) {

const mergeHapiLogData = options.mergeHapiLogData

// expose logger as 'server.app.logger'
server.app.logger = logger

// expose logger as 'server.logger()'
server.decorate('server', 'logger', () => logger)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hapi-pino",
"version": "1.7.0",
"version": "2.0.0",
"description": "Hapi plugin for the Pino logger ",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 5 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,10 @@ function ltest (func) {
})
}

experiment('logs through the server.app.logger', () => {
ltest(async (level) => {
const server = getServer()
await registerWithSink(server, level, onHelloWorld)
server.app.logger[level]('hello world')
})
test('server.app.logger is undefined', async () => {
const server = getServer()
await registerWithSink(server, 'info', () => { throw new Error('fail') })
expect(server.app.logger).to.be.undefined()
})

experiment('logs through the server.logger()', () => {
Expand Down Expand Up @@ -555,7 +553,7 @@ experiment('uses a prior pino instance', () => {
}

server.register(plugin).then(() => {
server.app.logger.info({foo: 'bar'}, 'hello world')
server.logger().info({foo: 'bar'}, 'hello world')
}).catch(done)
})
})
Expand Down

0 comments on commit 23715b7

Please sign in to comment.