townlet / game /log.py
Budlee's picture
Timestamped logs via game.log.tlog; explains visible drain pauses
e80adab verified
Raw
History Blame Contribute Delete
587 Bytes
"""Single-line stdout helper with an [HH:MM:SS] prefix.
Used in place of `print(..., flush=True)` for our `[townlet]`-tagged logs so
the Spaces log viewer (which does not prepend timestamps) shows wall-clock
between events. Crucial for diagnosing where time is going during long
drains — most of the visible "pauses" between log lines are LLM inference,
and the timestamps make that obvious at a glance.
"""
from __future__ import annotations
import sys
import time
def tlog(msg: str) -> None:
sys.stdout.write(f"[{time.strftime('%H:%M:%S')}] {msg}\n")
sys.stdout.flush()