pino-pretty: Log level incorrectly shows up as USERLVL when `useLevelLabels: true`
I created pino with option useLevelLabels: true
. When formatting via pino-pretty those log lines show up as
[2019-04-23 13:56:29.560 +0000] USERLVL (runScript): Request did succeed
The log line itself cpontains
{
"level": "info",
"time": 1556027789560,
"name": "runScript",
"msg": "Request did succeed",
"v": 1
}
Given that useLevelLabels
is a feature built into pino, pino-pretty should be able to understand their corresponding string based levels.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 11
- Comments: 24 (11 by maintainers)
Is there currently any way to work around this? I am currently using the RFC5424 Syslog levels https://tools.ietf.org/html/rfc5424 for more granular logging and the ones that are not defined by pino itself in https://github.com/pinojs/pino-pretty/blob/master/lib/constants.js#L12-L20 just end up showing as USERLVL which is rather unfortunate.
@rodrigo-oleria I’ve successfully addressed a similar issue with Pino and pino-pretty by defining custom log levels. Here’s the TypeScript code that worked for me:
While the lack of type safety in this configuration might be inconvenient, the infrequency of changes to the logger’s setup makes this a manageable aspect for me.
The key was ensuring the custom levels and their colors were accurately defined and integrated into both Pino and the pino-pretty transport options. This setup has been effective in my use case.
@55Cancri They’ve been waiting for your submission, clearly! Would you like to send a PR? https://github.com/pinojs/pino-pretty/pull/317 is not covering what you need?
Ah got it. Confirming pino-pretty@next works. It’s worth noting that I installed
pino
notpino@next
so it’d be great if pino-pretty can be synced with pino version wise.What I’m saying is we don’t need to maintain anything beyond the standard ones defined (10,20,30,40,50 + trace,debug,info,warn,error). The rest just display exactly as
USERLVL
today except instead of using the wordUSERLVL
it would be as the level themselves.