airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ash Berlin-Taylor (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRFLOW-1605) Fix log source of local loggers
Date Wed, 13 Sep 2017 09:35:01 GMT

    [ https://issues.apache.org/jira/browse/AIRFLOW-1605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16164386#comment-16164386
] 

Ash Berlin-Taylor commented on AIRFLOW-1605:
--------------------------------------------

One possible way of dealing with this would be something like this, in say airflow/utils/log/__init__.py:

{code}
import logging
import inspect


def module_logger():
    frame = inspect.stack()[1]
    try:
        module = inspect.getmodule(frame[0])
        return logging.root.getChild(module.__name__)
    finally:
        # As recommended by python docs: explicitly delete frame to avoid GC cycles.
        del frame

{code}

We could then this in the calling modules:

{code}
import airflow.utils.log
log = airflow.utils.log.module_logger()
{code}

(The inspect usage is just to avoid having to pass __module__ in every time, but I'm not sure
how good of an idea it is.)

> Fix log source of local loggers
> -------------------------------
>
>                 Key: AIRFLOW-1605
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1605
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: Fokko Driesprong
>
> As mentioned by ashb:
> https://github.com/apache/incubator-airflow/pull/2592#discussion_r138553133
> Sometimes we need to initialise a new logger because there is no logger in scope. Currently
this new logger will have airflow.utils.log.LoggingMixin.LoggingMixin as source. This needs
to be fixed by passing a reference to the logger class.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message