pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.25k stars 147 forks source link

How to format child logger like debug package? #333

Closed jeffrson closed 2 years ago

jeffrson commented 2 years ago

With debug package we had logs with names like "app:sub1", "app:another" a.s.o.

How can I achieve this with pino/pino-pretty?

At first I tried

logger.child({name: "sub1"})

which created log entries with two "name" fields (one for main, one for child). Then I used

logger.child({category: "sub1"})

which is formatted by pino-pretty in a second line.

What is the recommended approach?

jeffrson commented 2 years ago

Looks like overwriting "name" works with pino-pretty as expected:

logger.child({name: "main:sub1"})

However, there seems to be a bug in pino: https://github.com/pinojs/pino/issues/1420