Log not found errors to the debug channel

They are part of normal operation and shouldn't be logged in production.
This commit is contained in:
Slatian 2025-02-09 16:27:12 +01:00
parent caf47522e4
commit ba34caf8fc
2 changed files with 18 additions and 4 deletions

View File

@ -3,9 +3,10 @@
* that provides the results ready for templating. * that provides the results ready for templating.
*/ */
use log::{info,warn,error}; use log::{debug,info,warn,error};
use maxminddb::geoip2; use maxminddb::geoip2;
use maxminddb::MaxMindDBError::AddressNotFoundError;
use parking_lot::RwLock; use parking_lot::RwLock;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -135,9 +136,15 @@ impl QueryAsn for MMDBCarrier {
name: res.autonomous_system_organization.map(ToString::to_string), name: res.autonomous_system_organization.map(ToString::to_string),
}) })
}, },
Err(AddressNotFoundError(_)) => {
// Log to the debug channel.
// This isn't severe, and shouldn't be logged in production.
debug!("ASN not found in database for {address}.");
None
},
Err(e) => { Err(e) => {
error!("Error while looking up ASN for {address}: {e}"); error!("Error while looking up ASN for {address}: {e}");
Default::default() None
} }
} }
}, },
@ -203,9 +210,15 @@ impl QueryLocation for MMDBCarrier {
}, },
}) })
}, },
Err(AddressNotFoundError(_)) => {
// Log to the debug channel.
// This isn't severe, and shouldn't be logged in production.
debug!("IP location not found in database for {address}");
None
},
Err(e) => { Err(e) => {
error!("Error while looking up ASN for {address}: {e}"); error!("Error while looking up IP location for {address}: {e}");
Default::default() None
} }
} }
}, },

View File

@ -111,6 +111,7 @@ impl AddressInfo {
scope: address_scope scope: address_scope
} }
} }
} }