diff --git a/kernel/src/holeybytes/kernel_services/logging_service.rs b/kernel/src/holeybytes/kernel_services/logging_service.rs index 48a38b940..b1fbf4ae6 100644 --- a/kernel/src/holeybytes/kernel_services/logging_service.rs +++ b/kernel/src/holeybytes/kernel_services/logging_service.rs @@ -9,12 +9,16 @@ use log::Record; pub fn log_msg_handler(_vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { let msg_vec = block_read(mem_addr, length); - let log_level = msg_vec.last().unwrap(); + let log_level = msg_vec[0]; + let strptr = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap()); + let strlen = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap()) as usize; + + let str = block_read(strptr, strlen); let file_name = "None"; let line_number = 0; - match core::str::from_utf8(&msg_vec[..msg_vec.len() - 1]) { + match core::str::from_utf8(&str) { Ok(strr) => { use log::Level::*; let log_level = match log_level { diff --git a/sysdata/libraries/stn/src/log.hb b/sysdata/libraries/stn/src/log.hb index 72c68ebdf..95d91c1ea 100644 --- a/sysdata/libraries/stn/src/log.hb +++ b/sysdata/libraries/stn/src/log.hb @@ -1,10 +1,9 @@ string := @use("string.hb") -log := fn($Level: u8, message: ^u8): void { - message_length := @inline(string.length, message); - *(message + message_length) = Level +LogMsg := packed struct {level: u8, string: ^u8, strlen: uint} - return @eca(3, 1, message, message_length + 1) +log := fn($Level: u8, message: ^u8): void { + return @eca(3, 1, LogMsg.(Level, message, @inline(string.length, message)), @sizeof(LogMsg)) } error := fn(message: ^u8): void return @inline(log, 0, message) diff --git a/sysdata/libraries/stn/src/string.hb b/sysdata/libraries/stn/src/string.hb index 042de0254..8e8000113 100644 --- a/sysdata/libraries/stn/src/string.hb +++ b/sysdata/libraries/stn/src/string.hb @@ -1,5 +1,5 @@ -length := fn(ptr: ^u8): int { - len := 0 +length := fn(ptr: ^u8): uint { + len := @as(uint, 0) loop if *(ptr + len) == 0 break else len += 1 return len }