From acc2338aed8d789503dca7fba262b326eeb5c117 Mon Sep 17 00:00:00 2001 From: Daniel Standish <15932138+dstandish@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:02:45 -0700 Subject: [PATCH] Fix stacklevel for TaskContextLogger (#39142) Previously it would show the message as coming from context logger module and not the actual call site. --- airflow/utils/log/task_context_logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/utils/log/task_context_logger.py b/airflow/utils/log/task_context_logger.py index 07a5ed74e8be7..61cecfd92f5bb 100644 --- a/airflow/utils/log/task_context_logger.py +++ b/airflow/utils/log/task_context_logger.py @@ -101,7 +101,7 @@ def _log(self, level: int, msg: str, *args, ti: TaskInstance): task_handler.set_context(ti, identifier=self.component_name) if hasattr(task_handler, "mark_end_on_close"): task_handler.mark_end_on_close = False - filename, lineno, func, stackinfo = logger.findCaller() + filename, lineno, func, stackinfo = logger.findCaller(stacklevel=3) record = logging.LogRecord( self.component_name, level, filename, lineno, msg, args, None, func=func )