Add file logging to agent — writes to /workspace/agent.log

This commit is contained in:
2026-04-07 21:01:39 +00:00
parent 9f624e9497
commit 185cda575e

View File

@@ -217,8 +217,18 @@ def execute_skill(script_path, args):
TOOLS, SKILL_SCRIPTS = discover_skills()
LOG_FILE = f"{WORKSPACE}/agent.log" if os.path.isdir(WORKSPACE) else None
def log(msg):
print(f"[agent:{NICK}] {msg}", flush=True)
line = f"[{time.strftime('%H:%M:%S')}] {msg}"
print(f"[agent:{NICK}] {line}", flush=True)
if LOG_FILE:
try:
with open(LOG_FILE, "a") as f:
f.write(line + "\n")
except Exception:
pass
log(f"Loaded {len(TOOLS)} skills: {', '.join(SKILL_SCRIPTS.keys())}")