Skip to content

fix(server): display uvicorn lifecycle logs without an error logger name - #1335

Merged
Teingi merged 2 commits into
oceanbase:masterfrom
AlexStocks:fix/uvicorn-logger-display-name
Aug 25, 2026
Merged

fix(server): display uvicorn lifecycle logs without an error logger name#1335
Teingi merged 2 commits into
oceanbase:masterfrom
AlexStocks:fix/uvicorn-logger-display-name

Conversation

@AlexStocks

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

N/A — discovered during local usage; no tracking issue exists.

Rationale for this change

uvicorn hardcodes uvicorn.error as its lifecycle logger name, which mostly
carries INFO startup lines but reads like an error channel. New users routinely
misread startup logs such as INFO uvicorn.error Started server process as an
error. The Logger.name attribute is read-only, so the fix rewrites the record
name in the display layer only.

What changes are included in this PR?

  • src/powercontext/server/logging.py: add _UvicornDisplayNameFilter,
    registered in the dictConfig and attached to the uvicorn.error logger
    (attached to the logger, not the shared handler, so powercontext's own
    loggers are unaffected). It rewrites record.name to uvicorn for display;
    the logger tree, level routing, and any filtering keyed on the original name
    are untouched.
  • tests/test_server_logging.py: add 2 unit tests — the rewrite makes the JSON
    formatter emit "logger":"uvicorn", and other logger names are left untouched.

Are there any user-facing changes?

Display-only: server startup/shutdown logs now render as INFO uvicorn ...
instead of INFO uvicorn.error .... No API, config, or persisted format
changes. JSON-formatted logs emit "logger":"uvicorn" as well. Real errors
still render as ERROR uvicorn ....

How was this change tested?

  • uv run python -m pytest tests/test_server_logging.py: 6 passed
  • uv run ruff check src/powercontext/server/logging.py tests/test_server_logging.py: passed
  • Manual: started the server and verified startup/shutdown lines render as
    INFO uvicorn ...; a simulated error still renders as ERROR uvicorn ...

AI usage statement

An AI assistant (WorkBuddy) was used to implement the filter and draft this PR
description; the implementation was validated locally with tests and manual
runs.

uvicorn hardcodes uvicorn.error as its lifecycle logger name, which reads
like an error channel while it mostly carries INFO startup lines. Rewrite
the record name in the display layer only: attach a filter to the
uvicorn.error logger that renders it as uvicorn. The logger tree, level
routing, and JSON output stay consistent, and powercontext's own loggers
are untouched.
Comment thread tests/test_server_logging.py Outdated
Comment thread src/powercontext/server/logging.py Outdated

@Teingi Teingi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Teingi
Teingi merged commit 7b35ce4 into oceanbase:master Aug 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants