release: bump version to 0.67.0
This commit is contained in:
@@ -40,10 +40,10 @@ def test_read_log_snapshot_uses_structured_buffer_timestamp_level_and_search(mon
|
||||
{
|
||||
"earth-client": system_logs.LogSource(
|
||||
source_id="earth-client",
|
||||
name="Earth 浏览器端",
|
||||
name="智能星球浏览器端",
|
||||
kind="buffer",
|
||||
location="redis://planet:system_logs:earth-client",
|
||||
description="Earth 浏览器端上报日志",
|
||||
description="智能星球浏览器端上报日志",
|
||||
category="client",
|
||||
buffer_key=system_logs.get_buffer_log_key("earth-client"),
|
||||
)
|
||||
@@ -156,6 +156,52 @@ def test_append_buffer_log_persists_normalized_level(monkeypatch):
|
||||
assert payload["message"] == "feed delayed"
|
||||
|
||||
|
||||
def test_list_log_sources_includes_admin_client(monkeypatch):
|
||||
fake_redis = FakeRedis()
|
||||
monkeypatch.setattr(system_logs, "redis_client", fake_redis)
|
||||
|
||||
sources = system_logs.list_log_sources()
|
||||
|
||||
admin_source = next(item for item in sources if item["source_id"] == "admin-client")
|
||||
assert admin_source["kind"] == "buffer"
|
||||
assert admin_source["category"] == "client"
|
||||
|
||||
|
||||
def test_read_log_events_returns_stable_cursors(tmp_path: Path, monkeypatch):
|
||||
log_path = tmp_path / "backend.log"
|
||||
log_path.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"2026-04-22 08:00:00 INFO service booted",
|
||||
"2026-04-22 08:01:00 ERROR service failed",
|
||||
]
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
system_logs,
|
||||
"LOG_SOURCES",
|
||||
{
|
||||
"backend": system_logs.LogSource(
|
||||
source_id="backend",
|
||||
name="后端服务",
|
||||
kind="file",
|
||||
location=str(log_path),
|
||||
description="测试文件日志",
|
||||
category="service",
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
events = system_logs.read_log_events("backend", 50, level="error")
|
||||
|
||||
assert events is not None
|
||||
assert len(events) == 1
|
||||
assert events[0].source_id == "backend"
|
||||
assert events[0].cursor.startswith("backend:")
|
||||
assert events[0].line.endswith("ERROR service failed")
|
||||
|
||||
|
||||
def test_infer_log_level_prefers_leading_prefix_over_query_string():
|
||||
line = 'INFO: 127.0.0.1 - "GET /api/v1/system/logs/backend?limit=200&level=error&levels=error HTTP/1.1" 200 OK'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user