2023-03-21 13:00:44 +01:00
|
|
|
use env_logger::{Builder, Env, Target};
|
2023-03-23 14:57:24 +01:00
|
|
|
use std::io::Write;
|
2023-03-21 13:00:44 +01:00
|
|
|
|
|
|
|
pub fn init_log_system() {
|
2023-03-23 14:57:24 +01:00
|
|
|
let env = Env::new().filter_or(crate::LOG_LEVEL_ENV_VAR, "warn");
|
2023-03-21 13:00:44 +01:00
|
|
|
let mut builder = Builder::from_env(env);
|
2023-03-23 14:57:24 +01:00
|
|
|
builder.format(|buf, record| {
|
|
|
|
writeln!(
|
|
|
|
buf,
|
|
|
|
"{}: {}",
|
|
|
|
record.level().to_string().to_lowercase(),
|
|
|
|
record.args()
|
|
|
|
)
|
|
|
|
});
|
2023-03-21 13:00:44 +01:00
|
|
|
builder.target(Target::Stderr);
|
|
|
|
builder.init();
|
|
|
|
}
|