Files
gravel/stdsrv/src/logger.rs
2025-11-09 01:06:25 +02:00

40 lines
813 B
Rust

use std::fmt::Display;
#[derive(Debug)]
#[allow(dead_code)]
pub enum Level {
Error,
Warn,
Info,
Debug,
}
impl Display for Level {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}]\x1b[0m",
match self {
Self::Error => "\x1b[1;31m[ERROR",
Self::Warn => "\x1b[1;33m[WARN",
Self::Info => "\x1b[0;32m[INFO",
Self::Debug => "\x1b[0;36m[DEBUG",
}
)
}
}
#[macro_export]
macro_rules! log {
($level:expr, $($arg:tt)*) => {{
println!(
"{} {}:{}:{}: {}",
$level,
std::module_path!(),
std::file!(),
std::line!(),
format!($($arg)*)
);
}};
}