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

Too verbose for development? #60

Open
broom9 opened this issue Mar 13, 2019 · 5 comments
Open

Too verbose for development? #60

broom9 opened this issue Mar 13, 2019 · 5 comments

Comments

@broom9
Copy link

broom9 commented Mar 13, 2019

The multiple-line logs in console feel a bit verbose during development. Is there an easy (less custom code) way to output a simple one-line log for each request similar as Morgan?

I realized pino-toke is built for that. But it is also meant to be a CLI tool. We already need to pipe the output to pino-pretty. How do you suggest to use pino-pretty and pino-toke together?

@mcollina
Copy link
Member

I don't understand. Why you would need pin-pretty if you are using pino-toke?

@broom9
Copy link
Author

broom9 commented Mar 13, 2019

Thanks for the quick reply. I was probably not clear.

In a typical Express-based web app, we could have http logs from express-pino-logger and app logs from calling logger.debug/info/warn/error method from pino.

During development, we would like to pretty print http logs so that each req only generates one line of log (which looks like need to be done by pino-toke), and also pretty print app logs via pino-pretty.

@mcollina
Copy link
Member

That use case is not currently supported :/.

@davidmarkclements
Copy link
Member

on a side note you might want to checkout http://npm.im/pino-colada

@muuhoffman
Copy link

muuhoffman commented Jan 29, 2021

One solution I can think of is to use a custom serializer for development. You would just check your environment for whether you're in development or not and then change the serializer to only include minimal info. Check out the pino-http README to see the documentation for custom serializers.

const expressLogger = expressPino({
  logger,
  serializers: {
    req: (req) => {
      if (process.env.NODE_ENV === "development") {
        return {
          method: req.method,
          url: req.url,
        };
      } else {
        return req;
      }
    },
  },
});

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

4 participants