Skip to content

Commit ad971f0

Browse files
cfsmp3claude
andcommitted
fix(rust): Flush stdout after print to fix stream mode display
When using --input <format>, the startup output showed [Stream mode: ] (empty) instead of showing the format name like [Stream mode: SCC]. Root cause: The Rust logger's print() function uses print!() which doesn't automatically flush stdout. When mixing C and Rust code that both write to stdout, the Rust output was getting buffered and not appearing before the C code continued writing. The fix adds explicit std::io::stdout().flush() after each print!() call to ensure output appears immediately and interleaves correctly with C code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 1b0e66b commit ad971f0

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)