pino-pretty icon indicating copy to clipboard operation
pino-pretty copied to clipboard

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

Open WoodyWoodsta opened this issue 2 years ago • 3 comments

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.

WoodyWoodsta avatar Jul 14 '22 10:07 WoodyWoodsta

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.

monkeyscorpionratdev avatar Jul 27 '22 06:07 monkeyscorpionratdev

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

mcollina avatar Jul 27 '22 08:07 mcollina

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.

WoodyWoodsta avatar Jul 27 '22 08:07 WoodyWoodsta

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

TommyDew42 avatar Aug 19 '22 16:08 TommyDew42

No time for it - go ahead!

WoodyWoodsta avatar Aug 19 '22 17:08 WoodyWoodsta