Skip to content

Feature request: Add addFilter and removeFilter to Logger #3358

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

Closed
1 of 2 tasks
rafrafek opened this issue Nov 17, 2023 · 11 comments
Closed
1 of 2 tasks

Feature request: Add addFilter and removeFilter to Logger #3358

rafrafek opened this issue Nov 17, 2023 · 11 comments
Labels

Comments

@rafrafek
Copy link
Contributor

Use case

Pyright complains:

import logging
from aws_lambda_powertools.logging import Logger
logger = Logger(name="%(name)s")
temp_filter = logging.Filter()
logger.addFilter(temp_filter)  # Cannot access member "addFilter" for type "Logger"
logger.removeFilter(temp_filter)  # Cannot access member "removeFilter" for type "Logger"

Solution/User Experience

Add addFilter and removeFilter to Logger to match the built-in Python's logger.

Alternative solutions

import logging
from aws_lambda_powertools.logging import Logger
logger = Logger(name="%(name)s")
temp_filter = logging.Filter()
logger._logger.addFilter(temp_filter)
logger._logger.removeFilter(temp_filter)

Acknowledgment

@rafrafek rafrafek added feature-request feature request triage Pending triage from maintainers labels Nov 17, 2023
@heitorlessa heitorlessa added logger and removed triage Pending triage from maintainers labels Nov 21, 2023
@heitorlessa heitorlessa moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Nov 21, 2023
@heitorlessa
Copy link
Contributor

hey @rafrafek thanks a lot for reporting it, working on it now.

@heitorlessa
Copy link
Contributor

Done - should be out in the next release after re:Invent. #3380

@rafrafek
Copy link
Contributor Author

Thank you! Can you include removeFilter?

@heitorlessa
Copy link
Contributor

Oops, forgot! Sending that shortly

@rafrafek
Copy link
Contributor Author

Thanks!

@heitorlessa
Copy link
Contributor

All done, merging shortly. Fixed the exception type too #3356

@heitorlessa
Copy link
Contributor

Closing, coming up in the next release. Thank you one more time @rafrafek for reporting it!

@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Nov 21, 2023
@heitorlessa heitorlessa added the pending-release Fix or implementation already in dev waiting to be released label Nov 21, 2023
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.

@heitorlessa
Copy link
Contributor

@rafrafek releasing it now so you don't have to wait until re:Invent is over :) A logger bugfix along with the release too

Copy link
Contributor

This is now released under 2.27.1 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Nov 21, 2023
@rafrafek
Copy link
Contributor Author

Thank you very much!

@heitorlessa heitorlessa moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Shipped
Development

No branches or pull requests

2 participants