Spaces:
Sleeping
Sleeping
Update audit_log.py
Browse files- audit_log.py +10 -2
audit_log.py
CHANGED
|
@@ -1,2 +1,10 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, json, time
|
| 2 |
+
|
| 3 |
+
def log_event(kind: str, user_id: str | None, payload: dict):
|
| 4 |
+
rec = {"ts": time.time(), "kind": kind, "user": user_id, "payload": payload}
|
| 5 |
+
os.makedirs("./logs", exist_ok=True)
|
| 6 |
+
with open("./logs/events.log", "a", encoding="utf-8") as f:
|
| 7 |
+
f.write(json.dumps(rec, ensure_ascii=False) + "\n")
|
| 8 |
+
|
| 9 |
+
def hash_summary(label: str, text: str):
|
| 10 |
+
return {f"{label}_len": len(text or "")}
|