Flush the debug trace file after each dbg!().
When debugging code built with panic=about, the debug trace buffer is not flushed on a panic and important messages are lost. This does slow down debug tracing a bit, but this is still better than unbuffered or line buffered I/O since the dbg!() macro can write out many lines like a whole function.
This commit is contained in:
@@ -63,7 +63,11 @@ thread_local! {
|
||||
///
|
||||
/// This is for use by the `dbg!` macro.
|
||||
pub fn writeln_with_format_args(args: fmt::Arguments) -> io::Result<()> {
|
||||
WRITER.with(|rc| writeln!(*rc.borrow_mut(), "{}", args))
|
||||
WRITER.with(|rc| {
|
||||
let mut w = rc.borrow_mut();
|
||||
writeln!(*w, "{}", args)?;
|
||||
w.flush()
|
||||
})
|
||||
}
|
||||
|
||||
/// Open the tracing file for the current thread.
|
||||
|
||||
Reference in New Issue
Block a user