pub mod log {
pub use tracing::debug;
pub use tracing::error;
pub use tracing::info;
pub use tracing::trace;
pub use tracing::warn;
}
use tracing::Level;
pub fn init_logger(level: Level) {
let level = match level {
Level::TRACE => "trace",
Level::DEBUG => "debug",
Level::INFO => "info",
Level::WARN => "warn",
Level::ERROR => "error",
};
let timer =
tracing_subscriber::fmt::time::ChronoLocal::with_format("%Y-%m-%d %H:%M:%S".to_string());
let subscriber = tracing_subscriber::FmtSubscriber::builder()
.with_env_filter(format!("{},hyper=off,warp=off", level))
.with_writer(std::io::stderr)
.with_timer(timer)
.finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
}
pub fn init_stdlog() {
tracing_log::LogTracer::builder()
.with_max_level(stdlog::LevelFilter::Info)
.init()
.unwrap();
}