From 6a60174c04944e26619c8314c670f7f960b4089e Mon Sep 17 00:00:00 2001 From: David Mulder Date: Fri, 23 Aug 2024 09:02:51 -0600 Subject: [PATCH] Always print a newline at the end of debug msgs Otherwise the message doesn't flush to the log and could be lost when the program terminates. Signed-off-by: David Mulder Reviewed-by: Alexander Bokovoy --- rust/dbg/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/dbg/src/lib.rs b/rust/dbg/src/lib.rs index 30b66135811..26c513e2029 100644 --- a/rust/dbg/src/lib.rs +++ b/rust/dbg/src/lib.rs @@ -89,7 +89,9 @@ macro_rules! DBG_PREFIX { let function_msg = format!("{}: ", function); let function_cstr = chelps::wrap_string(&function); let function_msg_cstr = chelps::wrap_string(&function_msg); - let msg = format!($($arg),*); + // Always append a newline to the debug, otherwise it won't flush + // to the log. + let msg = format!("{}\n", format!($($arg),*)); let msg_cstr = chelps::wrap_string(&msg); unsafe { let _ = $crate::ffi::debuglevel_get_class($crate::ffi::DBGC_CLASS as usize) >= ($level as i32)