airflow-commits mailing list archives

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


Ash Berlin-Taylor commented on AIRFLOW-1605:

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

import logging
import inspect

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


We could then this in the calling modules:

import airflow.utils.log
log = airflow.utils.log.module_logger()

(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:
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: Fokko Driesprong
> As mentioned by ashb:
> 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

View raw message