pinojs / pino-pretty

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

Ho to properly pass log level via cli? #390

Closed enricoangelon closed 1 year ago

enricoangelon commented 1 year ago

Hello, I tried following the documentation to pass the levelVal property via CLI by using the -L flag but doesn't seem to have any effect in my workspace, I tried passing both -L 10 and -L 'trace' but logger.levelVal remains the same. Thanks in advice.

jsumners commented 1 year ago

What are you expecting? The docs state that logs will be filtered according to that value. They do not state that the logger generating the logs will have its level changed.

enricoangelon commented 1 year ago

This could also mean that if I put a low level of filtering, it shouldn't filter me logs such as trace, it's highly questionable. Anyway, if this isn't the correct flag, which one should I use?

jsumners commented 1 year ago

I don't know what you're asking.

'use strict'

const log = require('pino')({ level: 'trace' })

log.info('not filtered')
log.debug('not filtered')
log.trace('filtered')
❯ node index.js | pino-pretty -L debug
[08:46:11.194] INFO (24434): not filtered
[08:46:11.195] DEBUG (24434): not filtered
enricoangelon commented 1 year ago

Now I understand the concept better, but if I wanted pino to have for example { level: 'info' } but when I pipe with pino-pretty I can also show other underlying levels (trace, debug...), it is possible through some cli argument?

jsumners commented 1 year ago

Please read the docs for this tool. That is not in scope.