better iterlog

This commit is contained in:
folex 2020-06-10 15:41:46 +03:00
parent c36397b7de
commit c8839a5b55

View File

@ -391,20 +391,19 @@ impl ClosestPeersIter {
/// Immediately transitions the iterator to [`PeersIterState::Finished`]. /// Immediately transitions the iterator to [`PeersIterState::Finished`].
pub fn finish(&mut self) { pub fn finish(&mut self) {
self.state = State::Finished; self.state = State::Finished;
// let closest = self.closest_peers.values().cloned().collect::<Vec<Peer>>();
log::info!( log::info!(
"[iterlog] ClosestPeerIter: target = {}; finished +{}ms. Log:\n", "[iterlog] ClosestPeerIter: target = {}; finished +{}ms. Log:",
bs58::encode(&self.target).into_string(), bs58::encode(&self.target).into_string(),
self.created_at.elapsed().as_millis(), self.created_at.elapsed().as_millis(),
); );
let created_at = self.created_at; let created_at = self.created_at;
self.closest_peers.iter().for_each(|(_, p)| { self.closest_peers.iter().for_each(|(_, p)| {
log::info!("[iterlog] {}:\n", p.key.preimage()); log::info!("[iterlog] {}:", p.key.preimage());
p.log.iter().for_each(|(i, s)| { p.log.iter().for_each(|(i, s)| {
// TODO: show negative difference? // TODO: show negative difference?
let elapsed = i.saturating_duration_since(created_at).as_millis().to_string(); let elapsed = i.saturating_duration_since(created_at).as_millis().to_string();
log::info!("[iterlog] \t{: <45?}\t+{}ms", s, elapsed) log::info!("[iterlog] \t{: <45?}\t+{}ms\n", s, elapsed)
}); });
}); });