in smt2proxy/src/main.rs [106:128]
fn spawn_child_stream_logger<R>(
logger: Option<Arc<Mutex<std::fs::File>>>,
input: R,
repeat: bool,
error_msg: &'static str,
) -> std::thread::JoinHandle<()>
where
R: std::io::Read + Send + 'static,
{
let input = std::io::BufReader::new(input);
std::thread::spawn(move || {
for line in input.lines() {
let line = line.expect(error_msg);
if let Some(logger) = &logger {
let mut f = logger.lock().unwrap();
writeln!(f, ";; {}", line).expect("Failed to write to log file");
}
if repeat {
println!("{}", line);
}
}
})
}