-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_utils.py
More file actions
35 lines (30 loc) · 939 Bytes
/
log_utils.py
File metadata and controls
35 lines (30 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Lightweight structured logging utility."""
import json
from datetime import datetime, timezone
from typing import Any, Optional
def log_event(stage: str, task_id: str, message: str) -> None:
"""Print a single structured JSON log line."""
payload = {
"stage": stage,
"task_id": task_id,
"message": message,
"timestamp": datetime.now(timezone.utc).isoformat(),
}
print(json.dumps(payload))
def log_step(
agent_name: str,
message: str,
optional_data: Optional[dict[str, Any]] = None,
) -> None:
"""
Print a readable step log for multi-agent demo.
Format:
[Agent Name]
Message
Result: key=value, ... (if optional_data provided)
"""
print(f"\n[{agent_name}]")
print(message)
if optional_data is not None and optional_data:
parts = ", ".join(f"{k}={v}" for k, v in optional_data.items())
print(f"Result: {parts}")