Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation on global logging level with multiple targets #1895

Open
mjarosie opened this issue Feb 5, 2024 · 4 comments
Open

Comments

@mjarosie
Copy link

mjarosie commented Feb 5, 2024

The "global" level setting isn't taken into account when transport.targets parameter is provided - each target has its own level that defaults to info (as mentioned here). That might be a bit confusing and should probably be mentioned in the documentation.

For example originally having this config:

const logger = pino({
  level: 'debug',
  transport: {
    target: 'pino-pretty',
  },
})

logger.trace('trace') # Doesn't appear
logger.debug('debug')
logger.info('info')
logger.warn('warn')
logger.error('error')
logger.fatal('fatal')

If I switch to the following, I'd lose debug logs:

const logger = pino({
  level: 'debug',
  transport: {
    targets: [{ target: 'pino-pretty' }],
  },
})

logger.trace('trace') # Doesn't appear
logger.debug('debug') # Doesn't appear
logger.info('info')
logger.warn('warn')
logger.error('error')
logger.fatal('fatal')

I appreciate that this might be an expected behaviour, but I'd expect this to be documented explicitly - I couldn't find the mention of it, unless I didn't look in the right place or I somehow missed it? It took me some time to figure out what's happening - it only started making sense when I've found the comment in the GitHub issue linked above.

@jsumners
Copy link
Member

jsumners commented Feb 5, 2024

pino/docs/api.md

Line 1267 in 9259e13

* `targets`: May be specified instead of `target`. Must be an array of transport configurations. Transport configurations include the aforementioned `options` and `target` options plus a `level` option which will send only logs above a specified level to a transport.

@mjarosie
Copy link
Author

mjarosie commented Feb 6, 2024

pino/docs/api.md

Line 1267 in 9259e13

* `targets`: May be specified instead of `target`. Must be an array of transport configurations. Transport configurations include the aforementioned `options` and `target` options plus a `level` option which will send only logs above a specified level to a transport.

I don't see how the linked option documentation would clear up the confusion. I think that it should be clearly stated here or here to make it clear that if you provide a list of targets to pino(), the top-level level option is ignored.

@jsumners
Copy link
Member

jsumners commented Feb 6, 2024

Would you like to send a Pull Request to address this issue?

@mjarosie
Copy link
Author

mjarosie commented Feb 8, 2024

Sure, will create one soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants