feat: 引入 Loguru
This commit is contained in:
@@ -6,16 +6,15 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
from asyncio import CancelledError
|
||||
from collections.abc import Iterator
|
||||
from contextlib import contextmanager
|
||||
from typing import Any
|
||||
|
||||
from app.config import settings
|
||||
from loguru import logger
|
||||
|
||||
logger = logging.getLogger("app.observability")
|
||||
from app.config import settings
|
||||
|
||||
# 面板 Trace Name 列用的稳定名字,不要拼 thread_id 或用户原文
|
||||
TRACE_NAME = "screen-instruct"
|
||||
@@ -52,8 +51,8 @@ def flush_tracing() -> None:
|
||||
return
|
||||
try:
|
||||
client.flush()
|
||||
except Exception:
|
||||
logger.warning("Langfuse flush 失败", exc_info=True)
|
||||
except Exception as exc: # noqa: BLE001 追踪故障不阻断业务
|
||||
logger.opt(exception=exc).warning("Langfuse flush 失败")
|
||||
|
||||
|
||||
async def ainvoke_screen(
|
||||
@@ -232,9 +231,9 @@ def _ensure_client() -> Any:
|
||||
|
||||
try:
|
||||
client = Langfuse()
|
||||
except Exception:
|
||||
except Exception as exc: # noqa: BLE001 追踪故障不阻断业务
|
||||
_unavailable = True
|
||||
logger.warning("Langfuse 不可用,本进程跳过追踪", exc_info=True)
|
||||
logger.opt(exception=exc).warning("Langfuse 不可用,本进程跳过追踪")
|
||||
return None
|
||||
_client = client
|
||||
return client
|
||||
|
||||
Reference in New Issue
Block a user