mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-04-01 01:25:36 +00:00
implement some 0.2.0 features
This commit is contained in:
parent
18116491cb
commit
10c2d7e855
11 changed files with 319 additions and 157 deletions
29
src/debug.rs
29
src/debug.rs
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue