feat(P3): 5개 서비스 비즈니스 이벤트 logger.info 보강
This commit is contained in:
@@ -256,6 +256,7 @@ def order_stock(req: OrderRequest):
|
||||
if resp.status_code != 200:
|
||||
logger.error(f"Order Error: {resp.status_code}")
|
||||
return JSONResponse(status_code=resp.status_code, content=resp.json())
|
||||
logger.info(f"Order Response: {req.action} {req.ticker} x{req.quantity} → OK")
|
||||
return resp.json()
|
||||
except ValueError:
|
||||
status = resp.status_code if resp is not None else 502
|
||||
@@ -279,6 +280,7 @@ def ai_coach(req: AiCoachRequest):
|
||||
|
||||
allowed_models = {"claude-haiku-4-5-20251001", "claude-sonnet-4-6"}
|
||||
model = req.model if req.model in allowed_models else "claude-haiku-4-5-20251001"
|
||||
logger.info(f"AI Coach 호출: model={model}, prompt_len={len(req.prompt)}")
|
||||
|
||||
try:
|
||||
resp = requests.post(
|
||||
@@ -298,7 +300,10 @@ def ai_coach(req: AiCoachRequest):
|
||||
if resp.status_code != 200:
|
||||
logger.error(f"Anthropic API error: {resp.status_code}")
|
||||
return JSONResponse(status_code=resp.status_code, content={"error": "AI API error"})
|
||||
return resp.json()
|
||||
data = resp.json()
|
||||
usage = data.get("usage", {})
|
||||
logger.info(f"AI Coach 응답 완료: model={model}, input={usage.get('input_tokens', '?')}, output={usage.get('output_tokens', '?')}")
|
||||
return data
|
||||
except requests.Timeout:
|
||||
return JSONResponse(status_code=504, content={"error": "AI API timeout"})
|
||||
except Exception as e:
|
||||
|
||||
@@ -4,12 +4,15 @@ from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sqlite3
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from . import schemas
|
||||
from .registry import NODE_REGISTRY, GATE_REGISTRY
|
||||
from .. import webai_cache
|
||||
@@ -246,6 +249,7 @@ def post_run(body: schemas.RunRequest):
|
||||
telegram_payload=schemas.TelegramPayload(**payload),
|
||||
warnings=result.warnings,
|
||||
)
|
||||
logger.info(f"Screener 완료: mode={body.mode}, asof={asof.isoformat()}, survivors={result.survivors_count}, top_n={top_n}")
|
||||
# SP-A2 — preview 모드 결과 캐시 저장.
|
||||
if body.mode == "preview":
|
||||
webai_cache.cache_set_screener(body.mode, body.top_n, body.weights, response)
|
||||
|
||||
Reference in New Issue
Block a user