Skip to content

Migrate Logs V1

tools.migrate_logs_v1

migrate_logs_v1.py — rename pre-v2 xil logs to the versioned convention.

Lives in tools/; run from anywhere: python3 tools/migrate_logs_v1.py [-n]

Before v2, logs/xil_YYYY-MM-DD.log held a bare copy of the terminal transcript (no timestamp, level or stage per line). v2 writes a structured logs/xil_v2_YYYY-MM-DD.log instead, so the old files are renamed to xil_v1_YYYY-MM-DD.log and the format is unambiguous from the filename — no sniffing, and xil-stem-log / xil_effort can parse both.

Only files matching xil_YYYY-MM-DD.log exactly are touched. Anything else in logs/ (already-versioned files, unrelated *.log files) is left alone. Safe to re-run: already-renamed files are reported as skipped.

Files currently held open by another process are skipped. Renaming a log that a running xil command or xil-gui still has open leaves the writer appending to the old inode, and on a network mount (9p/NFS/SMB) it can leave the new name unresolvable until that process exits. Today's log is normally the only one at risk; stop the writer (or wait for it to finish) and re-run.

Log directory: $XIL_PROJECTROOT/logs, falling back to ./logs.

V1_NAME module-attribute

V1_NAME = re.compile('^xil_(\\d{4}-\\d{2}-\\d{2})\\.log$')

ap module-attribute

ap = argparse.ArgumentParser(description='Rename pre-v2 xil_<date>.log files to xil_v1_<date>.log.')

args module-attribute

args = ap.parse_args()

logs_dir module-attribute

logs_dir = Path(args.logs_dir)

root module-attribute

root = os.environ.get('XIL_PROJECTROOT')

m module-attribute

m = V1_NAME.match(path.name)

target module-attribute

target = path.with_name(f'xil_v1_{m.group(1)}.log')

holder module-attribute

holder = _open_by(path)