Skip to content

Support emitting debug logs in rules_rust process wrapper. #2845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading