Skip to content

Commit

Permalink
Set propagate to False on "uvicorn" logger (encode#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
guyskk authored and Kludex committed Oct 29, 2022
1 parent 7c2567c commit a6743f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/conftest.py
Expand Up @@ -15,6 +15,17 @@

from uvicorn.config import LOGGING_CONFIG

# Note: We explicitly turn the propagate on just for tests, because pytest
# caplog not able to capture no-propagate loggers.
#
# And the caplog_for_logger helper also not work on test config cases, because
# when create Config object, Config.configure_logging will remove caplog.handler.
#
# The simple solution is set propagate=True before execute tests.
#
# See also: https://github.com/pytest-dev/pytest/issues/3697
LOGGING_CONFIG["loggers"]["uvicorn"]["propagate"] = True


@pytest.fixture
def tls_certificate_authority() -> trustme.CA:
Expand Down
2 changes: 1 addition & 1 deletion uvicorn/config.py
Expand Up @@ -118,7 +118,7 @@
},
},
"loggers": {
"uvicorn": {"handlers": ["default"], "level": "INFO"},
"uvicorn": {"handlers": ["default"], "level": "INFO", "propagate": False},
"uvicorn.error": {"level": "INFO"},
"uvicorn.access": {"handlers": ["access"], "level": "INFO", "propagate": False},
},
Expand Down

0 comments on commit a6743f8

Please sign in to comment.