Skip to content

Static typing: The add_handler API from logger was removed #2377

Closed
@alexandreczg

Description

@alexandreczg

Expected Behaviour

In version 2.4.0 adding a handler to the log was easy. I would expect adding a handler to my log to be as simple as addHandler.

Current Behaviour

Method doesn't exist

image

Code snippet

logger = logging.Logger()
logger.addHandler(additional_handler)

But that API was removed on version 2.15.0. I depend on it to be able to log to cloudwatch and other places. I was reading the changelog but could not find any reference to this.

the only way around of this is to mess with the internals:

logger._logger.addHandler(additional_handler)


### Possible Solution

Semver would dictate that the public API doesn't change with a minor version upgrade. Did I miss something something regarding this breaking change? Is there another workaround?

### Steps to Reproduce

Above

### Powertools for AWS Lambda (Python) version

latest

### AWS Lambda function runtime

3.10

### Packaging format used

PyPi

### Debugging logs

_No response_

Metadata

Metadata

Assignees

Labels

loggertypingStatic typing definition related issues (mypy, pyright, etc.)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions