#[cfg(feature = "logging")]
use log::{debug, error, info, warn};
#[cfg(feature = "logging")]
pub fn log_command(program: &str, args: &[std::ffi::OsString]) {
let args_str: Vec<String> = args
.iter()
.map(|s| s.to_string_lossy().to_string())
.collect();
debug!("Executing command: {} {:?}", program, args_str);
}
#[cfg(feature = "logging")]
pub fn log_success(program: &str, exit_code: Option<i32>) {
info!(
"Command '{}' completed with exit code: {:?}",
program, exit_code
);
}
#[cfg(feature = "logging")]
pub fn log_failure(program: &str, exit_code: Option<i32>, stderr: &str) {
error!(
"Command '{}' failed with exit code: {:?}, stderr: {}",
program, exit_code, stderr
);
}
#[cfg(feature = "logging")]
pub fn log_timeout(program: &str, duration: std::time::Duration) {
warn!("Command '{}' timed out after {:?}", program, duration);
}
#[cfg(feature = "logging")]
pub fn log_env_set(key: &str, value: &str) {
debug!("Setting environment variable: {}={}", key, value);
}
#[cfg(feature = "logging")]
pub fn log_cwd(path: &std::path::Path) {
debug!("Changing working directory to: {:?}", path);
}
#[cfg(not(feature = "logging"))]
#[allow(missing_docs)]
pub fn log_command(_program: &str, _args: &[std::ffi::OsString]) {}
#[cfg(not(feature = "logging"))]
#[allow(missing_docs)]
pub fn log_success(_program: &str, _exit_code: Option<i32>) {}
#[cfg(not(feature = "logging"))]
#[allow(missing_docs)]
pub fn log_failure(_program: &str, _exit_code: Option<i32>, _stderr: &str) {}
#[cfg(not(feature = "logging"))]
#[allow(missing_docs)]
pub fn log_timeout(_program: &str, _duration: std::time::Duration) {}
#[cfg(not(feature = "logging"))]
#[allow(missing_docs)]
pub fn log_env_set(_key: &str, _value: &str) {}
#[cfg(not(feature = "logging"))]
#[allow(missing_docs)]
pub fn log_cwd(_path: &std::path::Path) {}