-
Notifications
You must be signed in to change notification settings - Fork 61
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
apply default serializer.req before using configured serializer.req #34
Conversation
…o make this work with pino-noir redacting values below req (BC breaking)
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1 similar comment
Mhh..I don't know. This results in an issue that the serializes doesn't get the whole information which breaks existing serializers and doesn't feel like best practice. Perhaps it's better so pass
|
@felixheck Yes, this would break existing serializers that are implemented against the complete request object. This is a problem. I agree. I'd rather export As far as I know me as a dev has to apply I am happy to help with any implementation but would rather leave the decision to people who have more experience with pino and these http-style serializers as it can have quite some implications for the future. |
Mhh..yeah, exposing |
@felixheck so should we go for not overriding but exposing |
@mcollina has the last word ;-) |
index.js
Outdated
if (options.serializers.req) { | ||
const oriqReqSerializer = options.serializers.req | ||
options.serializers.req = (req) => { | ||
return oriqReqSerializer(asReqValue(req)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oriqReqSerializer
=> origReqSerializer
How about attaching |
1 similar comment
@jsumners the plan is that |
@benib unfortunately I don't think so. But I believe whatever solution we settle upon there should be used here. |
hey guys thanks for all the input here! @benib - pino-http is the basis for express and koa loggers, but Hapi is too different to integrate with efficiently so it has it's own implementation @felixheck - the full req serialization is a bug that occurs when adding multiple serializers, which is unfortunate. However it doesn't happen in the main case. To retain the full request behaviour we simply provide a new serializer, let's not change the serializer format as this is more disruptive. Regarding how we collaborate on Pino and Pino's ecosystem: @mcollina and I wrote pino core together, @mcollina wrote hapi-pino, I wrote pino-http (express-pino-logger, koa-pino-logger, ...) and as in pretty much all cases when there's a hot topic, the "last word" tends to come from agreement between @mcollina, @jsumners and myself. In this particular case I trust @jsumners judgement (as does @mcollina) on which way to take |
thanks for all the explanations. I will leave this PR open and close it once I come up with one fixing the issue along the lines of pino-http once pinojs/pino-http#43 is settled. Or anyone else picks this up. No hard feelings here. |
thank you @benib ! |
|
@benib would you mind updating this PR? |
@mcollina sorry was pretty overwhelmed with work the last days. will try to get to that before the end of the year. If someone has the resources to take over, feel free. |
closed in favor of: #42 |
This serializes the
req
using the internalasReqValue
before passing the result to any configuredserializer.req
. This is to make it work in combination withpino-noir
and a configuration redacting a value in thereq
object. e.g.It is inspired by the discussion in this issue: pinojs/express-pino-logger#14
This change is BC breaking as before any configured serializer got the original
req
object without being passed throughasReqValue
. One test case is changed to reflect this.I am not sure if this makes sense. Another solution would be to do this within a function passed to
options.serializers.req
directly. Although this would slightly complicate the usage ofpino-noir
together with this plugin.I am also not sure if this should be done for
res
as well and if you would like to see this as copied code (just forres
instead ofreq
) or if you prefer to have it in a separate function called withres
orreq
returning the function.Let me know if I should change anything.