pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

[Feature] Add option which does the opposite of `ignore` #363

Closed WoodyWoodsta closed 2 years ago

WoodyWoodsta commented 2 years ago

Our use case of pino is to include contextual info under 1 log key (like data). During development, we're only really interested in this key, along with the top log line output (timestamp, message, etc).

The options for pino-pretty don't allow us to ignore all keys except for data, unless we ignore keys exhaustively. This means we have to understand all possible keys in the object, and have to keep updating this list as we find more keys to ignore. This isn't really sustainable.

Proposal

Add an option only, or select, which will select the keys to output, and will override ignore if they are both given.

monkeyscorpionratdev commented 2 years ago

This would be nice, for example in my case, I want to include only req.headers.host and ignore everything else in req.headers.*. , I currently have to explicitly add all possible headers to ignore list which is not ideal since we have no control on what will be giving in request headers.

This feature could be the right solution for my case.

mcollina commented 2 years ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

WoodyWoodsta commented 2 years ago

We've since rolled our own formatter as we needed a lot more than this change. If I find the time I'll contribute, but this is looking unlikely at the moment.

TommyDew42 commented 2 years ago

Hey lemme take this one! If @WoodyWoodsta haven't had time for it.

WoodyWoodsta commented 2 years ago

No time for it - go ahead!