From: Daan De Meyer Date: Tue, 20 Jan 2026 07:48:15 +0000 (+0100) Subject: run: Improve sandbox command logging X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50a1feee523ee308a6c23fe1d644deb2ff116ac8;p=thirdparty%2Fmkosi.git run: Improve sandbox command logging Replaces #4068 --- diff --git a/mkosi/run.py b/mkosi/run.py index 984fa2bc1..26598b724 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -111,10 +111,11 @@ def log_process_failure(sandbox: Sequence[str], cmdline: Sequence[str], returnco if -returncode in (signal.SIGINT, signal.SIGTERM): logging.error(f"Interrupted by {signal.Signals(-returncode).name} signal") elif returncode < 0: - logging.error( - f'"{shlex.join(["mkosi-sandbox", *sandbox, *cmdline] if ARG_DEBUG.get() else cmdline)}"' - f" was killed by {signal.Signals(-returncode).name} signal." - ) + logging.error(f'"{shlex.join(cmdline)}" was killed by {signal.Signals(-returncode).name} signal.') + if ARG_DEBUG.get(): + logging.info(f"Sandbox command: {shlex.join(['mkosi-sandbox', *sandbox])}") + else: + logging.info("(sandbox command omitted, rerun with --debug to see the full sandbox command.)") elif returncode == 127 and cmdline[0] != "mkosi": # Anything invoked beneath /work is a script that we mount into place (so we know it exists). If one # of these scripts fails with exit code 127, it's either because the script interpreter was not @@ -127,10 +128,11 @@ def log_process_failure(sandbox: Sequence[str], cmdline: Sequence[str], returnco else: logging.error(f"{cmdline[0]} not found.") else: - logging.error( - f'"{shlex.join(["mkosi-sandbox", *sandbox, *cmdline] if ARG_DEBUG.get() else cmdline)}"' - f" returned non-zero exit code {returncode}." - ) + logging.error(f'"{shlex.join(cmdline)}" returned non-zero exit code {returncode}.') + if ARG_DEBUG.get(): + logging.info(f"Sandbox command: {shlex.join(['mkosi-sandbox', *sandbox])}") + else: + logging.info("(sandbox command omitted, rerun with --debug to see the full sandbox command.)") class SandboxProtocol(Protocol):