15 lines
404 B
Python
15 lines
404 B
Python
from __future__ import annotations
|
|
import json
|
|
import time
|
|
from pathlib import Path
|
|
|
|
AUDIT_FILE = Path('/srv/prime-core/logs/audit.jsonl')
|
|
|
|
|
|
def log_event(event: dict) -> None:
|
|
AUDIT_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
event = dict(event)
|
|
event.setdefault('ts', int(time.time()))
|
|
with AUDIT_FILE.open('a') as f:
|
|
f.write(json.dumps(event, separators=(',', ':')) + '\n')
|