diff --git a/providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py b/providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py index b78ce9743ae2a..b5f6aaa12662b 100644 --- a/providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py +++ b/providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py @@ -125,9 +125,9 @@ def processors(self) -> tuple[structlog.typing.Processor, ...]: def proc(logger: structlog.typing.WrappedLogger, method_name: str, event: structlog.typing.EventDict): if not logger or not (stream_name := relative_path_from_logger(logger)): return event - # Only init the handler stream_name once. We cannot do it above when we init the handler because - # we don't yet know the log path at that point. - # we should always use the path(log-stream-name) coming from the logger. + # We can't set the log stream name in the above init handler because + # the log path isn't known at that stage. + # Instead, we should always rely on the path (log stream name) provided by the logger. _handler.log_stream_name = stream_name.as_posix().replace(":", "_") name = event.get("logger_name") or event.get("logger", "") level = structlog.stdlib.NAME_TO_LEVEL.get(method_name.lower(), logging.INFO)