fix: logging updates to prevent silent errors

This commit is contained in:
James Westbrook committed 2026-03-29 12:47:20 -06:00
1 parent dbb870c9fa
commit 0cb5a73e61
4 files changed
+10 -5

No files matched your search

+2
View File
@@ -1,5 +1,7 @@
FROM python:3.12-slim
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY . .
+3 -1
View File
@@ -46,4 +46,6 @@ def setup_logging() -> None:
# Intercept stdlib logging (uvicorn, sqlalchemy, etc.).
logging.basicConfig(handlers=[_InterceptHandler()], level=0, force=True)
for name in ("uvicorn", "uvicorn.error", "uvicorn.access", "sqlalchemy"):
logging.getLogger(name).handlers = [_InterceptHandler()]
named = logging.getLogger(name)
named.handlers = [_InterceptHandler()]
named.propagate = False
+4 -3
View File
@@ -17,11 +17,12 @@ from terminals.routers.proxy import close_proxy_client, router as proxy_router
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Startup / shutdown lifecycle."""
setup_logging()
# Run DB migrations
# Run DB migrations first (alembic's fileConfig reconfigures logging).
init_db()
# Set up loguru AFTER alembic so our InterceptHandler isn't overwritten.
setup_logging()
app.state.backend = create_backend()
# Recover state from any running containers (survives process restart).
+1 -1
View File
@@ -23,7 +23,7 @@ config = context.config
# Set up Python logging from the INI file.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
fileConfig(config.config_file_name, disable_existing_loggers=False)
# Target metadata for autogenerate support.
target_metadata = Base.metadata