pinojs / pino-pretty

🌲Basic prettifier for Pino log lines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to format child logger like debug package?

jeffrson opened this issue · comments

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?

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

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

However, there seems to be a bug in pino: pinojs/pino#1420