2021-11-27 09:19:08 -06:00
|
|
|
pub trait Log {
|
2021-12-24 03:39:24 -06:00
|
|
|
fn debug(val: &str);
|
|
|
|
fn error();
|
|
|
|
fn info(val: &str);
|
|
|
|
fn trace();
|
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:39:24 -06:00
|
|
|
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)*));
|
|
|
|
})
|
2021-11-27 09:19:08 -06:00
|
|
|
}
|