Rajan Sharma commited on
Commit
9f77a66
·
verified ·
1 Parent(s): 3c323be

Update audit_log.py

Browse files
Files changed (1) hide show
  1. audit_log.py +2 -25
audit_log.py CHANGED
@@ -1,25 +1,2 @@
1
- import json, time, hashlib
2
- from typing import Any
3
-
4
- def _hash(s: str) -> str:
5
- return hashlib.sha256(s.encode("utf-8", errors="ignore")).hexdigest()
6
-
7
- def log_event(event_type: str, user_id: str | None, meta: dict[str, Any]):
8
- # Do NOT store content. Use hashes and sizes only.
9
- rec = {
10
- "ts": time.strftime("%Y-%m-%dT%H:%M:%S%z"),
11
- "event": event_type,
12
- "user": user_id or "unknown",
13
- "meta": meta,
14
- }
15
- try:
16
- with open("audit.jsonl", "a", encoding="utf-8") as f:
17
- f.write(json.dumps(rec) + "\n")
18
- except Exception:
19
- pass
20
-
21
- def hash_summary(label: str, text: str) -> dict:
22
- return {
23
- f"{label}_sha256": _hash(text),
24
- f"{label}_chars": len(text or ""),
25
- }
 
1
+ def log_event(event, user, details):
2
+ print(f"[LOG] {event}: {details}")