From 9f798696ff4a6bc8045e6b34d690374802738ef3 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Wed, 28 Aug 2024 17:44:46 +0100 Subject: [PATCH] reduce noisy test logs --- crates/librqbit/src/peer_connection.rs | 7 ++++--- crates/librqbit/src/session.rs | 2 +- crates/librqbit/src/tests/test_util.rs | 4 ++-- crates/librqbit/src/torrent_state/live/mod.rs | 6 +++--- crates/librqbit/src/torrent_state/mod.rs | 3 ++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/librqbit/src/peer_connection.rs b/crates/librqbit/src/peer_connection.rs index 9b3ae73..55977de 100644 --- a/crates/librqbit/src/peer_connection.rs +++ b/crates/librqbit/src/peer_connection.rs @@ -199,9 +199,10 @@ impl PeerConnection { .await .context("error reading handshake")?; let h_supports_extended = h.supports_extended(); - debug!( - "connected: id={:?}", - try_decode_peer_id(Id20::new(h.peer_id)) + trace!( + peer_id=?h.peer_id, + decoded_id=?try_decode_peer_id(Id20::new(h.peer_id)), + "connected", ); if h.info_hash != self.info_hash.0 { anyhow::bail!("info hash does not match"); diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index d6bad63..9c956bb 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -74,7 +74,7 @@ struct ParsedTorrentFile { } fn torrent_from_bytes(bytes: Bytes) -> anyhow::Result { - debug!( + trace!( "all fields in torrent: {:#?}", bencode::dyn_from_bytes::(&bytes) ); diff --git a/crates/librqbit/src/tests/test_util.rs b/crates/librqbit/src/tests/test_util.rs index f33baa2..2dc1436 100644 --- a/crates/librqbit/src/tests/test_util.rs +++ b/crates/librqbit/src/tests/test_util.rs @@ -10,7 +10,7 @@ use librqbit_core::Id20; use parking_lot::RwLock; use rand::{thread_rng, Rng, RngCore, SeedableRng}; use tempfile::TempDir; -use tracing::{debug, info}; +use tracing::{info, trace}; pub fn setup_test_logging() { if std::env::var("RUST_LOG").is_err() { @@ -26,7 +26,7 @@ pub fn create_new_file_with_random_content(path: &Path, mut size: usize) { .open(path) .unwrap(); - debug!(?path, "creating temp file"); + trace!(?path, "creating temp file"); const BUF_SIZE: usize = 8192 * 16; let mut rng = rand::rngs::SmallRng::from_entropy(); diff --git a/crates/librqbit/src/torrent_state/live/mod.rs b/crates/librqbit/src/torrent_state/live/mod.rs index 6afa729..ec04115 100644 --- a/crates/librqbit/src/torrent_state/live/mod.rs +++ b/crates/librqbit/src/torrent_state/live/mod.rs @@ -979,7 +979,7 @@ impl PeerHandler { PeerState::Live(live) => { let mut g = self.state.lock_write("mark_chunk_requests_canceled"); for req in live.inflight_requests { - debug!( + trace!( "peer dead, marking chunk request cancelled, index={}, chunk={}", req.piece_index.get(), req.chunk_index @@ -1036,9 +1036,9 @@ impl PeerHandler { duration = format!("{dur:?}") ), async move { - debug!("waiting to reconnect again"); + trace!("waiting to reconnect again"); tokio::time::sleep(dur).await; - debug!("finished waiting"); + trace!("finished waiting"); self.state .peers .with_peer_mut(handle, "dead_to_queued", |peer| { diff --git a/crates/librqbit/src/torrent_state/mod.rs b/crates/librqbit/src/torrent_state/mod.rs index a7e1bf9..33a137c 100644 --- a/crates/librqbit/src/torrent_state/mod.rs +++ b/crates/librqbit/src/torrent_state/mod.rs @@ -32,6 +32,7 @@ use tokio_stream::StreamExt; use tokio_util::sync::CancellationToken; use tracing::debug; use tracing::error_span; +use tracing::trace; use tracing::warn; use crate::chunk_tracker::ChunkTracker; @@ -271,7 +272,7 @@ impl ManagedTorrent { loop { match timeout(Duration::from_secs(5), peer_rx.next()).await { Ok(Some(peer)) => { - debug!(?peer, "received peer from peer_rx"); + trace!(?peer, "received peer from peer_rx"); let live = match live.upgrade() { Some(live) => live, None => return Ok(()),