Skip to content

Commit cfa7d91

Browse files
authored
fix(rust): Flush stdout after print to fix stream mode display
2 parents 8aadbfb + ad971f0 commit cfa7d91

File tree

1 file changed

+10
-2
lines changed
  • src/rust/lib_ccxr/src/util

1 file changed

+10
-2
lines changed

src/rust/lib_ccxr/src/util/log.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,16 @@ impl<'a> CCExtractorLogger {
281281

282282
fn print(&self, args: &Arguments<'a>) {
283283
match &self.target {
284-
OutputTarget::Stdout => print!("{args}"),
285-
OutputTarget::Stderr => eprint!("{args}"),
284+
OutputTarget::Stdout => {
285+
print!("{args}");
286+
// Flush stdout to ensure output appears immediately, especially when
287+
// mixing with C code that also writes to stdout
288+
let _ = std::io::Write::flush(&mut std::io::stdout());
289+
}
290+
OutputTarget::Stderr => {
291+
eprint!("{args}");
292+
let _ = std::io::Write::flush(&mut std::io::stderr());
293+
}
286294
OutputTarget::Quiet => {}
287295
}
288296
}

0 commit comments

Comments
 (0)