Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aws_lambda_powertools/logging/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"threadName",
"processName",
"process",
"taskName",
"asctime",
"location",
"timestamp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,29 @@ def test_log_dict_xray_is_not_present_when_explicitly_disabled(
assert "xray_trace_id" not in log_dict


def test_log_dict_task_name_is_not_present_when_inside_asyncio_task(
stdout,
service_name,
):
# GIVEN Logger is initialized
logger = Logger(
service=service_name,
stream=stdout,
)

# WHEN logging a message inside an asyncio task
async def task():
logger.info("in asyncio task")

asyncio.run(task())

# THEN the logs should not contain the taskName key
logs = capture_logging_output(stdout)

assert logs[0].get("message") == "in asyncio task"
assert "taskName" not in logs[0]


def test_log_custom_std_log_attribute(stdout, service_name):
# GIVEN a logger where we have a standard log attr process
# https://docs.python.org/3/library/logging.html#logrecord-attributes
Expand Down