diff --git a/lib/src/blockdev.rs b/lib/src/blockdev.rs index 8631902fb..cd9c58b1f 100644 --- a/lib/src/blockdev.rs +++ b/lib/src/blockdev.rs @@ -98,6 +98,7 @@ pub(crate) fn list_dev(dev: &Utf8Path) -> Result { let mut devs: DevicesOutput = Command::new("lsblk") .args(["-J", "-b", "-O"]) .arg(dev) + .log_debug() .run_and_parse_json()?; for dev in devs.blockdevices.iter_mut() { dev.backfill_missing()?; diff --git a/utils/src/command.rs b/utils/src/command.rs index 3a360caae..8b80be95e 100644 --- a/utils/src/command.rs +++ b/utils/src/command.rs @@ -7,6 +7,7 @@ use anyhow::{Context, Result}; /// Helpers intended for [`std::process::Command`]. pub trait CommandRunExt { + fn log_debug(&mut self) -> &mut Self; fn run(&mut self) -> Result<()>; /// Execute the child process, parsing its stdout as JSON. fn run_and_parse_json(&mut self) -> Result; @@ -68,9 +69,17 @@ impl CommandRunExt for Command { fn run(&mut self) -> Result<()> { let stderr = tempfile::tempfile()?; self.stderr(stderr.try_clone()?); + tracing::trace!("exec: {self:?}"); self.status()?.check_status(stderr) } + /// Output a debug-level log message with this command. + fn log_debug(&mut self) -> &mut Self { + tracing::debug!("exec: {self:?}"); + self + } + + /// Synchronously execute the child, and parse its stdout as JSON. fn run_and_parse_json(&mut self) -> Result { let mut stdout = tempfile::tempfile()?; self.stdout(stdout.try_clone()?);