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

Bug: Register existing loggers function should use module logging, not source logger #4714

Closed
plondino opened this issue Jul 9, 2024 · 6 comments
Assignees

Comments

@plondino
Copy link

plondino commented Jul 9, 2024

Expected Behaviour

I would expect that the logging levels for code in aws_lambda_powertools library can be adjusted independently of the main application code.

For example, if I explicitly configure the aws_lambda_powertools module to have an INFO level, I wouldn't get messages from the library higher than info, e.g.:

logging.getLogger('aws_lambda_powertools').setLevel(logging.INFO)

I would also expect the name attribute of the log messages to be the module, not the service name.

Current Behaviour

Currently the copy_config_to_registered_loggers uses the passed in source logger (the logger configured for the top level application) to log its own configuration messages, so if my source logger is set to DEBUG, I get a bunch of debug messages from this code:

source_logger.debug(f"Logger {logger} reconfigured to use {source_handler}")

e.g.

{"level":"DEBUG","location":"_configure_logger:102","message":"Logger <Logger concurrent (WARNING)> reconfigured to use <StreamHandler <_io.FileIO name=6 mode='rb+' closefd=True> (NOTSET)>","timestamp":"2024-07-08T19:55:26.427-0400","service":"publisher","name":"publisher"}
{"level":"DEBUG","location":"_configure_logger:102","message":"Logger <Logger asyncio (WARNING)> reconfigured to use <StreamHandler <_io.FileIO name=6 mode='rb+' closefd=True> (NOTSET)>","timestamp":"2024-07-08T19:55:26.427-0400","service":"publisher","name":"publisher"}

This is problematic because:
a) I have no way to adjust the verbosity of this function short of setting my entire application log level
b) It shows the log messages as originating from my application and not from the powertools modules.

Ideally, the module should configure a regular Python logger and use that for its own internal logging.

Code snippet

See above

Possible Solution

No response

Steps to Reproduce

See above

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.11

Packaging format used

PyPi

Debugging logs

No response

@leandrodamascena
Copy link
Contributor

Hello @heitorlessa! Can you help with this when you get back from PTO?

@leandrodamascena leandrodamascena moved this from Triage to Backlog in Powertools for AWS Lambda (Python) Jul 9, 2024
@leandrodamascena leandrodamascena removed the triage Pending triage from maintainers label Jul 9, 2024
@dreamorosi dreamorosi added the revisit-in-3-months Requires more customers feedback before making or revisiting a decision label Jul 22, 2024
@heitorlessa heitorlessa added not-a-bug and removed bug Something isn't working labels Jul 22, 2024
@heitorlessa
Copy link
Contributor

@plondino thanks a lot for submitting it!

yup, I've changed to not-a-bug as IIRC this was intentional (a disagree & commit situation) back then from the community.

b) It shows the log messages as originating from my application and not from the powertools modules.

This was the original argument back then but it got lost in between calls and PRs. I agree ^ and it's a quick change that we can include this Thursday's release.

@heitorlessa heitorlessa moved this from Backlog to Working on it in Powertools for AWS Lambda (Python) Jul 22, 2024
@heitorlessa heitorlessa self-assigned this Jul 22, 2024
@heitorlessa heitorlessa removed the revisit-in-3-months Requires more customers feedback before making or revisiting a decision label Jul 22, 2024
@heitorlessa
Copy link
Contributor

talked to @leandrodamascena, this will be this Thursday's release. We also publish alpha releases every morning (UTC)

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Jul 22, 2024
@leandrodamascena
Copy link
Contributor

Thanks for working on this @heitorlessa!

Closing as completed! #4793

@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Jul 22, 2024
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Copy link
Contributor

This is now released under 2.42.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Coming soon
Development

No branches or pull requests

4 participants