airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Davis (JIRA)" <>
Subject [jira] [Commented] (AIRFLOW-2127) Airflow's Alembic migrations globally disable logging
Date Tue, 20 Feb 2018 19:20:00 GMT


Matt Davis commented on AIRFLOW-2127:

Here's the PR adding {{disable_existing_loggers=False}}:

> Airflow's Alembic migrations globally disable logging
> -----------------------------------------------------
>                 Key: AIRFLOW-2127
>                 URL:
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: db
>            Reporter: Matt Davis
>            Priority: Major
> When running Airflow's {{[upgradedb|]}},
and {{[initdb|]}} functions
logging is disabled thereafter for all but the {{sqlalchemy.engine}} and {{alembic}} loggers.
This is caused [this usage|]
of Python's {{fileConfig}} function, which by default disables all loggers that aren't part
of the supplied configuration. (See [Python 2 docs|]
and [Python 3 docs|].)
This can be fixed by adding {{disable_existing_loggers=False}} to the call of {{fileConfig}}.
> This has affected us at Clover Health because we use these database utility functions
in some of our tooling, and particularly our _tests_ of the tooling. Having all logging disabled
in the midst of our tests has it difficult to test our use of logging in completely unrelated
parts of our codebase.
> As an example, we were trying to use [pytest's caplog feature|],
but were unable to do so with logging globally disabled by {{fileConfig}}. Here's an example
of a test that fails with {{disable_existing_loggers=True}} (the default), but passes with
> {code}
> import logging
> import pytest
> import airflow.utils.db as af_db
> LOGGER = logging.getLogger(__name__)
> @pytest.fixture(autouse=True)
> def resetdb():
>     af_db.resetdb()
> def test_caplog(caplog):
>'LINE 1')
>     assert caplog.record_tuples
>     assert 'LINE 1' in caplog.text
> {code}
> I'll submit a pull request shortly to add {{disable_existing_loggers=False}} to Airflow's

This message was sent by Atlassian JIRA

View raw message