fix: centralize logging config in main.py (#26) #46
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#46
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-database#26"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #26
Summary
logging.basicConfig()call toapp/main.py— the canonical entry pointbasicConfigcalls fromapp/db_engine.py,app/dependencies.py, and all 30 router files inapp/routers_v2/LOG_DATAdict and associateddate/log_levellocals fromdependencies.pyanddb_engine.pyWhat was wrong
logging.basicConfig()is a no-op after the first call.db_engine.pywas always imported first (bymain.py), so its call won configuration. All 30+ router calls were silently discarded, and effective logging behavior was determined by import order rather than explicit intent.Files changed
app/main.py— added centralized logging setupapp/db_engine.py— removed basicConfig, date, log_level localsapp/dependencies.py— removed LOG_DATA dict and basicConfig callapp/routers_v2/*.py(30 files) — removed basicConfig calls and LOG_DATA from importsAI Code Review
Files Reviewed
app/main.py(modified — centralized logging setup added)app/db_engine.py(modified — removed duplicate basicConfig)app/dependencies.py(modified — removed LOG_DATA and duplicate basicConfig)app/routers_v2/*.py(30 files — removed LOG_DATA imports and duplicate basicConfig calls)Findings
Correctness
logging.basicConfig()is indeed a no-op after the first call, and placing the single authoritative call inmain.py— beforefrom .db_engine import dband the router imports — ensures it executes first and actually configures the root logger."WARN"as the log level indb_engine.pyanddependencies.py. The newmain.pycorrectly useslogging.WARNING(the integer constant). This is a correctness improvement.import logging— verified that each still makes directlogging.*calls in their route handlers, so no orphaned imports were introduced.dependencies.pyretainsimport logging,import os, andimport datetime— all three remain in active use bydb_get,db_patch,db_post,db_delete, andint_timestampafterLOG_DATAremoval.db_engine.pyretainsimport loggingandimport os— both are still used by the remainder of the file.Security
Style & Conventions
_log_dateunderscore prefix is a good convention for a module-level private temporary.db.create_tables()reformatting to multi-line list is a cosmetic improvement that follows standard Python style.f"{datetime.now().year}-{datetime.now().month}-{datetime.now().day}"produces single-digit months/days (e.g.2026-3-3). This is unchanged from the pre-existing format indb_engine.py, so not a regression introduced here.Suggestions
datetime.now().strftime("%Y-%m-%d")would give zero-padded dates, but that's out of scope for this PR.Verdict: APPROVED ✓
Clean, well-scoped fix. The root cause (import-order-dependent logging config) is correctly addressed by moving the single
basicConfigcall tomain.pybefore any sub-module imports execute. No correctness, security, or convention issues found. Ready to merge.Automated review by Claude PR Reviewer
867e8ce888to053fcbab05