pinojs / pino-http

🌲 high-speed HTTP logger for Node.js
MIT License
527 stars 117 forks source link

Recipe for local development and for human eyes? #345

Closed binarykitchen closed 1 month ago

binarykitchen commented 1 month ago

In short: too much is logged for humans.

The longer version:

Imagine, you are a tired developer, using this cool library, do not want to scroll too much at late hour and have this code:

app.use(pinoHttp({ transport: { target: "pino-pretty", options: { colorize: true } } }));

... and a big JSON is printed in the console. Something like that:

[20:05:05.872] INFO (102901): request completed
    req: {
      "id": 1,
      "method": "POST",
      "url": "/whitelist2",
      "query": {},
      "params": {},
      "headers": {
        "host": "----",
        "connection": "keep-alive",
        "content-length": "123",
        "sec-ch-ua": "\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\"",
        "content-type": "application/json",
        "dnt": "1",
        "sec-ch-ua-mobile": "?0",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
        "sec-ch-ua-platform": "\"Linux\"",

Of course, this information is great for production. For local development, I'm only keen on, like the API URL/method, parameters, response and any errors if any; all that on a single line. Nothing else further.

I read your documentation two times, and haven't found a recipe for this yet, hence I raised this issue.

binarykitchen commented 1 month ago

Related to https://github.com/pinojs/pino-http/issues/60

I think I should fine-tune with serializers.

jsumners commented 1 month ago

Related to https://github.com/pinojs/pino-http/issues/60

I think I should fine-tune with serializers.

Yes. That would be an appropriate choice.