This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 0c2f71e Revert "Opmitise LoggingMixin.log (#17280)" (#18047)
0c2f71e is described below
commit 0c2f71ea0795ef6a751c6c374d844288a75cacf0
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Sep 6 15:56:17 2021 +0200
Revert "Opmitise LoggingMixin.log (#17280)" (#18047)
This reverts commit fe7efcaeb22f9053aa1cfdec01a50dc943583a8e.
---
airflow/utils/log/logging_mixin.py | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/airflow/utils/log/logging_mixin.py
b/airflow/utils/log/logging_mixin.py
index bc67e2d..1fc0757 100644
--- a/airflow/utils/log/logging_mixin.py
+++ b/airflow/utils/log/logging_mixin.py
@@ -16,12 +16,10 @@
# specific language governing permissions and limitations
# under the License.
import abc
+import logging
import re
import sys
-from logging import Handler, Logger, StreamHandler, getLogger
-from typing import Optional
-
-from airflow.compat.functools import cached_property
+from logging import Handler, Logger, StreamHandler
# 7-bit C1 ANSI escape sequences
ANSI_ESCAPE = re.compile(r'\x1B[@-_][0-?]*[ -/]*[@-~]')
@@ -38,19 +36,18 @@ def remove_escape_codes(text: str) -> str:
class LoggingMixin:
"""Convenience super-class to have a logger configured with the class
name"""
- _log: Optional[Logger] = None
-
def __init__(self, context=None):
self._set_context(context)
- @cached_property
+ @property
def log(self) -> Logger:
"""Returns a logger."""
- if self.__class__._log is None:
- logger = getLogger(self.__class__.__module__ + '.' +
self.__class__.__name__)
- self.__class__._log = logger
- return logger
- return self.__class__._log
+ try:
+ # FIXME: LoggingMixin should have a default _log field.
+ return self._log # type: ignore
+ except AttributeError:
+ self._log = logging.getLogger(self.__class__.__module__ + '.' +
self.__class__.__name__)
+ return self._log
def _set_context(self, context):
if context is not None: