From 41d47b8dd72eb351b3ca5a3d9ce3e2a8502c0d8f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 18 Sep 2024 11:04:44 -0400 Subject: [PATCH] utils: Add a `log_debug()` helper ref https://github.com/containers/bootc/discussions/793 --- lib/src/blockdev.rs | 1 + utils/src/command.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/src/blockdev.rs b/lib/src/blockdev.rs index 8631902f..cd9c58b1 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 3a360caa..7e57eab7 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; @@ -71,6 +72,11 @@ impl CommandRunExt for Command { self.status()?.check_status(stderr) } + fn log_debug(&mut self) -> &mut Self { + tracing::debug!("exec: {self:?}"); + self + } + fn run_and_parse_json(&mut self) -> Result { let mut stdout = tempfile::tempfile()?; self.stdout(stdout.try_clone()?);