Spaces:
Running
Running
| """ํด ๋ก๊ทธ ์ ์ฅ โ ์ฐ๊ตฌ ๋ฐ์ดํฐ ๊ฒธ์ฉ, ์ญ์ ๊ธ์ง (CLAUDE.md). | |
| MVP: ๋ก์ปฌ jsonl ๋ฐฑ์๋. ์คํค๋ง๋ 2๋จ๊ณ ๊ทธ๋ํํ๋ฅผ ์ผ๋์ ๋ ํ๋ฉด ๋ ์ฝ๋. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| import time | |
| from pathlib import Path | |
| class PlaylogRepository: | |
| def __init__(self, path: str | Path = "logs/playlog.jsonl"): | |
| self.path = Path(path) | |
| self.path.parent.mkdir(parents=True, exist_ok=True) | |
| def append(self, record: dict) -> None: | |
| record = {"ts": round(time.time(), 3), **record} | |
| with self.path.open("a", encoding="utf-8") as f: | |
| f.write(json.dumps(record, ensure_ascii=False) + "\n") | |