From 6ec811393a805e38a5938ddd70e6f7414892a3e8 Mon Sep 17 00:00:00 2001 From: avi Date: Fri, 18 Sep 2026 13:13:40 -0500 Subject: [PATCH] =?UTF-8?q?Migrations=20no=20longer=20clobber=20app=20logg?= =?UTF-8?q?ing:=20drop=20fileConfig(alembic.ini)=20from=20migrations/env.p?= =?UTF-8?q?y.=20fileConfig=20rewrote=20the=20root=20logger=20(WARN=20+=20d?= =?UTF-8?q?isable=5Fexisting)=20during=20the=20engine's=20startup=20migrat?= =?UTF-8?q?ion,=20silently=20muting=20every=20INFO=20line=20afterwards=20?= =?UTF-8?q?=E2=80=94=20engine.log=20froze=20at=20the=20migration's=20last?= =?UTF-8?q?=20line=20and=20uvicorn=20access=20logs=20vanished,=20swallowin?= =?UTF-8?q?g=20the=20TRACE=20instrumentation.=20The=20app=20owns=20logging?= =?UTF-8?q?=20(main.py=20basicConfig);=20alembic.ini's=20[loggers]=20appli?= =?UTF-8?q?ed=20only=20to=20standalone=20CLI=20runs.=20Verified:=20fresh?= =?UTF-8?q?=20engine=20boot=20now=20logs=20access=20lines=20live=20(GET=20?= =?UTF-8?q?/jobs=20flowing),=2083=20tests=20pass.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/migrations/env.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/migrations/env.py b/backend/migrations/env.py index fae9a1d..38ccd64 100644 --- a/backend/migrations/env.py +++ b/backend/migrations/env.py @@ -3,7 +3,6 @@ from __future__ import annotations import asyncio -from logging.config import fileConfig from alembic import context from sqlalchemy import pool @@ -14,9 +13,15 @@ from shonar.core.config import get_settings from shonar.db import models # noqa: F401 (register tables) from shonar.db.base import Base +# NOTE: deliberately NO fileConfig(alembic.ini) here. fileConfig rewrites +# the ROOT logger (alembic.ini sets it to WARN and disables existing +# loggers), so calling it during the app's startup migration silently +# muted every INFO line the engine and uvicorn emitted afterwards. The +# app owns its logging config (shonar.main basicConfig); alembic.ini's +# [loggers] sections only ever applied to standalone CLI runs, which work +# fine with Python's default logging. + config = context.config -if config.config_file_name is not None: - fileConfig(config.config_file_name) settings = get_settings() config.set_main_option("sqlalchemy.url", settings.database_url)