feat(calllog): 调用日志落地(SQLite / 90 天 / 管理员可查全部)
- app/calllog.py:SQLite 表 api_calls(21 列,含提示词与回复)+ 异步批量写 + 双向握手
(流式请求的访问日志条目比响应晚到也能落库)+ 早失败补记 + 失败也记 Key 前 8 位
- 新增 4 个仅管理员端点:/logs/calls、/logs/calls/stats、/logs/calls/{id}、/logs/calls/export
- 前端:日志页新增「实时 / 调用日志」页签,新组件 CallLogs.vue(筛选/分页/详情/CSV 导出)
- 保留 90 天;队列满丢弃计数,不反压请求;零新依赖
- docs:新增 docs/call-log-design.md(方案对比与三个关键设计)
- 版本 2.7.3 → 2.8.0
This commit is contained in:
1 parent
19224f1993
commit
2c53504ad4
10 files changed
+1101
-4
No files matched your search
@@ -25,6 +25,7 @@ ROLE: ContextVar[str] = ContextVar("gw_role", default="member")
|
||||
# 附上「具体请求内容」,便于在日志页查看实际发了什么。有界缓存,防无界增长。
|
||||
BODY_BY_RID: dict[str, str] = {}
|
||||
|
||||
|
||||
# ── 视频轮询历史(/logs 按 video_id 合成到「创建」那一条里,不再每个轮询各占一行) ──
|
||||
VIDEO_POLLS: dict[str, "deque"] = {}
|
||||
_vp_lock = threading.Lock()
|
||||
@@ -272,6 +273,13 @@ class AccessLog:
|
||||
entry["body"] = snip
|
||||
with self._lock:
|
||||
self._buf.append(entry)
|
||||
# 调用日志落地(2026-10-23):交给 app/calllog.py —— 它与请求中间件的响应元数据
|
||||
# 做双向握手(谁后到谁拼行),流式请求的条目比响应晚到也能落到库里。
|
||||
try:
|
||||
from app import calllog
|
||||
calllog.on_access(entry)
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
|
||||
def tail(self, n: int = 100) -> list[dict[str, Any]]:
|
||||
with self._lock:
|
||||
|
||||
Reference in new issue
Block a user