Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved logging for more Address usages
  • Loading branch information
mdashti committed Aug 2, 2023
commit 142438826b20f0b348d2cc8b1e6fad7af0ee651c
14 changes: 7 additions & 7 deletions src/mirrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl MirroredClient {
Ok(server) => server,
Err(err) => {
error!(
"Failed to get connection from pool, Discarding message {:?}, {:?}",
"Failed to get connection from pool, Discarding message {:?}, {}",
err,
address.clone()
);
Expand All @@ -73,17 +73,17 @@ impl MirroredClient {
tokio::select! {
// Exit channel events
_ = self.disconnect_rx.recv() => {
info!("Got mirror exit signal, exiting {:?}", address.clone());
info!("Got mirror exit signal, exiting {}", address.clone());
break;
}

// Incoming data from server (we read to clear the socket buffer and discard the data)
recv_result = server.recv() => {
match recv_result {
Ok(message) => trace!("Received from mirror: {} {:?}", String::from_utf8_lossy(&message[..]), address.clone()),
Ok(message) => trace!("Received from mirror: {} {}", String::from_utf8_lossy(&message[..]), address.clone()),
Err(err) => {
server.mark_bad();
error!("Failed to receive from mirror {:?} {:?}", err, address.clone());
error!("Failed to receive from mirror {:?} {}", err, address.clone());
}
}
}
Expand All @@ -93,15 +93,15 @@ impl MirroredClient {
match message {
Some(bytes) => {
match server.send(&BytesMut::from(&bytes[..])).await {
Ok(_) => trace!("Sent to mirror: {} {:?}", String::from_utf8_lossy(&bytes[..]), address.clone()),
Ok(_) => trace!("Sent to mirror: {} {}", String::from_utf8_lossy(&bytes[..]), address.clone()),
Err(err) => {
server.mark_bad();
error!("Failed to send to mirror, Discarding message {:?}, {:?}", err, address.clone())
error!("Failed to send to mirror, Discarding message {:?}, {}", err, address.clone())
}
}
}
None => {
info!("Mirror channel closed, exiting {:?}", address.clone());
info!("Mirror channel closed, exiting {}", address.clone());
break;
},
}
Expand Down
22 changes: 10 additions & 12 deletions src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl ConnectionPool {
}
}

debug!("Hash obtained for {:?}", address);
debug!("Hash obtained for {}", address);

{
let mut pool_auth_hash = pool_auth_hash.write();
Expand Down Expand Up @@ -631,7 +631,7 @@ impl ConnectionPool {
if self.try_unban(&address).await {
force_healthcheck = true;
} else {
debug!("Address {:?} is banned", address);
debug!("Address {} is banned", address);
continue;
}
}
Expand All @@ -644,7 +644,7 @@ impl ConnectionPool {
Ok(conn) => conn,
Err(err) => {
error!(
"Connection checkout error for instance {:?}, error: {:?}",
"Connection checkout error for instance {}, error: {:?}",
address, err
);
self.ban(address, BanReason::FailedCheckout, Some(client_stats));
Expand Down Expand Up @@ -730,7 +730,7 @@ impl ConnectionPool {
// Health check failed.
Err(err) => {
error!(
"Failed health check on instance {:?}, error: {:?}",
"Failed health check on instance {}, error: {:?}",
address, err
);
}
Expand All @@ -739,7 +739,7 @@ impl ConnectionPool {
// Health check timed out.
Err(err) => {
error!(
"Health check timeout on instance {:?}, error: {:?}",
"Health check timeout on instance {}, error: {:?}",
address, err
);
}
Expand All @@ -761,7 +761,7 @@ impl ConnectionPool {
return;
}

error!("Banning instance {:?}, reason: {:?}", address, reason);
error!("Banning instance {}, reason: {:?}", address, reason);

let now = chrono::offset::Utc::now().naive_utc();
let mut guard = self.banlist.write();
Expand Down Expand Up @@ -839,14 +839,14 @@ impl ConnectionPool {
drop(read_guard);

if exceeded_ban_time {
warn!("Unbanning {:?}", address);
warn!("Unbanning {}", address);
let mut write_guard = self.banlist.write();
write_guard[address.shard].remove(address);
drop(write_guard);

true
} else {
debug!("{:?} is banned", address);
debug!("{} is banned", address);
false
}
}
Expand Down Expand Up @@ -920,7 +920,7 @@ impl ConnectionPool {
return 0;
}
let busy = provisioned - idle;
debug!("{:?} has {:?} busy connections", address, busy);
debug!("{} has {:?} busy connections", address, busy);
return busy;
}
}
Expand Down Expand Up @@ -978,7 +978,7 @@ impl ManageConnection for ServerPool {

/// Attempts to create a new connection.
async fn connect(&self) -> Result<Self::Connection, Self::Error> {
info!("Creating a new server connection {:?}", self.address);
info!("Creating a new server connection {}", self.address);

let stats = Arc::new(ServerStats::new(
self.address.clone(),
Expand All @@ -1000,10 +1000,8 @@ impl ManageConnection for ServerPool {
.await
{
Ok(mut conn) => {
// println!(">>>> self.plugins: {:?}", self.plugins);
if let Some(ref plugins) = self.plugins {
if let Some(ref prewarmer) = plugins.prewarmer {
// println!(">>>> prewarmer: {:?}", prewarmer);
let mut prewarmer = prewarmer::Prewarmer {
enabled: prewarmer.enabled,
server: &mut conn,
Expand Down
8 changes: 4 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ impl Server {
}
Err(err) => {
error!(
"Terminating server {:?} because of: {:?}",
"Terminating server {} because of: {:?}",
self.address, err
);
self.bad = true;
Expand All @@ -779,7 +779,7 @@ impl Server {
Ok(message) => message,
Err(err) => {
error!(
"Terminating server {:?} because of: {:?}",
"Terminating server {} because of: {:?}",
self.address, err
);
self.bad = true;
Expand Down Expand Up @@ -1093,7 +1093,7 @@ impl Server {

/// Indicate that this server connection cannot be re-used and must be discarded.
pub fn mark_bad(&mut self) {
error!("Server {:?} marked bad", self.address);
error!("Server {} marked bad", self.address);
self.bad = true;
}

Expand Down Expand Up @@ -1346,7 +1346,7 @@ impl Drop for Server {
};

info!(
"{} {:?}, session duration: {}",
"{} {}, session duration: {}",
message,
self.address,
crate::format_duration(&duration)
Expand Down