feat(logging): improve local and docker log handling

This commit is contained in:
yml2213
2026-08-28 16:49:00 +08:00
parent 70621cff8f
commit 5ba70d5b4e
8 changed files with 348 additions and 47 deletions
+2 -2
View File
@@ -20,9 +20,9 @@ from utils import setup_logger
@asynccontextmanager
async def lifespan(app: FastAPI):
# 初始化日志(控制台 + 按天命名文件)
# 本地 dev.sh 和 Docker 均显式设置 LOG_DIR;直接运行时回退到项目 logs/。
_log_level = os.getenv("LOG_LEVEL", "INFO")
_log_dir = Path(__file__).resolve().parents[2] / "logs"
_log_dir = Path(os.getenv("LOG_DIR", str(Path(__file__).resolve().parents[2] / "logs")))
setup_logger(level=_log_level, log_dir=str(_log_dir))
init_db()