增加接口日志输出

This commit is contained in:
mark.tian
2025-12-02 19:57:54 +08:00
parent 6cb2b9225f
commit addd75fbf9
10 changed files with 1029 additions and 21 deletions

View File

@@ -3,6 +3,9 @@ from sqlalchemy.orm import DeclarativeBase
from sqlalchemy import Column, String, Integer, DateTime, Text, JSON
from datetime import datetime
from app.config import settings
from app.logger import get_logger
logger = get_logger("database")
class Base(DeclarativeBase):
@@ -60,5 +63,11 @@ async def get_db():
async def init_db():
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
logger.info("📊 初始化数据库表结构...")
try:
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
logger.info("✅ 数据库表结构初始化完成")
except Exception as e:
logger.error(f"❌ 数据库初始化失败: {e}")
raise