File size: 609 Bytes
c8f68bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# telemetry.py
import json
import os
from datetime import datetime

LOG_FILE = "telemetry_log.jsonl"

def log_event(agent_id, action, status, metadata=None):
    """Logs each agent event with timestamp and context."""
    event = {
        "timestamp": datetime.utcnow().isoformat(),
        "agent_id": agent_id,
        "action": action,
        "status": status,
        "metadata": metadata or {}
    }

    # Write to local JSONL file (can be replaced with Supabase later)
    with open(LOG_FILE, "a") as f:
        f.write(json.dumps(event) + "\n")

    print(f"[Telemetry] Logged: {action} - {status}")