Write stdout/stderr from a failed CLI invocation to a log file.
(output_dir: Path, job_name: str, result: subprocess.CompletedProcess)
| 254 | |
| 255 | |
| 256 | def _save_cli_log(output_dir: Path, job_name: str, result: subprocess.CompletedProcess): |
| 257 | """Write stdout/stderr from a failed CLI invocation to a log file.""" |
| 258 | log_path = output_dir / f"{job_name}_cli.log" |
| 259 | parts = [ |
| 260 | f"exit code: {result.returncode}", |
| 261 | f"\n--- stdout ---\n{result.stdout}" if result.stdout else "", |
| 262 | f"\n--- stderr ---\n{result.stderr}" if result.stderr else "", |
| 263 | ] |
| 264 | log_path.write_text("\n".join(parts)) |
| 265 | print(f"Saved CLI log to {log_path}") |
| 266 | |
| 267 | |
| 268 | # --------------------------------------------------------------------------- |