1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use colored::*;
fn color_level(level: log::Level) -> colored::ColoredString {
let text = format!("{: <8}", level);
match level {
log::Level::Error => text.red().bold(),
log::Level::Warn => text.yellow(),
log::Level::Info => text.green(),
log::Level::Debug => text.cyan(),
log::Level::Trace => text.magenta(),
}
}
pub fn init_logger() {
fern::Dispatch::new().format(|out, message, record|{
out.finish(format_args!(
"{} {} > {}",
color_level(record.level()),
record.target(),
message
)
)
})
.level(log::LevelFilter::Debug)
.level_for("hyper", log::LevelFilter::Off)
.level_for("tokio_reactor", log::LevelFilter::Off)
.level_for("reqwest", log::LevelFilter::Off)
.chain(std::io::stdout())
.apply().unwrap();
}
|