feat: 添加预约回退功能完整测试脚本和错误场景测试脚本

This commit is contained in:
Your Name committed 2026-01-08 00:15:00 +08:00
1 parent 93d47a16d6
commit 5738d29bd6
16 files changed
+1228 -64

No files matched your search

+29 -7
View File
@@ -1616,15 +1616,27 @@ class Handler(BaseHTTPRequestHandler):
# 取最近 tail_n 条作为候选,然后按关键词过滤(不区分大小写)
with RUNNER._lock:
total = len(RUNNER._log)
cand = RUNNER._log[-tail_n:] if tail_n > 0 else RUNNER._log[:]
cand = (
RUNNER._log[-tail_n:] if tail_n > 0 else RUNNER._log[:]
)
qlow = q.lower()
filtered = [l for l in cand if qlow in (l or "").lower()]
return self._send_json({"next": total, "lines": filtered, "running": RUNNER.is_running()})
return self._send_json(
{
"next": total,
"lines": filtered,
"running": RUNNER.is_running(),
}
)
except Exception as e:
import traceback
print(f"[WEB_GUI] logs search error: {e}\n{traceback.format_exc()}")
return self._send_json({"next": 0, "lines": [], "running": RUNNER.is_running()})
print(
f"[WEB_GUI] logs search error: {e}\n{traceback.format_exc()}"
)
return self._send_json(
{"next": 0, "lines": [], "running": RUNNER.is_running()}
)
# 默认行为:按 since 增量返回日志(原有逻辑)
since = 0
@@ -1634,13 +1646,23 @@ class Handler(BaseHTTPRequestHandler):
since = 0
try:
next_idx, lines = RUNNER.get_logs_since(since)
return self._send_json({"next": next_idx, "lines": lines, "running": RUNNER.is_running()})
return self._send_json(
{
"next": next_idx,
"lines": lines,
"running": RUNNER.is_running(),
}
)
except Exception as e:
# 记录错误但不中断请求,返回空日志
import traceback
print(f"[WEB_GUI] get_logs_since error: {e}\n{traceback.format_exc()}")
return self._send_json({"next": 0, "lines": [], "running": RUNNER.is_running()})
print(
f"[WEB_GUI] get_logs_since error: {e}\n{traceback.format_exc()}"
)
return self._send_json(
{"next": 0, "lines": [], "running": RUNNER.is_running()}
)
if u.path == "/api/logfile-tail":
# 返回统一日志文件的尾部若干行,便于在内存日志不同步时调试
qs = parse_qs(u.query)