From 8a3e9ea3f5df8300d67e2ab3be2241c469774709 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 25 Oct 2025 21:36:46 +0800 Subject: [PATCH] fix crlf issue in logging crate --- services/xous-log/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/xous-log/src/main.rs b/services/xous-log/src/main.rs index 1e1a8a60b..1feef8603 100644 --- a/services/xous-log/src/main.rs +++ b/services/xous-log/src/main.rs @@ -131,8 +131,8 @@ fn reader_thread(arg: usize) { usb_str.push(*c as char); } write!(usb_str, ": ").ok(); - for c in args_slice { - usb_str.push(*c as char); + unsafe { + usb_str.push_str(std::str::from_utf8_unchecked(args_slice)); } write!(usb_str, " (").ok(); for c in file_slice { @@ -141,7 +141,7 @@ fn reader_thread(arg: usize) { if let Some(line) = lr.line { write!(usb_str, ":{}", line.get()).ok(); } - writeln!(usb_str, ")").ok(); + writeln!(usb_str, ")\r").ok(); usb_send_str(conn, &usb_str); } } @@ -180,7 +180,8 @@ fn reader_thread(arg: usize) { // safety: this routine will just blow up if you try to pass non utf-8 to it, // so it's not very safe. On the other hand, it's fast and shame on you for // sending non-utf8 to this API. - usb_send_str(conn, unsafe { std::str::from_utf8_unchecked(buffer) }); + let s = unsafe { std::str::from_utf8_unchecked(buffer) }.to_string(); + usb_send_str(conn, &s.replace("\n", "\r\n")); } } _ => {