pino-http icon indicating copy to clipboard operation
pino-http copied to clipboard

[Proposal] support for quietResLogger (similar to quietReqLogger) - log full bindings at start of request instead at the end.

Open manvydasu opened this issue 2 years ago • 1 comments

It's currently hard to implement following behavior with pino-http:

  1. Log request with headers, url, request params and other required info.
  2. Process request and call log multiple times during the scope of request. Request params, headers, etc.. should NOT be included in these logs.
  3. Log response. Request params, headers, etc... should NOT be added to this log.

It seems like with current functionality we can either add unnecessary metadata to every single log during scope of request (quietReqLogger=false) or add them at the end (quietReqLogger=true). However, there is no way to easily do the opposite - to add all aditional info at start of request, and do only lightweight logging afterwards. It seems natural, that first log of request scope should include all the metadata (i..e what if request takes way longer than expected or it hangs somehow).

manvydasu avatar Jun 22 '22 16:06 manvydasu

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

mcollina avatar Jun 22 '22 16:06 mcollina