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()