awslabs / awslabs/aws-appflow-custom-connector-python

Library logging does not work with AWS Lambda Power Tools

Open
#36 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
51
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Per the lambda best practices, trying to enable structured logging
https://awslabs.github.io/aws-lambda-powertools-python/2.5.0/core/logger/#how-can-i-enable-powertools-logging-for-imported-libraries

```python
from aws_lambda_powertools.logging.logger import Logger
from aws_lambda_powertools.logging import utils

logger = Logger(service='appFlow_Connector')

utils.copy_config_to_registered_loggers(source_logger=logger)
```

But because this [line](https://github.com/awslabs/aws-appflow-custom-connector-python/blob/main/custom_connector_sdk/lambda_handler/lambda_handler.py#L26) in the SDK does not specify a logger name and implicitly uses the root logger, the power tools configuration can't apply the logger configuration to it. Hence logs are output in text format rather than JSON.

```python
def lambda_handler(self, event, context):
logger = logging.getLogger()
logger.setLevel(logging.INFO)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.