Use the log create instead of println

This commit is contained in:
Slatian
2025-02-09 15:11:17 +01:00
parent 2aae2d6626
commit d902dae35d
6 changed files with 84 additions and 40 deletions

View File

@ -3,6 +3,7 @@
* that provides the results ready for templating.
*/
use log::{info,warn,error};
use maxminddb;
use maxminddb::geoip2;
@ -136,7 +137,7 @@ impl QueryAsn for MMDBCarrier {
})
},
Err(e) => {
println!("Error while looking up ASN for {address}: {e}");
error!("Error while looking up ASN for {address}: {e}");
Default::default()
}
}
@ -204,7 +205,7 @@ impl QueryLocation for MMDBCarrier {
})
},
Err(e) => {
println!("Error while looking up ASN for {address}: {e}");
error!("Error while looking up ASN for {address}: {e}");
Default::default()
}
}
@ -232,7 +233,7 @@ impl MMDBCarrier {
pub fn load_database_from_path(&self, path: &Path) -> Result<(),maxminddb::MaxMindDBError> {
let mut mmdb = self.mmdb.write();
println!("Loading {} from '{}' ...", &self.name, path.display());
info!("Loading {} from '{}' ...", &self.name, path.display());
match maxminddb::Reader::open_readfile(path) {
Ok(reader) => {
let wording = if mmdb.is_some() {
@ -241,13 +242,13 @@ impl MMDBCarrier {
"Loaded new"
};
*mmdb = Some(reader);
println!("{} {} with new one.", wording, &self.name);
info!("{} {} with new one.", wording, &self.name);
Ok(())
},
Err(e) => {
println!("Error while reading {}: {}", &self.name, &e);
error!("Error while reading {}: {}", &self.name, &e);
if mmdb.is_some() {
println!("Not replacing old database.");
warn!("Not replacing old database.");
}
Err(e)
},