#![allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LogLevel {
Start,
Success,
Error,
}
impl LogLevel {
fn as_str(&self) -> &'static str {
match self {
LogLevel::Start => "START",
LogLevel::Success => "SUCCESS",
LogLevel::Error => "ERROR",
}
}
}
#[macro_export]
macro_rules! klog {
(START, $($args:tt)*) => {{
#[allow(unused_imports)]
{
use tail_core::kprint::kprint;
use tail_core::rich_text::*;
kprint(format_args!("{}{}[START]{} ", BOLD, BLU, RESET));
kprint(format_args!($($args)*));
kprint(format_args!("\n"));
}
}};
(SUCCESS, $($args:tt)*) => {{
#[allow(unused_imports)]
{
use tail_core::kprint::kprint;
use tail_core::rich_text::*;
kprint(format_args!("{}{}[SUCCESS]{} ", BOLD, BLU, RESET));
kprint(format_args!($($args)*));
kprint(format_args!("\n"));
}
}};
(ERROR, $($args:tt)*) => {{
#[allow(unused_imports)]
{
use tail_core::kprint::kprint;
use tail_core::rich_text::*;
kprint(format_args!("{}{}[ERROR]{} ", BOLD, RED, RESET));
kprint(format_args!($($args)*));
kprint(format_args!("\n"));
}
}};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_log_level_as_str() {
assert_eq!(LogLevel::Start.as_str(), "START");
assert_eq!(LogLevel::Success.as_str(), "SUCCESS");
assert_eq!(LogLevel::Error.as_str(), "ERROR");
}
}