linvest21's picture
download
raw
657 Bytes
from __future__ import annotations
import json
from datetime import datetime, timezone
from pathlib import Path
from typing import Any
def utc_now() -> str:
return datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")
class AuditLogger:
def __init__(self, path: Path):
self.path = path
self.path.parent.mkdir(parents=True, exist_ok=True)
def emit(self, event: dict[str, Any]) -> None:
event = dict(event)
event.setdefault("timestamp", utc_now())
with self.path.open("a", encoding="utf-8") as handle:
handle.write(json.dumps(event, sort_keys=True) + "\n")

Xet Storage Details

Size:
657 Bytes
·
Xet hash:
af8c77758235e06a8d1c9fc8b7ab045682a7c4ca25c7c805fb55f9a78f41450b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.