Returns an iterator over the lines of data output to `stdout` by the child process. Beware that the iterator buffers the output, thus when the it is dropped the buffered data will be discarded and following reads won't restore it. The returned line of output is logged via [`log`] crate according to [`Cmd::log_cmd()`] configuration. # Panics Panics if some [`std::io::Error`] happens during the rea
(&mut self)
| 644 | /// Panics if some [`std::io::Error`] happens during the reading. |
| 645 | /// All invariants from [`Child::read_bytes()`] apply here too. |
| 646 | pub fn stdout_lines(&mut self) -> impl Iterator<Item = String> + '_ { |
| 647 | let log_cmd = self.cmd.0.log_cmd; |
| 648 | let id = self.child.id(); |
| 649 | let bin_name = self.cmd.bin_name(); |
| 650 | let stdout = io::BufReader::new(self.child.stdout.as_mut().unwrap()); |
| 651 | stdout |
| 652 | .lines() |
| 653 | .map(|line| line.expect("Unexpected io error")) |
| 654 | .inspect(move |line| { |
| 655 | if let Some(level) = log_cmd { |
| 656 | log::log!(level, "[{} {}] {}", id, bin_name, line); |
| 657 | } |
| 658 | }) |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | /// Defines the kind of standard process output stream. |