File size: 554 Bytes
9459cd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
Per-job structured logging so an Agent can debug a failed render by reading
logs/{job_id}.log. Every pipeline stage writes through job_log().
"""
import datetime
import os

LOG_DIR = "logs"


def job_log(job_id: str, message: str, stage: str = ""):
    os.makedirs(LOG_DIR, exist_ok=True)
    ts = datetime.datetime.utcnow().isoformat()
    prefix = f"[{stage}] " if stage else ""
    line = f"{ts} {prefix}{message}\n"
    with open(os.path.join(LOG_DIR, f"{job_id}.log"), "a") as f:
        f.write(line)
    print(f"[{job_id}] {prefix}{message}")