Apply suggestions from code review of branch no-uvicorn.error-logs-without-error

Co-authored-by: Richard Bowman <richard.bowman@cantab.net>
This commit is contained in:
Julian Stirling 2025-08-27 13:24:37 +00:00
parent 95969c5daa
commit 353d311c1e
2 changed files with 2 additions and 4 deletions

View file

@ -106,10 +106,8 @@ class OFMLogFileFormatter(logging.Formatter):
def format(self, record: logging.LogRecord): def format(self, record: logging.LogRecord):
"""Adjust the logging formatting for uvicorn logs. """Adjust the logging formatting for uvicorn logs.
Any ``uvicorn.error`` logs that are at a lower
uvicorn has two loggers. Each API access is ``uvicorn.access`` which we filter uvicorn has two loggers. Each API access is ``uvicorn.access`` which we filter
due to the noise the other is ``uvicorn.error`` for more important messages. due to the noise. The other is ``uvicorn.error`` for more important messages.
However, ``uvicorn.error`` is used for expected messages that are not errors, However, ``uvicorn.error`` is used for expected messages that are not errors,
such as server start up. This can lead to people erroneously thinking that such as server start up. This can lead to people erroneously thinking that
there is an error with their miroscope. there is an error with their miroscope.

View file

@ -181,7 +181,7 @@ def test_uvicorn_error_only_says_error_on_error(
ofm_logging.OFM_HANDLER = ofm_logging.OFMHandler() ofm_logging.OFM_HANDLER = ofm_logging.OFMHandler()
with tempfile.TemporaryDirectory() as tmpdir: with tempfile.TemporaryDirectory() as tmpdir:
ofm_logging.configure_logging(tmpdir) ofm_logging.configure_logging(tmpdir)
log_command("Mockedy mock mock!") log_command("Mockety mock mock!")
with open(ofm_logging.OFM_LOG_FILE, "r", encoding="utf-8") as log_file: with open(ofm_logging.OFM_LOG_FILE, "r", encoding="utf-8") as log_file:
log_txt = log_file.read() log_txt = log_file.read()
for name in names_in_log: for name in names_in_log: