1
0

better logger

This commit is contained in:
midefos 2024-08-30 12:46:01 +02:00
parent 6154a858ce
commit a5dd929eb8

View File

@ -16,7 +16,7 @@ use structopt::StructOpt;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
logfmt_logger::init(); start_logger();
match Cli::from_args() { match Cli::from_args() {
Cli::BanServer { Cli::BanServer {
@ -84,10 +84,7 @@ async fn start_ban_server(
) -> std::io::Result<()> { ) -> std::io::Result<()> {
if let Some(iptables_save) = iptables_save { if let Some(iptables_save) = iptables_save {
let seconds_iptables = Duration::from_secs(60); let seconds_iptables = Duration::from_secs(60);
println!( info!("saving IPTables every {} secs", seconds_iptables.as_secs());
"Saving IPTables every {} seconds",
seconds_iptables.as_secs()
);
spawn(move || loop { spawn(move || loop {
sleep(seconds_iptables); 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();
}