Open every line loop-claude prints with the machine's local time

This commit is contained in:
2026-10-28 18:30:24 +01:00
parent 9014fd0a2c
commit 43e7e96b41
13 changed files with 123 additions and 58 deletions
+13
View File
@@ -0,0 +1,13 @@
import sys
import time
from loop_claude.effects import Effects
# The spelling `YYYY-MM-DD HH:MM:SS` in local time, never UTC, is lilleman's call of 2026-10-28.
def say(text: str, effects: Effects, *, stdout: bool = False) -> None:
"""Prints text on stderr, or on stdout where stdout, opening its first line with the machine's local time as `2026-10-28 11:46:01`, so the human sees when it happened. Blank lines before the text stay blank, and only its first line gets the time."""
body = text.lstrip("\n")
blanks = text[: len(text) - len(body)]
stamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(effects.now()))
print(f"{blanks}{stamp} {body}", file=sys.stdout if stdout else sys.stderr, flush=True)