Skip to content

Commit

Permalink
Support emitting debug logs in rules_rust process wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Sep 6, 2024
1 parent 3d1856b commit 1bdd249
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions util/process_wrapper/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,19 @@ impl fmt::Display for ProcessWrapperError {

impl std::error::Error for ProcessWrapperError {}

macro_rules! log {
($($arg:tt)*) => {
if std::env::var("RULES_RUST_PROCESS_WRAPPER_DEBUG").is_ok() {
eprintln!($($arg)*);
}
};
}

fn main() -> Result<(), ProcessWrapperError> {
let opts = options().map_err(|e| ProcessWrapperError(e.to_string()))?;

let mut child = Command::new(opts.executable)
let mut command = Command::new(opts.executable);
command
.args(opts.child_arguments)
.env_clear()
.envs(opts.child_environment)
Expand All @@ -79,7 +88,9 @@ fn main() -> Result<(), ProcessWrapperError> {
} else {
Stdio::inherit()
})
.stderr(Stdio::piped())
.stderr(Stdio::piped());
log!("{:#?}", command);
let mut child = command
.spawn()
.map_err(|e| ProcessWrapperError(format!("failed to spawn child process: {}", e)))?;

Expand Down

0 comments on commit 1bdd249

Please sign in to comment.