Skip to content
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

Log at the beginning of the request #120

Open
muuhoffman opened this issue Jan 29, 2021 · 1 comment
Open

Log at the beginning of the request #120

muuhoffman opened this issue Jan 29, 2021 · 1 comment

Comments

@muuhoffman
Copy link

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.

@francisdb
Copy link

There is customReceivedMessage that was added in #177

https://github.com/pinojs/pino-http#pinohttpopts-stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants