Medica_DecisionSupportAI / audit_log.py
Rajan Sharma
Update audit_log.py
ac62f48 verified
raw
history blame
418 Bytes
import os, json, time
def log_event(kind: str, user_id: str | None, payload: dict):
rec = {"ts": time.time(), "kind": kind, "user": user_id, "payload": payload}
os.makedirs("./logs", exist_ok=True)
with open("./logs/events.log", "a", encoding="utf-8") as f:
f.write(json.dumps(rec, ensure_ascii=False) + "\n")
def hash_summary(label: str, text: str):
return {f"{label}_len": len(text or "")}