Closed palbrecht1 closed 7 months ago
I think you can use customReceivedObject
option. Check out the tests and docs.
@mcollina I believe that in customReceivedObject you don't have access to the request body unless you use the custom serializers, in which case you then ahve the body in all the logs not just the first one
I use pino-http in a NestJS project and my log messages look like this:
Pino HTTP is what generates the first and last line and Pino is used for the inbetween (my log 1, my log 2).
My issue is that all my logs have the
req.headers
(and in my case a sanitized version of thereq.body
). Because there could be hundreds of log lines by Pino between the moment the request is received and the moment I send a response, the log output ends up annoyingly huge.I'm already using a custom serializer to append
req.body
, but what I'm looking for is to only showreq.headers
(andreq.body
) in the first log for the request, not any of the subsequent ones. If I need to look what headers / body were sent in "my log 1", I'll just scroll up to read it from "-> GET /my-endpoint".