-
Notifications
You must be signed in to change notification settings - Fork 408
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
Feature request: Copying existing logging config without touching logging levels #4226
Comments
Reading... at a glance we have the Lemme read fully and get back to you today. PS: It's uncommon for us to take this long to reply a "bug" issue, please accept our apologies as our on-call shift had an unexpected change. |
Appreciate the patience. I agree with the pain - what would be a good experience to you with an additional parameter to skip touching log level? Now, please allow me to add some context for anyone reading in the future (maintainers included).
That's expected and came from an original pain from a diverse set of customers unaware of logging in Python. To summarize our previous Slack, now Discord discussions, and that issue, it boiled down to:
With those in mind, by default it'll include all loggers. You can use As a side effect from this ask, it can get noisy so customers adjust as they see fit. That said, we could surely add a new parameter to skip touching log levels, update docs, and explain why that's desired in the grand scheme of things (e.g., logging hierarchy is a common source of doubt for devs and non-devs). Does that sum it up? This is the block of code we'd be improving once we hear from you:
Look forward to hearing from you :) |
Thank you for the thorough response and the history. An option to preserve the existing levels works for me, even if it's not the default. The one thing that still seems potentially counter-intuitive is that if there are nested loggers, they aren't touched by the existing code. E.g. if |
thank you so much again @CausticYarn for your great thoughts - I'll be tackling this today and ping for a review if you don't mind Edit: Tackling a bug first: #4295 |
PR is up: #4299 I wanted to brush up the docs a bit more but it got late here, so i added the bare minimum for now. Part of me is tempted to make this the default behaviour in v3, the other part knows a great chunk of customers use this feature in combination with log sampling, in which the One of the reasons we reverted Edit: suffice to say we'll include it in the next release so you can use it :) |
This is now released under 2.38.0 version! |
Expected Behaviour
I often use a logging config for fine grained control over the logging level of third party dependencies in a lambda application. I often need to set the overall level of an application to DEBUG or INFO but there are some very chatty libraries that obscure useful information so I set them to WARNING or ERROR. I would expect these levels to be preserved when copying them over to the powertools logger.
Current Behaviour
Current behavior is to set all existing loggers to the level of the powertools logger. It's unclear why this is necessary, as levels below the powertools logger won't get displayed anyway (e.g. DEBUG on a library when the powertools logger is INFO) and overriding higher levels to lower levels causes undesired messages to be displayed (e.g. overriding WARNING and setting it to INFO). At the very least this should be configurable. It also has odd behavior because if the logging configuration has a level set one level down, e.g.
chatty_library.submodule
that does not get overridden, so if it's higher thanchatty_library
it will get blocked.Code snippet
Possible Solution
Don't override log level in existing loggers, or make it configurable as an option to pass to
copy_config_to_registered_loggers
.It does seem that setting the logging config AFTER copying the loggers may set the values to the desired state but not sure if there are any side effects from doing it in this order.
Steps to Reproduce
See code sample.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: