add logger

This commit is contained in:
Dohyun Lim committed 2026-01-14 17:46:45 +09:00
1 parent 1acd8846ab
commit bf7b53c8e8
41 files changed
+1832 -694

No files matched your search

+9 -5
View File
@@ -4,12 +4,16 @@ from contextlib import asynccontextmanager
from fastapi import FastAPI
from app.utils.logger import get_logger
logger = get_logger("core")
@asynccontextmanager
async def lifespan(app: FastAPI):
"""FastAPI 애플리케이션 생명주기 관리"""
# Startup - 애플리케이션 시작 시
print("Starting up...")
logger.info("Starting up...")
try:
from config import prj_settings
@@ -19,20 +23,20 @@ async def lifespan(app: FastAPI):
from app.database.session import create_db_tables
await create_db_tables()
print("Database tables created (DEBUG mode)")
logger.info("Database tables created (DEBUG mode)")
except asyncio.TimeoutError:
print("Database initialization timed out")
logger.error("Database initialization timed out")
# 타임아웃 시 앱 시작 중단하려면 raise, 계속하려면 pass
raise
except Exception as e:
print(f"Database initialization failed: {e}")
logger.error(f"Database initialization failed: {e}")
# 에러 시 앱 시작 중단하려면 raise, 계속하려면 pass
raise
yield # 애플리케이션 실행 중
# Shutdown - 애플리케이션 종료 시
print("Shutting down...")
logger.info("Shutting down...")
# 공유 HTTP 클라이언트 종료
from app.utils.creatomate import close_shared_client