logging
This commit is contained in:
parent
b4aa724e26
commit
1e2a739e5b
@ -65,6 +65,7 @@ impl CloudflareClient {
|
||||
pub async fn check(&mut self) -> Result<()> {
|
||||
let new_ip = get_current_public_ipv4(&self.client).await?;
|
||||
if new_ip == self.current_ip {
|
||||
info!("IP '{}' is already set", new_ip);
|
||||
return Ok(());
|
||||
}
|
||||
info!(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::fmt;
|
||||
|
||||
use log::{debug, error, info, log_enabled, Level};
|
||||
use log::{debug, error, info};
|
||||
use netlink_packet_core::{NetlinkMessage, NetlinkPayload};
|
||||
use netlink_packet_route::RouteNetlinkMessage as RtnlMessage;
|
||||
|
||||
@ -49,30 +49,24 @@ impl<'a> MessageHandler<'a> {
|
||||
D: fmt::Display + ?Sized,
|
||||
M: fmt::Debug,
|
||||
{
|
||||
if log_enabled!(Level::Debug) {
|
||||
debug!("{}: {:?}", log_msg, msg);
|
||||
} else {
|
||||
info!("{}", log_msg);
|
||||
if let Err(e) = self.cloudflare.check().await {
|
||||
self.errs_counter += 1;
|
||||
error!(
|
||||
"Failed to check cloudflare ({}/{}): {:?}",
|
||||
self.errs_counter, self.errs_max, &e
|
||||
);
|
||||
if self.errs_counter >= self.errs_max {
|
||||
return None;
|
||||
}
|
||||
info!("{}", log_msg);
|
||||
debug!("{}: {:?}", log_msg, msg);
|
||||
if let Err(e) = self.cloudflare.check().await {
|
||||
self.errs_counter += 1;
|
||||
error!(
|
||||
"Failed to check cloudflare ({}/{}): {:?}",
|
||||
self.errs_counter, self.errs_max, &e
|
||||
);
|
||||
if self.errs_counter >= self.errs_max {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(())
|
||||
}
|
||||
|
||||
async fn log_info<M: fmt::Debug>(&self, log_msg: &str, msg: &M) -> Option<()> {
|
||||
if log_enabled!(Level::Debug) {
|
||||
debug!("{:?} message: {:?}", log_msg, msg);
|
||||
} else {
|
||||
info!("{}", log_msg);
|
||||
}
|
||||
info!("{}", log_msg);
|
||||
debug!("{:?} message: {:?}", log_msg, msg);
|
||||
Some(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user