Merge pull request #21 from Eraden/fix-logs
Set default log level and initialize logger before load config
This commit is contained in:
commit
de85a17e66
@ -80,14 +80,16 @@ pub struct Opts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
|
if std::env::var("RUST_LOG").is_err() {
|
||||||
|
std::env::set_var("RUST_LOG", "DEBUG");
|
||||||
|
}
|
||||||
|
pretty_env_logger::init();
|
||||||
if std::fs::read(CONFIG_DIR).map_err(|e| e.kind() == ErrorKind::NotFound) == Err(true) {
|
if std::fs::read(CONFIG_DIR).map_err(|e| e.kind() == ErrorKind::NotFound) == Err(true) {
|
||||||
std::fs::create_dir_all(CONFIG_DIR)?;
|
std::fs::create_dir_all(CONFIG_DIR)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = load_config()?;
|
let config = load_config()?;
|
||||||
|
log::set_max_level(config.log_level().as_str().parse().unwrap());
|
||||||
std::env::set_var("RUST_LOG", config.log_level().as_str());
|
|
||||||
pretty_env_logger::init();
|
|
||||||
|
|
||||||
let opts: Opts = Opts::parse_args_default_or_exit();
|
let opts: Opts = Opts::parse_args_default_or_exit();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user