Skip to content

Bug: logger errors #4782

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
tb102122 opened this issue Jul 18, 2024 · 3 comments
Closed

Bug: logger errors #4782

tb102122 opened this issue Jul 18, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@tb102122
Copy link

Expected Behaviour

Logger successful initiated.

Current Behaviour

logger setup phase is not running successful

Code snippet

from aws_lambda_powertools import Logger

logger = Logger(service="cx_claims")

def lambda_handler(event, context):
    logger.debug("Received event: " + json.dumps(event, indent=2))
    logger.info("test")
    return True

Possible Solution

No response

Steps to Reproduce

set env var to AWS_LAMBDA_LOG_LEVEL = "INFO" invoke lambda

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

START RequestId: XXX Version: $LATEST
--- Logging error ---
Traceback (most recent call last):
File "/var/lang/lib/python3.12/logging/__init__.py", line 1160, in emit
msg = self.format(record)
^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/logging/__init__.py", line 999, in format
return fmt.format(record)
^^^^^^^^^^^^^^^^^^
File "/opt/python/aws_lambda_powertools/logging/formatter.py", line 170, in format
formatted_log["message"] = self._extract_log_message(log_record=record)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/aws_lambda_powertools/logging/formatter.py", line 283, in _extract_log_message
return log_record.getMessage()
^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/logging/__init__.py", line 392, in getMessage
msg = msg % self.args
~~~~^~~~~~~~~~~
TypeError: not all arguments converted during string formatting
Call stack:
File "/var/runtime/bootstrap.py", line 63, in <module>
main()
File "/var/runtime/bootstrap.py", line 60, in main
awslambdaricmain.main([os.environ["LAMBDA_TASK_ROOT"], os.environ["_HANDLER"]])
File "/var/lang/lib/python3.12/site-packages/awslambdaric/__main__.py", line 21, in main
bootstrap.run(app_root, handler, lambda_runtime_api_addr)
File "/var/lang/lib/python3.12/site-packages/awslambdaric/bootstrap.py", line 499, in run
handle_event_request(
File "/var/lang/lib/python3.12/site-packages/awslambdaric/bootstrap.py", line 188, in handle_event_request
response = request_handler(event, lambda_context)
@tb102122 tb102122 added bug Something isn't working triage Pending triage from maintainers labels Jul 18, 2024
@leandrodamascena
Copy link
Contributor

Hello @tb102122! Thanks for reporting this issue!

I was looking at the error and the code and I think the problem is related to the type of data you are trying to log in the logger.debug("Received event: " + json.dumps(event, indent=2)) line.

I have some questions to help me understand better the problem:

1 - Are you using custom runtime or docker images with Lambda?
2 - Can you share with me the payload? Please remove any sensitive data.
3 - What the experience you're trying to have here? You want INFO level, DEBUG level or switch between them when executing your Lambda?

Thanks

@leandrodamascena leandrodamascena removed the triage Pending triage from maintainers label Jul 19, 2024
@leandrodamascena leandrodamascena moved this from Triage to Pending customer in Powertools for AWS Lambda (Python) Jul 19, 2024
@leandrodamascena leandrodamascena self-assigned this Jul 19, 2024
@tb102122
Copy link
Author

sorry yes you are right the formatting was wrong.

@github-project-automation github-project-automation bot moved this from Pending customer to Coming soon in Powertools for AWS Lambda (Python) Jul 19, 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.

@leandrodamascena leandrodamascena moved this from Coming soon to Closed in Powertools for AWS Lambda (Python) Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants