feat(cli): add structured JSONL session logging for AI output
This commit is contained in:
22
tests/test_session_log.py
Normal file
22
tests/test_session_log.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Tests for structured session logging."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from tai.session_log import SessionLogger
|
||||
|
||||
|
||||
def test_session_logger_writes_jsonl_row(tmp_path) -> None: # type: ignore[no-untyped-def]
|
||||
log_path = tmp_path / "logs" / "session.jsonl"
|
||||
logger = SessionLogger.create(str(log_path))
|
||||
|
||||
logger.log_event("analysis_response", {"response": "Root cause is X"})
|
||||
|
||||
lines = log_path.read_text(encoding="utf-8").splitlines()
|
||||
assert len(lines) == 1
|
||||
|
||||
row = json.loads(lines[0])
|
||||
assert row["event"] == "analysis_response"
|
||||
assert row["payload"]["response"] == "Root cause is X"
|
||||
assert "ts" in row
|
||||
Reference in New Issue
Block a user