LCOV - code coverage report
Current view: top level - compute_tools/src/bin/fast_import - child_stdio_to_log.rs (source / functions) Coverage Total Hit
Test: 20b6afc7b7f34578dcaab2b3acdaecfe91cd8bf1.info Lines: 0.0 % 19 0
Test Date: 2024-11-25 17:48:16 Functions: 0.0 % 4 0

            Line data    Source code
       1              : use tokio::io::{AsyncBufReadExt, BufReader};
       2              : use tokio::process::{ChildStderr, ChildStdout};
       3              : use tracing::info;
       4              : 
       5              : /// Asynchronously relays the output from a child process's `stdout` and `stderr` to the tracing log.
       6              : /// Each line is read and logged individually, with lossy UTF-8 conversion.
       7              : ///
       8              : /// # Arguments
       9              : ///
      10              : /// * `stdout`: An `Option<ChildStdout>` from the child process.
      11              : /// * `stderr`: An `Option<ChildStderr>` from the child process.
      12              : ///
      13            0 : pub(crate) async fn relay_process_output(stdout: Option<ChildStdout>, stderr: Option<ChildStderr>) {
      14            0 :     let stdout_fut = async {
      15            0 :         if let Some(stdout) = stdout {
      16            0 :             let reader = BufReader::new(stdout);
      17            0 :             let mut lines = reader.lines();
      18            0 :             while let Ok(Some(line)) = lines.next_line().await {
      19            0 :                 info!(fd = "stdout", "{}", line);
      20              :             }
      21            0 :         }
      22            0 :     };
      23              : 
      24            0 :     let stderr_fut = async {
      25            0 :         if let Some(stderr) = stderr {
      26            0 :             let reader = BufReader::new(stderr);
      27            0 :             let mut lines = reader.lines();
      28            0 :             while let Ok(Some(line)) = lines.next_line().await {
      29            0 :                 info!(fd = "stderr", "{}", line);
      30              :             }
      31            0 :         }
      32            0 :     };
      33              : 
      34            0 :     tokio::join!(stdout_fut, stderr_fut);
      35            0 : }
        

Generated by: LCOV version 2.1-beta