소스 검색

net: change info logs to verbose logs

oars 9 달 전
부모
커밋
c048f753da

+ 3 - 2
src/net/acceptor.rs

@@ -25,7 +25,7 @@ use std::{
 };
 
 use smol::Executor;
-use tracing::{error, info, warn};
+use tracing::{error, warn};
 use url::Url;
 
 use super::{
@@ -36,6 +36,7 @@ use super::{
 };
 use crate::{
     system::{CondVar, Publisher, PublisherPtr, StoppableTask, StoppableTaskPtr, Subscription},
+    util::logger::verbose,
     Error, Result,
 };
 
@@ -75,7 +76,7 @@ impl Acceptor {
         #[cfg(feature = "p2p-tor")]
         if endpoint.scheme() == "tor" {
             let onion_addr = listener.endpoint().await;
-            info!("[P2P] Adding {onion_addr} to external_addrs");
+            verbose!("[P2P] Adding {onion_addr} to external_addrs");
             self.session
                 .upgrade()
                 .unwrap()

+ 5 - 5
src/net/channel.rs

@@ -35,7 +35,7 @@ use smol::{
     lock::{Mutex as AsyncMutex, OnceCell},
     Executor,
 };
-use tracing::{debug, error, info, trace, warn};
+use tracing::{debug, error, trace, warn};
 use url::Url;
 
 use super::{
@@ -54,7 +54,7 @@ use super::{
 use crate::{
     net::BanPolicy,
     system::{msleep, Publisher, PublisherPtr, StoppableTask, StoppableTaskPtr, Subscription},
-    util::time::NanoTimestamp,
+    util::{logger::verbose, time::NanoTimestamp},
     Error, Result,
 };
 
@@ -409,7 +409,7 @@ impl Channel {
                 Ok(command) => command,
                 Err(err) => {
                     if Self::is_eof_error(&err) {
-                        info!(
+                        verbose!(
                             target: "net::channel::main_receive_loop()",
                             "[P2P] Channel {} disconnected",
                             self.display_address()
@@ -520,10 +520,10 @@ impl Channel {
         };
 
         let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
-        info!(target: "net::channel::ban()", "Blacklisting peer={peer}");
+        verbose!(target: "net::channel::ban()", "Blacklisting peer={peer}");
         match self.p2p().hosts().move_host(&peer, last_seen, HostColor::Black).await {
             Ok(()) => {
-                info!(target: "net::channel::ban()", "Peer={peer} blacklisted successfully");
+                verbose!(target: "net::channel::ban()", "Peer={peer} blacklisted successfully");
             }
             Err(e) => {
                 warn!(target: "net::channel::ban()", "Could not blacklisted peer={peer}, err={e}");

+ 3 - 2
src/net/hosts.rs

@@ -29,7 +29,7 @@ use std::{
     },
     time::{Instant, UNIX_EPOCH},
 };
-use tracing::{debug, error, info, trace, warn};
+use tracing::{debug, error, trace, warn};
 use url::{Host, Url};
 
 use super::{
@@ -41,6 +41,7 @@ use crate::{
     system::{Publisher, PublisherPtr, Subscription},
     util::{
         file::{load_file, save_file},
+        logger::verbose,
         most_frequent_or_any,
         path::expand_path,
         ringbuffer::RingBuffer,
@@ -790,7 +791,7 @@ impl HostContainer {
         }
 
         if !tsv.is_empty() {
-            info!(target: "net::hosts::save_hosts()", "Saving hosts to: {path:?}");
+            verbose!(target: "net::hosts::save_hosts()", "Saving hosts to: {path:?}");
             if let Err(e) = save_file(&path, &tsv) {
                 error!(target: "net::hosts::save_hosts()", "Failed saving hosts: {e}");
             }

+ 4 - 4
src/net/p2p.rs

@@ -24,7 +24,7 @@ use std::sync::{
 use futures::{stream::FuturesUnordered, TryFutureExt};
 use futures_rustls::rustls::crypto::{ring, CryptoProvider};
 use smol::{fs, lock::RwLock as AsyncRwLock, stream::StreamExt};
-use tracing::{debug, error, info, warn};
+use tracing::{debug, error, warn};
 use url::Url;
 
 use super::{
@@ -42,7 +42,7 @@ use super::{
 };
 use crate::{
     system::{ExecutorPtr, Publisher, PublisherPtr, Subscription},
-    util::path::expand_path,
+    util::{logger::verbose, path::expand_path},
     Result,
 };
 
@@ -129,7 +129,7 @@ impl P2p {
     pub async fn start(self: Arc<Self>) -> Result<()> {
         debug!(target: "net::p2p::start", "P2P::start() [BEGIN] [magic_bytes={:?}]",
                self.settings.read().await.magic_bytes.0);
-        info!(target: "net::p2p::start", "[P2P] Starting P2P subsystem");
+        verbose!(target: "net::p2p::start", "[P2P] Starting P2P subsystem");
 
         // Start the inbound session
         if let Err(err) = self.session_inbound().start().await {
@@ -153,7 +153,7 @@ impl P2p {
         // Start the direct session
         self.session_direct().start().await;
 
-        info!(target: "net::p2p::start", "[P2P] P2P subsystem started successfully");
+        verbose!(target: "net::p2p::start", "[P2P] P2P subsystem started successfully");
         Ok(())
     }
 

+ 8 - 7
src/net/session/direct_session.rs

@@ -37,7 +37,7 @@ use std::{
 
 use async_trait::async_trait;
 use smol::lock::Mutex as AsyncMutex;
-use tracing::{debug, error, info, warn};
+use tracing::{debug, error, warn};
 use url::Url;
 
 use super::{
@@ -53,6 +53,7 @@ use super::{
 use crate::{
     net::ChannelPtr,
     system::{sleep, timeout::timeout, CondVar, PublisherPtr, StoppableTask, StoppableTaskPtr},
+    util::logger::verbose,
     Error, Result,
 };
 
@@ -268,7 +269,7 @@ impl ChannelBuilder {
     /// Create a new channel to `addr` in the direct session.
     /// The transport is verified before the connection is started.
     pub async fn new_channel(&mut self, addr: &Url) -> Result<ChannelPtr> {
-        info!(
+        verbose!(
             target: "net::direct_session",
             "[P2P] Connecting to direct outbound [{addr}]",
         );
@@ -323,7 +324,7 @@ impl ChannelBuilder {
 
         match self.connector().connect(addr).await {
             Ok((_, channel)) => {
-                info!(
+                verbose!(
                     target: "net::direct_session",
                     "[P2P] Direct outbound connected [{}]",
                     channel.display_address()
@@ -471,7 +472,7 @@ impl PeerDiscovery {
             current_attempt += 1;
 
             if current_attempt >= 4 {
-                info!(
+                verbose!(
                     target: "net::direct_session::peer_discovery()",
                     "[P2P] [PEER DISCOVERY] Sleeping and trying again. Attempt {current_attempt}"
                 );
@@ -513,7 +514,7 @@ impl PeerDiscovery {
             if self.p2p().is_connected() && current_attempt <= 2 {
                 // Broadcast the GetAddrs message to all active peers.
                 // If we have no active peers, we will perform a SeedSyncSession instead.
-                info!(
+                verbose!(
                     target: "net::direct_session::peer_discovery()",
                     "[P2P] [PEER DISCOVERY] Asking peers for new peers to connect to...");
 
@@ -540,7 +541,7 @@ impl PeerDiscovery {
 
                 match result {
                     Ok(addrs_len) => {
-                        info!(
+                        verbose!(
                             target: "net::direct_session::peer_discovery()",
                             "[P2P] [PEER DISCOVERY] Discovered {addrs_len} peers"
                         );
@@ -565,7 +566,7 @@ impl PeerDiscovery {
                 // de-allocated when the Session completes.
                 store_sub.unsubscribe().await;
             } else if !seeds.is_empty() {
-                info!(
+                verbose!(
                     target: "net::direct_session::peer_discovery()",
                     "[P2P] [PEER DISCOVERY] Asking seeds for new peers to connect to...");
 

+ 6 - 5
src/net/session/inbound_session.rs

@@ -27,7 +27,7 @@ use std::sync::{Arc, Weak};
 
 use async_trait::async_trait;
 use smol::{lock::Mutex, Executor};
-use tracing::{debug, error, info, warn};
+use tracing::{debug, error, warn};
 use url::Url;
 
 use super::{
@@ -41,6 +41,7 @@ use super::{
 };
 use crate::{
     system::{StoppableTask, StoppableTaskPtr, Subscription},
+    util::logger::verbose,
     Error, Result,
 };
 
@@ -70,7 +71,7 @@ impl InboundSession {
         let inbound_addrs = self.p2p().settings().read().await.inbound_addrs.clone();
 
         if inbound_addrs.is_empty() {
-            info!(target: "net::inbound_session", "[P2P] Not configured for inbound connections.");
+            verbose!(target: "net::inbound_session", "[P2P] Not configured for inbound connections.");
             return Ok(())
         }
 
@@ -114,7 +115,7 @@ impl InboundSession {
     /// Stops the inbound session.
     pub async fn stop(&self) {
         if self.p2p().settings().read().await.inbound_addrs.is_empty() {
-            info!(target: "net::inbound_session", "[P2P] Stopping inbound session.");
+            verbose!(target: "net::inbound_session", "[P2P] Stopping inbound session.");
             return
         }
 
@@ -137,7 +138,7 @@ impl InboundSession {
         acceptor: AcceptorPtr,
         ex: Arc<Executor<'_>>,
     ) -> Result<()> {
-        info!(target: "net::inbound_session", "[P2P] Starting Inbound session #{index} on {accept_addr}");
+        verbose!(target: "net::inbound_session", "[P2P] Starting Inbound session #{index} on {accept_addr}");
         // Start listener
         let result = acceptor.clone().start(accept_addr, ex).await;
         if let Err(e) = &result {
@@ -174,7 +175,7 @@ impl InboundSession {
         channel: ChannelPtr,
         ex: Arc<Executor<'_>>,
     ) {
-        info!(
+        verbose!(
              target: "net::inbound_session::setup_channel",
              "[P2P] Connected Inbound #{index} [{}]", channel.display_address()
         );

+ 6 - 5
src/net/session/manual_session.rs

@@ -36,7 +36,7 @@ use std::sync::{Arc, Weak};
 use async_trait::async_trait;
 use futures::stream::{FuturesUnordered, StreamExt};
 use smol::lock::{Mutex as AsyncMutex, RwLock as AsyncRwLock};
-use tracing::{debug, error, info, warn};
+use tracing::{debug, error, warn};
 use url::Url;
 
 use super::{
@@ -49,6 +49,7 @@ use super::{
 use crate::{
     net::{hosts::HostState, settings::Settings},
     system::{sleep, StoppableTask, StoppableTaskPtr},
+    util::logger::verbose,
     Error, Result,
 };
 
@@ -154,7 +155,7 @@ impl Slot {
         loop {
             attempts += 1;
 
-            info!(
+            verbose!(
                 target: "net::manual_session",
                 "[P2P] Connecting to manual outbound [{}] (attempt #{})",
                 self.addr, attempts
@@ -186,7 +187,7 @@ impl Slot {
 
             match self.connector.connect(&self.addr).await {
                 Ok((_, channel)) => {
-                    info!(
+                    verbose!(
                         target: "net::manual_session",
                         "[P2P] Manual outbound connected [{}]",
                         channel.display_address()
@@ -202,7 +203,7 @@ impl Slot {
                             // Wait for channel to close
                             stop_sub.receive().await;
 
-                            info!(
+                            verbose!(
                                 target: "net::manual_session",
                                 "[P2P] Manual outbound disconnected [{}]",
                                 channel.display_address()
@@ -235,7 +236,7 @@ impl Slot {
                 }
             }
 
-            info!(
+            verbose!(
                 target: "net::manual_session",
                 "[P2P] Waiting {outbound_connect_timeout} seconds until next manual outbound connection attempt [{}]",
                 self.addr,

+ 11 - 10
src/net/session/outbound_session.rs

@@ -37,7 +37,7 @@ use std::{
 use async_trait::async_trait;
 use futures::stream::{FuturesUnordered, StreamExt};
 use smol::lock::Mutex;
-use tracing::{debug, error, info, warn};
+use tracing::{debug, error, warn};
 use url::Url;
 
 use super::{
@@ -53,6 +53,7 @@ use super::{
 };
 use crate::{
     system::{sleep, timeout::timeout, CondVar, StoppableTask, StoppableTaskPtr},
+    util::logger::verbose,
     Error, Result,
 };
 
@@ -81,7 +82,7 @@ impl OutboundSession {
     /// Start the outbound session. Runs the channel connect loop.
     pub(crate) async fn start(self: Arc<Self>) {
         let n_slots = self.p2p().settings().read().await.outbound_connections;
-        info!(target: "net::outbound_session", "[P2P] Starting {n_slots} outbound connection slots.");
+        verbose!(target: "net::outbound_session", "[P2P] Starting {n_slots} outbound connection slots.");
 
         // Activate mutex lock on connection slots.
         let mut slots = self.slots.lock().await;
@@ -296,7 +297,7 @@ impl Slot {
             let last_seen = addr.1;
             let slot = self.slot;
 
-            info!(
+            verbose!(
                 target: "net::outbound_session::try_connect()",
                 "[P2P] Connecting outbound slot #{slot} [{host}]"
             );
@@ -328,7 +329,7 @@ impl Slot {
             // At this point we've managed to connect.
             let stop_sub = channel.subscribe_stop().await?;
 
-            info!(
+            verbose!(
                 target: "net::outbound_session::try_connect()",
                 "[P2P] Outbound slot #{slot} connected [{}]",
                 channel.display_address()
@@ -344,7 +345,7 @@ impl Slot {
             if let Err(err) =
                 self.session().register_channel(channel.clone(), self.p2p().executor()).await
             {
-                info!(
+                verbose!(
                     target: "net::outbound_session",
                     "[P2P] Outbound slot #{slot} disconnected: {err}"
                 );
@@ -404,7 +405,7 @@ impl Slot {
             Ok((addr_final, channel)) => Ok((addr_final, channel)),
 
             Err(err) => {
-                info!(
+                verbose!(
                     target: "net::outbound_session::try_connect()",
                     "[P2P] Unable to connect outbound slot #{} {err}",
                     self.slot
@@ -549,7 +550,7 @@ impl PeerDiscoveryBase for PeerDiscovery {
             }
 
             if current_attempt >= 4 {
-                info!(
+                verbose!(
                     target: "net::outbound_session::peer_discovery()",
                     "[P2P] [PEER DISCOVERY] Sleeping and trying again. Attempt {current_attempt}"
                 );
@@ -569,7 +570,7 @@ impl PeerDiscoveryBase for PeerDiscovery {
             if self.p2p().is_connected() && current_attempt <= 2 {
                 // Broadcast the GetAddrs message to all active peers.
                 // If we have no active peers, we will perform a SeedSyncSession instead.
-                info!(
+                verbose!(
                     target: "net::outbound_session::peer_discovery()",
                     "[P2P] [PEER DISCOVERY] Asking peers for new peers to connect to...");
 
@@ -596,7 +597,7 @@ impl PeerDiscoveryBase for PeerDiscovery {
 
                 match result {
                     Ok(addrs_len) => {
-                        info!(
+                        verbose!(
                             target: "net::outbound_session::peer_discovery()",
                             "[P2P] [PEER DISCOVERY] Discovered {addrs_len} peers"
                         );
@@ -617,7 +618,7 @@ impl PeerDiscoveryBase for PeerDiscovery {
                 // de-allocated when the Session completes.
                 store_sub.unsubscribe().await;
             } else if !seeds.is_empty() {
-                info!(
+                verbose!(
                     target: "net::outbound_session::peer_discovery()",
                     "[P2P] [PEER DISCOVERY] Asking seeds for new peers to connect to...");
 

+ 4 - 3
src/net/session/seedsync_session.rs

@@ -51,7 +51,7 @@ use std::sync::{
 use async_trait::async_trait;
 use futures::stream::{FuturesUnordered, StreamExt};
 use smol::lock::{Mutex as AsyncMutex, RwLock as AsyncRwLock};
-use tracing::{debug, info, warn};
+use tracing::{debug, warn};
 use url::Url;
 
 use super::{
@@ -66,6 +66,7 @@ use super::{
 use crate::{
     net::hosts::HostState,
     system::{CondVar, StoppableTask, StoppableTaskPtr},
+    util::logger::verbose,
     Error,
 };
 
@@ -214,7 +215,7 @@ impl Slot {
 
             match self.connector.connect(&self.addr).await {
                 Ok((_, ch)) => {
-                    info!(
+                    verbose!(
                         target: "net::session::seedsync_session",
                         "[P2P] Connected seed [{}]",
                         ch.display_address()
@@ -224,7 +225,7 @@ impl Slot {
                         Ok(()) => {
                             self.failed.store(false, SeqCst);
 
-                            info!(
+                            verbose!(
                                 target: "net::session::seedsync_session",
                                 "[P2P] Disconnecting from seed [{}]",
                                 ch.display_address()

+ 3 - 3
src/net/transport/tor.rs

@@ -45,11 +45,11 @@ use tor_error::ErrorReport;
 use tor_hsservice::{HsNickname, RendRequest, RunningOnionService};
 use tor_proto::stream::IncomingStreamRequest;
 use tor_rtcompat::PreferredRuntime;
-use tracing::{debug, error, info, warn};
+use tracing::{debug, error, warn};
 use url::Url;
 
 use super::{PtListener, PtStream};
-use crate::util::path::expand_path;
+use crate::util::{logger::verbose, path::expand_path};
 
 /// A static for `TorClient` reusability
 static TOR_CLIENT: OnceCell<TorClient<PreferredRuntime>> = OnceCell::new();
@@ -236,7 +236,7 @@ impl TorListener {
             }
         };
 
-        info!(
+        verbose!(
             target: "net::tor::do_listen",
             "[P2P] Established Tor listener on tor://{}:{port}",
             onion_service.onion_address().unwrap()