Spaces:
Sleeping
Sleeping
File size: 498 Bytes
fbb917f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import logging
from pathlib import Path
_swap_log_dir = Path("logs")
_swap_log_dir.mkdir(exist_ok=True)
class _SwapLog:
"""Simple file writer that flushes every line."""
def debug(self, msg, statement_id=None):
if statement_id:
path = _swap_log_dir / f"auto_swap_{statement_id}.log"
else:
path = _swap_log_dir / "auto_swap_general.log"
with open(path, "a", encoding="utf-8") as f:
f.write(msg + "\n")
_swap_logger = _SwapLog()
|