uranusjr commented on a change in pull request #20355:
URL: https://github.com/apache/airflow/pull/20355#discussion_r775082325



##########
File path: airflow/utils/log/logging_mixin.py
##########
@@ -38,17 +39,15 @@ class LoggingMixin:
     """Convenience super-class to have a logger configured with the class 
name"""
 
     def __init__(self, context=None):
+        self._log: Optional[logging.Logger] = None
         self._set_context(context)
 
     @property
     def log(self) -> Logger:
         """Returns a logger."""
-        try:
-            # FIXME: LoggingMixin should have a default _log field.
-            return self._log  # type: ignore
-        except AttributeError:
+        if not hasattr(self, '_log') or self._log is None:

Review comment:
       Class attributes are not allocated for each subclass, only once for the 
parent class that defines it, so subclasses would have no additional 
allocations to choose waste, even if they do inherit LoggingMixin withou using 
`log`.

##########
File path: airflow/utils/log/logging_mixin.py
##########
@@ -38,17 +39,15 @@ class LoggingMixin:
     """Convenience super-class to have a logger configured with the class 
name"""
 
     def __init__(self, context=None):
+        self._log: Optional[logging.Logger] = None
         self._set_context(context)
 
     @property
     def log(self) -> Logger:
         """Returns a logger."""
-        try:
-            # FIXME: LoggingMixin should have a default _log field.
-            return self._log  # type: ignore
-        except AttributeError:
+        if not hasattr(self, '_log') or self._log is None:

Review comment:
       Class attributes are not allocated for each subclass, only once for the 
parent class that defines it, so subclasses would have no additional 
allocations to choose waste, even if they do inherit LoggingMixin without using 
`log`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to