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