Closed indreek closed 4 years ago
I don't really understand this fix.
See https://github.com/pinojs/hapi-pino/pull/87 for the full discussion on that option.
Idea behind this fix is that element req gets added twice to each log entry. 1s time in getChildBindings with default options. 2nd time in server.ext('onRequest', OR tryAddEvent(server, options, 'on', 'response'.
In my opinion we shouldn't add it twice because 1) We don't know what is the next processor, and what it does actually. Is it getting the correct element? 2) For example if I modify remote address (reverse proxy, etc), first req element is with default api provided, but 2nd one is correct. 3) If whole log is 1483 chars, then req element of it is 521. Over 1/3 is rubbish. 4) If you enable logRequestStart. Req element is in both log entries. From readme: Note: when logRequestStart is enabled and getChildBindings is configured to omit the req field, then the req field will be omitted from the "request complete" log event. This behavior is useful if you want to separate requests from responses
Indrek
Why cannot just pass a getChildBindings()
function that returns an empty object?
You can do this also, but I think that it should be default behaviour then.
On Fri, 15 Nov 2019, 10:07 Matteo Collina, notifications@github.com wrote:
Why cannot just pass a getChildBindings() function that returns an empty object?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pinojs/hapi-pino/pull/92?email_source=notifications&email_token=ABJZCJ6HJJD4PRZG2ADCHBDQTZRFJA5CNFSM4JM3RWTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEEZEUY#issuecomment-554275411, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJZCJ7F6QB5DZFMG52YS5TQTZRFJANCNFSM4JM3RWTA .
https://github.com/pinojs/hapi-pino/issues/91
Didn't update version. Also tests should be reviewed because in my opinion they don't do what they are meant to do.