Skip to content

Use logging.NullHandler #3403

Closed
Closed
@aguckenber-chwy

Description

@aguckenber-chwy

Describe the feature

Referencing this line. Please change it to using logging.NullHandler() instead of a custom handler. Because boto3 (as well as botocore and s3transfer) creates its own NullHandler, I as a developer can't iterate through the handlers and do a simple isinstance(handler, logging.NullHandler).

Use Case

Need to pull the class name and hope boto3 stays using the name NullHandler:

```python
loggers = []
for logger_name, logger_instance in logging.root.manager.loggerDict.items():
    if hasattr(logger_instance, "handlers"):
        for handler in logger_instance.handlers:
            if handler.__class__.__name__ != "NullHandler": # isinstance is preferred here
                loggers.append(logger_name)
                break

Proposed Solution

logging.getLogger('boto3').addHandler(logging.NullHandler())

And remove the custom class. Or, bare minimum, at least inherit from pythons NullHandler instead of from Handler.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

latest

Environment details (OS name and version, etc.)

not-needed

Metadata

Metadata

Labels

feature-requestThis issue requests a feature.p3This is a minor priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions