Skip to content

Commit

Permalink
Logging process stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
pwalski committed Jan 2, 2024
1 parent b18055b commit 90688fe
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/process/automatic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{path::Path, process::Stdio};

use tokio::process::Command;
use tokio::{process::Command, io::BufReader, io::AsyncBufReadExt, };

use super::{AiFramework, RuntimeArgs};

Expand Down Expand Up @@ -28,6 +28,15 @@ impl AiFramework for Automatic {
}

fn run<ReportFn: Fn(super::Usage) + 'static>(stdout: tokio::process::ChildStdout, report_fn: ReportFn) {
log::info!("Run cmd");
tokio::spawn(async move {
let mut reader = BufReader::new(stdout).lines();

while let Some(line) = reader.next_line().await.unwrap_or_else(|e| {
log::debug!("Error reading line from stdout: {}", e);
None
}) {
log::debug!("{}", line);
}
});
}
}

0 comments on commit 90688fe

Please sign in to comment.