Log TTS errors on create

Record exception details during TTS generation to help diagnose 500 errors.
This commit is contained in:
dsyoon
2026-01-30 15:55:27 +09:00
parent 1abe725480
commit 39387a0544

View File

@@ -1,6 +1,8 @@
from pathlib import Path from pathlib import Path
from typing import List from typing import List
import logging
from dotenv import load_dotenv from dotenv import load_dotenv
from fastapi import FastAPI, HTTPException, Request from fastapi import FastAPI, HTTPException, Request
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
@@ -29,6 +31,7 @@ RESOURCES_DIR = ROOT_DIR / "resources"
load_dotenv(dotenv_path=ROOT_DIR / ".env") load_dotenv(dotenv_path=ROOT_DIR / ".env")
app = FastAPI() app = FastAPI()
logger = logging.getLogger("tts")
app.add_middleware( app.add_middleware(
CORSMiddleware, CORSMiddleware,
@@ -103,6 +106,7 @@ def api_create_tts(payload: TtsCreateRequest):
try: try:
text_to_mp3(text=text, mp3_path=str(mp3_path)) text_to_mp3(text=text, mp3_path=str(mp3_path))
except Exception as exc: except Exception as exc:
logger.exception("TTS 생성 실패")
delete_item_by_id(tts_id) delete_item_by_id(tts_id)
raise HTTPException(status_code=500, detail=str(exc)) from exc raise HTTPException(status_code=500, detail=str(exc)) from exc