implement some 0.2.0 features

This commit is contained in:
yggverse 2025-06-14 23:33:11 +03:00
parent 18116491cb
commit 10c2d7e855
11 changed files with 319 additions and 157 deletions

View file

@ -1,9 +1,28 @@
pub fn error(e: &anyhow::Error) {
eprintln!("[{}] [error] {e}", now())
}
mod level;
use level::Level;
pub fn info(message: String) {
println!("[{}] [info] {message}", now())
pub struct Debug(Vec<Level>);
impl Debug {
pub fn init(levels: &str) -> anyhow::Result<Self> {
let mut l = Vec::with_capacity(levels.len());
for s in levels.to_lowercase().chars() {
l.push(Level::parse(s)?);
}
Ok(Self(l))
}
pub fn error(&self, message: &str) {
if self.0.contains(&Level::Error) {
eprintln!("[{}] [error] {message}", now());
}
}
pub fn info(&self, message: &str) {
if self.0.contains(&Level::Info) {
println!("[{}] [info] {message}", now());
}
}
}
fn now() -> u128 {