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

Question | Hapi Pino Decorates Server Object with Logger as a Function #98

Closed
GoPro16 opened this issue Mar 11, 2020 · 2 comments · Fixed by #99
Closed

Question | Hapi Pino Decorates Server Object with Logger as a Function #98

GoPro16 opened this issue Mar 11, 2020 · 2 comments · Fixed by #99

Comments

@GoPro16
Copy link
Contributor

GoPro16 commented Mar 11, 2020

Had a quick question as to the reason the logger is decorated onto the server as a function returning the logger vs. just decorating the server object with the logger instance itself. However, the logger object on the request is not a function.

Example (feature request):

server.decorate(server,'logger',logger)

https://github.com/pinojs/hapi-pino/blob/2d57bb6f0b186fa8212f84dc42e91ab2b8f95d8a/index.js#L83

In our microservices we heavily use the decorate method on the server object for a few different things but haven't had a case where we needed to use it as a method returning what we want.

We may be missing something here so if it was intended I would love to know the explanation so we can potentially refactor some of our plugins to do so in this way. Otherwise it would be nice to not have to return the logger as a function

@GoPro16 GoPro16 changed the title Question | Hapi Pino Decorates Server as a Function Question | Hapi Pino Decorates Logger as a Function Mar 11, 2020
@GoPro16 GoPro16 changed the title Question | Hapi Pino Decorates Logger as a Function Question | Hapi Pino Decorates Server Object with Logger as a Function Mar 11, 2020
@mcollina
Copy link
Collaborator

I don't think any good reason for this, and git blame points to the initial commit.

I think it's because the docs states the signature is

server.decorate(type, property, method, [options])

Note that it is method.

Does it work with objects too? In case, would you like to send a PR?

@GoPro16
Copy link
Contributor Author

GoPro16 commented Mar 12, 2020

Sure! Sadly it will be breaking change but I think it will help clear up some confusion when people have to mix and match the server logged and request logged destructures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants