From 086cc4aef08b13432e2061e5d8c19d28126c85ce Mon Sep 17 00:00:00 2001 From: koniifer Date: Wed, 16 Oct 2024 00:03:23 +0100 Subject: [PATCH] patch minor logging bug --- .../holeybytes/kernel_services/logging_service.rs | 2 +- sysdata/libraries/stn/src/log.hb | 15 +++++++-------- sysdata/programs/tests/src/main.hb | 6 ++++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/src/holeybytes/kernel_services/logging_service.rs b/kernel/src/holeybytes/kernel_services/logging_service.rs index a0b461f..48a38b9 100644 --- a/kernel/src/holeybytes/kernel_services/logging_service.rs +++ b/kernel/src/holeybytes/kernel_services/logging_service.rs @@ -14,7 +14,7 @@ pub fn log_msg_handler(_vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), let file_name = "None"; let line_number = 0; - match core::str::from_utf8(&msg_vec[..msg_vec.len()]) { + match core::str::from_utf8(&msg_vec[..msg_vec.len() - 1]) { 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 14639df..72c68eb 100644 --- a/sysdata/libraries/stn/src/log.hb +++ b/sysdata/libraries/stn/src/log.hb @@ -1,15 +1,14 @@ string := @use("string.hb") -buffer := @use("buffer.hb") -log := fn(message: ^u8, level: u8): void { +log := fn($Level: u8, message: ^u8): void { message_length := @inline(string.length, message); - *(message + message_length) = level + *(message + message_length) = Level return @eca(3, 1, message, message_length + 1) } -error := fn(message: ^u8): void return log(message, 0) -warn := fn(message: ^u8): void return log(message, 1) -info := fn(message: ^u8): void return log(message, 2) -debug := fn(message: ^u8): void return log(message, 3) -trace := fn(message: ^u8): void return log(message, 4) \ No newline at end of file +error := fn(message: ^u8): void return @inline(log, 0, message) +warn := fn(message: ^u8): void return @inline(log, 1, message) +info := fn(message: ^u8): void return @inline(log, 2, message) +debug := fn(message: ^u8): void return @inline(log, 3, message) +trace := fn(message: ^u8): void return @inline(log, 4, message) \ No newline at end of file diff --git a/sysdata/programs/tests/src/main.hb b/sysdata/programs/tests/src/main.hb index be45842..e89eafb 100644 --- a/sysdata/programs/tests/src/main.hb +++ b/sysdata/programs/tests/src/main.hb @@ -9,5 +9,11 @@ service_search := fn(): void { main := fn(): int { //service_search() + buf := "\0\0\0\0" + x := 0 + loop if x == 255 break else { + log.info(string.display_int(x, buf)) + x += 1 + } return 0 } \ No newline at end of file