You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bo...@apache.org on 2017/12/05 08:19:17 UTC

incubator-airflow git commit: [AIRFLOW-1881] Make operator log in task log

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 28c2d8d90 -> 97383f76d


[AIRFLOW-1881] Make operator log in task log

Previously operators logged under
airflow.operators or
airflow.contrib.operators. This unifies them under
airflow.task.operators allowing the task log to
pick
them up and not have 'double' logging.

Closes #2838 from bolkedebruin/AIRFLOW-1881


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/97383f76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/97383f76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/97383f76

Branch: refs/heads/master
Commit: 97383f76d03481e3925781e5bba65a9630c4751a
Parents: 28c2d8d
Author: Bolke de Bruin <bo...@xs4all.nl>
Authored: Tue Dec 5 09:19:11 2017 +0100
Committer: Bolke de Bruin <bo...@xs4all.nl>
Committed: Tue Dec 5 09:19:11 2017 +0100

----------------------------------------------------------------------
 airflow/models.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/97383f76/airflow/models.py
----------------------------------------------------------------------
diff --git a/airflow/models.py b/airflow/models.py
index e93e8a8..22cf9f0 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -2201,6 +2201,8 @@ class BaseOperator(LoggingMixin):
         if dag:
             self.dag = dag
 
+        self._log = logging.getLogger("airflow.task.operators")
+
         self._comps = {
             'task_id',
             'dag_id',
@@ -2412,15 +2414,28 @@ class BaseOperator(LoggingMixin):
         memo[id(self)] = result
 
         for k, v in list(self.__dict__.items()):
-            if k not in ('user_defined_macros', 'user_defined_filters', 'params'):
+            if k not in ('user_defined_macros', 'user_defined_filters',
+                         'params', '_log'):
                 setattr(result, k, copy.deepcopy(v, memo))
         result.params = self.params
         if hasattr(self, 'user_defined_macros'):
             result.user_defined_macros = self.user_defined_macros
         if hasattr(self, 'user_defined_filters'):
             result.user_defined_filters = self.user_defined_filters
+        if hasattr(self, '_log'):
+            result._log = self._log
         return result
 
+    def __getstate__(self):
+        state = dict(self.__dict__)
+        del state['_log']
+
+        return state
+
+    def __setstate__(self, state):
+        self.__dict__ = state
+        self._log = logging.getLogger("airflow.task.operators")
+
     def render_template_from_field(self, attr, content, context, jinja_env):
         """
         Renders a template from a field. If the field is a string, it will