2021-11-27 09:19:08 -06:00
|
|
|
pub trait Log {
|
2021-12-24 03:30:27 -06:00
|
|
|
fn debug(val: &str);
|
2021-12-24 03:40:11 -06:00
|
|
|
fn error(val: &str);
|
2021-12-24 03:30:27 -06:00
|
|
|
fn info(val: &str);
|
2021-12-24 03:40:11 -06:00
|
|
|
fn trace(val: &str);
|
2021-11-27 09:19:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
use crate::serial_print;
|
2021-11-27 14:59:29 -06:00
|
|
|
use lliw::{Fg, Reset};
|
2021-11-27 09:19:08 -06:00
|
|
|
pub struct ANSISerialLogger;
|
|
|
|
impl Log for ANSISerialLogger {
|
2021-12-24 03:30:27 -06:00
|
|
|
fn debug(val: &str) {
|
|
|
|
serial_print!("[{}Debug{}] {}\n", Fg::Blue, Reset, val);
|
2021-11-27 09:19:08 -06:00
|
|
|
}
|
2021-12-24 03:40:11 -06:00
|
|
|
fn error(val: &str) {
|
|
|
|
serial_print!("[{}Error{}] {}\n", Fg::Red, Reset, val);
|
2021-11-27 09:19:08 -06:00
|
|
|
}
|
2021-12-24 03:30:27 -06:00
|
|
|
fn info(val: &str) {
|
2021-12-24 03:40:11 -06:00
|
|
|
serial_print!("[{}Info{}] {}\n", Fg::LightWhite, Reset, val);
|
2021-11-27 09:19:08 -06:00
|
|
|
}
|
2021-12-24 03:40:11 -06:00
|
|
|
fn trace(val: &str) {
|
|
|
|
serial_print!("[{}Trace{}] {}\n", Fg::Yellow, Reset, val);
|
2021-11-27 09:19:08 -06:00
|
|
|
}
|
2021-12-24 03:39:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! debug {
|
|
|
|
($($arg:tt)*) => ({
|
2021-12-24 04:05:23 -06:00
|
|
|
let _ = &log::ANSISerialLogger::debug(&alloc::format!($($arg)*));
|
2021-12-24 03:39:24 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! error {
|
|
|
|
($($arg:tt)*) => ({
|
2021-12-24 04:05:23 -06:00
|
|
|
log::ANSISerialLogger::error(&alloc::format!($($arg)*));
|
2021-12-24 03:39:24 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! info {
|
|
|
|
($($arg:tt)*) => ({
|
2021-12-24 04:05:23 -06:00
|
|
|
log::ANSISerialLogger::info(&alloc::format!($($arg)*));
|
2021-12-24 03:39:24 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! trace {
|
|
|
|
($($arg:tt)*) => ({
|
2021-12-24 04:05:23 -06:00
|
|
|
log::ANSISerialLogger::trace(&alloc::format!($($arg)*));
|
2021-12-24 03:39:24 -06:00
|
|
|
})
|
2021-11-27 09:19:08 -06:00
|
|
|
}
|