pino-http
pino-http copied to clipboard
Log at the beginning of the request
For human readable logs I think it makes sense to have a log at the beginning of the request and at the end so it's easy to see in the logs what happens between the start and end of the request. Right now I'm accomplishing it by doing this:
server.use((req, res, next) => {
// log the start of the request
logger.info({msg: "Handling request", "url": req.url})
return expressLogger(req, res, next);
});
However, this method doesn't exclude routes from my ignorePaths
, so it seems like this would be pretty nice to just have a function or something in the configuration that gets run before the rest of the request code gets executed that can print out something before the request runs. This took me a lot of trial and error to find the right placement here. I'm curious if other people have this need, and if this is the best practice for accomplishing this today.
There is customReceivedMessage
that was added in #177
https://github.com/pinojs/pino-http#pinohttpopts-stream