-
Notifications
You must be signed in to change notification settings - Fork 2
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
Optional parameters for the middleware #14
base: main
Are you sure you want to change the base?
Conversation
I'm not entirely clear what problem we're trying to solve here with this passing of arguments to the logger. From my (naive!) perspective, the less customisation for the logger the better - that way we can be confident in our logs having a standard format. If one service starts logging 4xx as I like having the middleware be as simple as something like Maybe I'm missing a conversation or some requirement though? |
Hey @erickhun, thanks for this PR 🌮
I would go with the simplest approach and just do
@colinscape I fully agree and this PR wouldn't change that. It would still be simple and opinionated by default. However, I feel that exposing the underlying options gives us some extra features for free when/if we need them.
Yeah, I agree that it could lead to some inconsistencies, which I'd expect to be justified. For instance, it may be useful to log the 403 responses (rate limited) for the I wouldn't ask for custom features to the logger before they are needed, but I wouldn't hide existing features either. |
I feel this starts to tie us to the implementation, which I'd rather we didn't do. I like how simple the log library is 'out of the box' and I'm loathe to add additional complexity for the sake of potential future need. YAGNI and all that.
For sure, and I think logging these kind of special cases explicitly with a From my point of view, the interface of the Buffer Logger is this:
plus the helper method I now realise we added exposing the internal logger recently which I'm reconsidering - I don't think I really understood exactly what was happening there since while it does add flexibility it now means we can't really change the implementation and as a result we haven't abstracted the interface sufficiently. |
Thanks a lot for sharing your thoughts @colinscape
I guess it's sort of a YAGNI vs NIH in this case 😄 I am probably biased here because I proposed moving away from our own logger wrappers a year ago 😅 Back then, after adding a few custom features to However, I did not have the focus and bandwidth to move forward with that proposal. @erickhun and you are doing a much better job at standardizing our logging approach and the last thing I want is to provide any kind stop energy. This project clearly owned by Infrastructure, so I am happy with whatever direction feels better to you. Let me know how I can help 🙌 |
@esclapes - thanks so much! I realise we (well, me!) are being quite opinionated here, and that's a deliberate focus in order to strive for standardisation and a simple, generic interface for all our logs across multiple languages & frameworks. That isn't to say we won't revisit this later on as we learn what works and what doesn't! You have such a breadth of knowledge on all this, I'm sure we'll come knocking to your door once more! You've contributed a lot to this project already - with your work last year and introducing pino to us all, which by all accounts is working very well with all the work we are giving it! Not to mention the time and effort on the reviews over the past few months! 🌮 🙌 |
Allow to pass optional parameters to the middleware.
For now, only allow
logger
andcustomLogLevel
optionWhat I'm unsure:
Here my non-js expertise that talks :
For the others options, I didn't do it (yet) since it feels like copy pasting the code of the
pino-http
itself .I'm wondering if there is not a way to not copy paste, but get the pino-http defaults and then forward them ?
Thoughts @esclapes @colinscape ?