Skip to content

Commit 66056ad

Browse files
Move ACCESS_LOG setting to config and use it
Add ACCESS_LOG_ENABLED to src/config/settings.py (defaults to true; accepts true/1/yes) with a comment explaining use cases (disable when fronted by a load balancer or to reduce CI noise). Update src/main.py to import and use ACCESS_LOG_ENABLED for uvicorn's access_log, and remove the now-unused local getenv/os usage. Centralizes the access-log configuration.
1 parent 3b64b27 commit 66056ad

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/config/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@
9090
"yes",
9191
)
9292

93+
# Whether uvicorn emits an access log line per HTTP request. On by
94+
# default; flip via ACCESS_LOG=false (e.g. when fronted by a load balancer
95+
# that already logs requests, or to reduce log noise in CI).
96+
ACCESS_LOG_ENABLED = os.getenv("ACCESS_LOG", "true").lower() in ("true", "1", "yes")
97+
9398
# Number of uvicorn worker processes to allow. Multi-worker is currently
9499
# unsupported because the RBAC permission cache and the OAuth-subject→DB-id
95100
# cache are per-process; the lifespan startup hook hard-fails if this is >1

src/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
import asyncio
2424
import atexit
25-
import os
2625

2726
# Re-exported so tests that monkeypatch "main.httpx.AsyncClient" keep working.
2827
# Module attributes in Python are shared singletons, so the patch propagates
2928
# to services/default_docs_service.py which calls httpx.AsyncClient directly.
3029
import httpx # noqa: F401
3130

3231
from app.factory import create_app
32+
from config.settings import ACCESS_LOG_ENABLED
3333
from services.default_docs_service import (
3434
_get_remote_docs_signature,
3535
_should_use_url_default_docs_ingest,
@@ -87,14 +87,12 @@ def cleanup():
8787

8888
app = asyncio.run(create_app())
8989

90-
access_log = os.getenv("ACCESS_LOG", "true").lower() == "true"
91-
9290
uvicorn.run(
9391
app,
9492
workers=1,
9593
host="0.0.0.0",
9694
port=8000,
9795
reload=False,
98-
access_log=access_log,
96+
access_log=ACCESS_LOG_ENABLED,
9997
log_config=None,
10098
)

0 commit comments

Comments
 (0)