diff --git a/ableos/src/log.rs b/ableos/src/log.rs index 3ef38631b..03928b968 100644 --- a/ableos/src/log.rs +++ b/ableos/src/log.rs @@ -1,24 +1,52 @@ pub trait Log { - fn debug(val: &str); - fn error(); - fn info(val: &str); - fn trace(); + fn debug(val: &str); + fn error(); + fn info(val: &str); + fn trace(); } use crate::serial_print; use lliw::{Fg, Reset}; pub struct ANSISerialLogger; impl Log for ANSISerialLogger { - fn debug(val: &str) { - serial_print!("[{}Debug{}] {}\n", Fg::Blue, Reset, val); - } - fn error() { - todo!(); - } - fn info(val: &str) { - serial_print!("[{}Info{}] {}\n", Fg::Blue, Reset, val); - } - fn trace() { - todo!(); - } + fn debug(val: &str) { + serial_print!("[{}Debug{}] {}\n", Fg::Blue, Reset, val); + } + fn error() { + todo!(); + } + fn info(val: &str) { + serial_print!("[{}Info{}] {}\n", Fg::Blue, Reset, val); + } + fn trace() { + todo!(); + } +} + +#[macro_export] +macro_rules! debug { + ($($arg:tt)*) => ({ + log::ANSISerialLogger::debug(&format!($($arg)*)); + }) +} + +#[macro_export] +macro_rules! error { + ($($arg:tt)*) => ({ + log::ANSISerialLogger::error(&format!($($arg)*)); + }) +} + +#[macro_export] +macro_rules! info { + ($($arg:tt)*) => ({ + log::ANSISerialLogger::info(&format!($($arg)*)); + }) +} + +#[macro_export] +macro_rules! trace { + ($($arg:tt)*) => ({ + log::ANSISerialLogger::trace(&format!($($arg)*)); + }) }