Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: server.logger() function removed in favor of server.logger #99

Merged
merged 1 commit into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function start () {
})

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

// and through Hapi standard logging system
server.log(['subsystem'], 'third way for accessing it')
Expand Down Expand Up @@ -242,7 +242,7 @@ events"](#hapievents) section.
<a name="serverdecorations"></a>
### Server Decorations

**hapi-pino** decorates the Hapi server with `server.logger()`, which is a function that returns the current instance of
**hapi-pino** decorates the Hapi server with `server.logger`, which is an instance of
[pino][pino]. See its doc for the way to actual log.

<a name="requestdecorations"></a>
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async function register (server, options) {
? () => !!options.logRequestComplete
: () => true

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

// set a logger for each request
server.ext('onRequest', (request, h) => {
Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ test('server.app.logger is undefined', async () => {
expect(server.app.logger).to.be.undefined()
})

experiment('logs through the server.logger()', () => {
experiment('logs through the server.logger', () => {
ltest(async level => {
const server = getServer()
await registerWithSink(server, level, onHelloWorld)
server.logger()[level]('hello world')
server.logger[level]('hello world')
})
})

Expand Down Expand Up @@ -799,7 +799,7 @@ experiment('uses a prior pino instance', () => {
}

await server.register(plugin)
server.logger().info({ foo: 'bar' }, 'hello world')
server.logger.info({ foo: 'bar' }, 'hello world')
await finish
})
})
Expand Down