diff --git a/src/main.rs b/src/main.rs index 9d98fcb..bcdaf05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use structopt::StructOpt; #[tokio::main] async fn main() { - logfmt_logger::init(); + start_logger(); match Cli::from_args() { Cli::BanServer { @@ -84,10 +84,7 @@ async fn start_ban_server( ) -> std::io::Result<()> { if let Some(iptables_save) = iptables_save { let seconds_iptables = Duration::from_secs(60); - println!( - "Saving IPTables every {} seconds", - seconds_iptables.as_secs() - ); + info!("saving IPTables every {} secs", seconds_iptables.as_secs()); spawn(move || loop { sleep(seconds_iptables); @@ -146,3 +143,13 @@ async fn start_ban_server( } } } + +fn start_logger() { + unsafe { + std::env::set_var( + "RUST_LOG", + std::env::var("RUST_LOG").unwrap_or("INFO".to_string()), + ); + } + logfmt_logger::init(); +}