packager/pkgr/src/process/output.rs
Didier f050daf035
All checks were successful
/ check (push) Successful in 38s
format: fix formatting
2023-07-17 21:23:59 +02:00

26 lines
814 B
Rust

// create functions that spawn threads for Stdout and Stderr
// that print the output to info!(target: "command:stdout", ...) and info!(target: "command:stderr", ...) respectively
use std::io::{BufRead, BufReader};
use std::process::Child;
use log::{error, info};
pub fn spawn_output_handlers(child: &mut Child) {
let stdout = child.stdout.take().unwrap();
let stderr = child.stderr.take().unwrap();
std::thread::spawn(move || {
let reader = BufReader::new(stdout);
for line in reader.lines() {
info!(target: "command:stdout", "{}", line.unwrap());
}
});
std::thread::spawn(move || {
let reader = BufReader::new(stderr);
for line in reader.lines() {
error!(target: "command:stderr", "{}", line.unwrap());
}
});
}