Procházet zdrojové kódy

net: cleanup log targets

* downgrade most warn! and error! to verbose!
* upgrade a very select few (non-noisy, single print, user-facing info) from verbose! to info!
* fix a few log target style inconsistencies
* add some trace! statements to outbound_session::fetch_addrs
darkfi před 2 měsíci
rodič
revize
0d0bf837ad

+ 9 - 10
src/net/acceptor.rs

@@ -24,7 +24,6 @@ use std::{
     },
 };
 
-use tracing::warn;
 use url::Url;
 
 #[cfg(feature = "upnp-igd")]
@@ -165,7 +164,7 @@ impl Acceptor {
                 // These channels are the channels spawned below on listener.next().is_ok().
                 // After the notification, we reset the condvar and retry this loop to see
                 // if we can accept more connections, and if not - we'll be back here.
-                warn!(target: "net::acceptor::run_accept_loop", "Reached incoming conn limit, waiting...");
+                verbose!(target: "net::acceptor::run_accept_loop", "Reached incoming conn limit, waiting...");
                 cv.wait().await;
                 cv.reset();
                 continue
@@ -178,7 +177,7 @@ impl Acceptor {
                     if hosts.container.contains(HostColor::Black, &url) ||
                         hosts.block_all_ports(&url)
                     {
-                        warn!(target: "net::acceptor::run_accept_loop", "Peer {url} is blacklisted");
+                        verbose!(target: "net::acceptor::run_accept_loop", "Peer {url} is blacklisted");
                         continue
                     }
 
@@ -212,28 +211,28 @@ impl Acceptor {
                 Err(e) if e.raw_os_error().is_some() => match e.raw_os_error().unwrap() {
                     libc::EAGAIN | libc::ECONNABORTED | libc::EPROTO | libc::EINTR => continue,
                     libc::ECONNRESET => {
-                        warn!(
+                        verbose!(
                             target: "net::acceptor::run_accept_loop",
                             "[P2P] Connection reset by peer in accept_loop"
                         );
                         continue
                     }
                     libc::ETIMEDOUT => {
-                        warn!(
+                        verbose!(
                             target: "net::acceptor::run_accept_loop",
                             "[P2P] Connection timed out in accept_loop"
                         );
                         continue
                     }
                     libc::EPIPE => {
-                        warn!(
+                        verbose!(
                             target: "net::acceptor::run_accept_loop",
                             "[P2P] Broken pipe in accept_loop"
                         );
                         continue
                     }
                     x => {
-                        warn!(
+                        verbose!(
                             target: "net::acceptor::run_accept_loop",
                             "[P2P] Unhandled OS Error: {e} {x}"
                         );
@@ -248,7 +247,7 @@ impl Acceptor {
                 Err(e) if e.kind() == ErrorKind::Other => {
                     if let Some(inner) = std::error::Error::source(&e) {
                         if let Some(inner) = inner.downcast_ref::<futures_rustls::rustls::Error>() {
-                            warn!(
+                            verbose!(
                                 target: "net::acceptor::run_accept_loop",
                                 "[P2P] rustls listener error: {inner:?}"
                             );
@@ -256,7 +255,7 @@ impl Acceptor {
                         }
                     }
 
-                    warn!(
+                    verbose!(
                         target: "net::acceptor::run_accept_loop",
                         "[P2P] Unhandled ErrorKind::Other error: {e:?}"
                     );
@@ -265,7 +264,7 @@ impl Acceptor {
 
                 // Errors we didn't handle above:
                 Err(e) => {
-                    warn!(
+                    verbose!(
                         target: "net::acceptor::run_accept_loop",
                         "[P2P] Unhandled listener.next() error: {e}"
                     );

+ 8 - 8
src/net/channel.rs

@@ -35,7 +35,7 @@ use smol::{
     lock::{Mutex as AsyncMutex, OnceCell},
     Executor,
 };
-use tracing::{debug, error, trace, warn};
+use tracing::{debug, trace};
 use url::Url;
 
 use super::{
@@ -265,7 +265,7 @@ impl Channel {
         // Catch failure and stop channel, return a net error
         if let Err(e) = self.send_message(message).await {
             if self.session.upgrade().unwrap().type_id() & (SESSION_ALL & !SESSION_REFINE) != 0 {
-                error!(
+                verbose!(
                     target: "net::channel::send", "[P2P] Channel send error for [{self:?}]: {e}"
                 );
             }
@@ -337,7 +337,7 @@ impl Channel {
         trace!(target: "net::channel::read_command", "Read magic {magic:?}");
         let magic_bytes = self.p2p().settings().read().await.magic_bytes.0;
         if magic != magic_bytes {
-            error!(target: "net::channel::read_command", "Error: Magic bytes mismatch");
+            verbose!(target: "net::channel::read_command", "Error: Magic bytes mismatch");
 
             // If it is outbound, ban the host so we don't share it with other nodes
             if self.session_type_id() & SESSION_OUTBOUND != 0 {
@@ -352,7 +352,7 @@ impl Channel {
         // First extract the length from the stream
         let cmd_len = VarInt::decode_async(stream).await?.0;
         if cmd_len > (MAX_COMMAND_LENGTH as u64) {
-            error!(target: "net::channel::read_command",
+            verbose!(target: "net::channel::read_command",
                 "Error: Command length ({cmd_len}) exceeds configured limit ({MAX_COMMAND_LENGTH}). Dropping...");
             return Err(Error::MessageInvalid);
         }
@@ -432,7 +432,7 @@ impl Channel {
                         (SESSION_ALL & !SESSION_REFINE) !=
                         0
                     {
-                        error!(
+                        verbose!(
                             target: "net::channel::main_receive_loop",
                             "[P2P] Read error on channel {}: {err}",
                             self.display_address()
@@ -476,7 +476,7 @@ impl Channel {
                     // since it regularly forms connections with nodes sending
                     // messages it does not have dispatchers for.
                     if self.session.upgrade().unwrap().type_id() != SESSION_REFINE {
-                        warn!(
+                        verbose!(
                         target: "net::channel::main_receive_loop",
                         "MissingDispatcher|MessageInvalid|MeteringLimitExceeded for command={command}, channel={self:?}"
                         );
@@ -504,7 +504,7 @@ impl Channel {
         let peer = {
             if self.session_type_id() & SESSION_INBOUND != 0 {
                 if self.address().host().is_none() {
-                    error!("[P2P] ban() caught Url without host: {:?}", self.display_address());
+                    verbose!("[P2P] ban() caught Url without host: {:?}", self.display_address());
                     return
                 }
 
@@ -542,7 +542,7 @@ impl Channel {
                 verbose!(target: "net::channel::ban", "Peer={peer} blacklisted successfully");
             }
             Err(e) => {
-                warn!(target: "net::channel::ban", "Could not blacklisted peer={peer}, err={e}");
+                verbose!(target: "net::channel::ban", "Could not blacklist peer={peer}, err={e}");
             }
         }
         self.stop().await;

+ 2 - 3
src/net/connector.rs

@@ -26,7 +26,6 @@ use futures::{
     pin_mut,
 };
 use smol::lock::RwLock as AsyncRwLock;
-use tracing::warn;
 use url::Url;
 
 use super::{
@@ -36,7 +35,7 @@ use super::{
     settings::Settings,
     transport::Dialer,
 };
-use crate::{net::hosts::HostContainer, system::CondVar, Error, Result};
+use crate::{net::hosts::HostContainer, system::CondVar, util::logger::verbose, Error, Result};
 
 /// Create outbound socket connections
 pub struct Connector {
@@ -58,7 +57,7 @@ impl Connector {
     pub async fn connect(&self, url: &Url) -> Result<(Url, ChannelPtr)> {
         let hosts = self.session.upgrade().unwrap().p2p().hosts();
         if hosts.container.contains(HostColor::Black, url) || hosts.block_all_ports(url) {
-            warn!(target: "net::connector::connect", "Peer {url} is blacklisted");
+            verbose!(target: "net::connector::connect", "Peer {url} is blacklisted");
             return Err(Error::ConnectFailed(format!("[{url}]: Peer is blacklisted")));
         }
 

+ 4 - 4
src/net/hosts.rs

@@ -49,7 +49,7 @@ use std::{
     },
     time::{Instant, UNIX_EPOCH},
 };
-use tracing::{debug, error, warn};
+use tracing::debug;
 use url::{Host, Url};
 
 use super::{
@@ -484,7 +484,7 @@ impl HostContainer {
         let contents = match load_file(&path) {
             Ok(c) => c,
             Err(e) => {
-                warn!(target: "net::hosts::load_all", "[P2P] Failed retrieving saved hosts: {e}");
+                verbose!(target: "net::hosts::load_all", "[P2P] Failed retrieving saved hosts: {e}");
                 return Ok(())
             }
         };
@@ -542,7 +542,7 @@ impl HostContainer {
         if !tsv.is_empty() {
             verbose!(target: "net::hosts::save_all", "[P2P] Saving hosts to: {path:?}");
             if let Err(e) = save_file(&path, &tsv) {
-                error!(target: "net::hosts::save_all", "[P2P] Failed saving hosts: {e}");
+                verbose!(target: "net::hosts::save_all", "[P2P] Failed saving hosts: {e}");
             }
         }
 
@@ -782,7 +782,7 @@ impl Hosts {
         }
 
         if let Err(e) = self.try_register(address, HostState::Connected(channel.clone())) {
-            warn!(target: "net::hosts::register_channel", "[P2P] Error registering channel: {e:?}");
+            verbose!(target: "net::hosts::register_channel", "[P2P] Error registering channel: {e:?}");
             return
         }
 

+ 5 - 4
src/net/message_publisher.rs

@@ -22,12 +22,13 @@ use async_trait::async_trait;
 use futures::stream::{FuturesUnordered, StreamExt};
 use rand::{rngs::OsRng, Rng};
 use smol::{io::AsyncReadExt, lock::Mutex};
-use tracing::{debug, error};
+use tracing::debug;
 
 use super::message::Message;
 use crate::{
     net::{metering::MeteringQueue, transport::PtStream},
     system::{msleep, timeout::timeout},
+    util::logger::verbose,
     Error, Result,
 };
 use darkfi_serial::{AsyncDecodable, VarInt};
@@ -250,7 +251,7 @@ impl<M: Message> MessageDispatcherInterface for MessageDispatcher<M> {
         let length = match VarInt::decode_async(stream).await {
             Ok(int) => int.0,
             Err(err) => {
-                error!(
+                verbose!(
                     target: "net::message_publisher::trigger",
                     "Unable to decode VarInt. Dropping...: {err}"
                 );
@@ -260,7 +261,7 @@ impl<M: Message> MessageDispatcherInterface for MessageDispatcher<M> {
 
         // Check the message length does not exceed set limit
         if M::MAX_BYTES > 0 && length > M::MAX_BYTES {
-            error!(
+            verbose!(
                 target: "net::message_publisher::trigger",
                 "Message length ({length}) exceeds configured limit ({}). Dropping...",
                 M::MAX_BYTES
@@ -273,7 +274,7 @@ impl<M: Message> MessageDispatcherInterface for MessageDispatcher<M> {
         let message = match M::decode_async(&mut take).await {
             Ok(payload) => Ok(Arc::new(payload)),
             Err(err) => {
-                error!(
+                verbose!(
                     target: "net::message_publisher::trigger",
                     "Unable to decode data. Dropping...: {err}"
                 );

+ 6 - 6
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, warn};
+use tracing::{debug, error, info};
 use url::Url;
 
 use super::{
@@ -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);
-        verbose!(target: "net::p2p::start", "[P2P] Starting P2P subsystem");
+        info!(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;
 
-        verbose!(target: "net::p2p::start", "[P2P] P2P subsystem started successfully");
+        info!(target: "net::p2p::start", "[P2P] P2P subsystem started successfully");
         Ok(())
     }
 
@@ -296,13 +296,13 @@ impl P2p {
     /// Enable network debugging
     pub fn dnet_enable(&self) {
         self.dnet_enabled.store(true, Ordering::SeqCst);
-        warn!("[P2P] Network debugging enabled!");
+        verbose!("[P2P] Network debugging enabled!");
     }
 
     /// Disable network debugging
     pub fn dnet_disable(&self) {
         self.dnet_enabled.store(false, Ordering::SeqCst);
-        warn!("[P2P] Network debugging disabled!");
+        verbose!("[P2P] Network debugging disabled!");
     }
 
     /// Subscribe to dnet events
@@ -333,7 +333,7 @@ async fn broadcast_serialized_to<M: Message>(
             channel
                 .send_serialized(&message, &M::METERING_SCORE, &M::METERING_CONFIGURATION)
                 .map_err(|e| {
-                    error!(
+                    verbose!(
                         target: "net::p2p::broadcast",
                         "[P2P] Broadcasting message to {} failed: {e}",
                         channel.display_address()

+ 7 - 7
src/net/protocol/protocol_holepunch.rs

@@ -35,7 +35,7 @@ use async_trait::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use rand::{rngs::OsRng, Rng};
 use smol::{lock::Mutex as AsyncMutex, Executor};
-use tracing::{debug, info, warn};
+use tracing::debug;
 use url::Url;
 
 use crate::{
@@ -45,7 +45,7 @@ use crate::{
         P2pPtr, ProtocolBase, ProtocolBasePtr, ProtocolJobsManager, ProtocolJobsManagerPtr,
     },
     system::{sleep, timeout::timeout},
-    util::time::NanoTimestamp,
+    util::{logger::verbose, time::NanoTimestamp},
     Error, Result,
 };
 
@@ -303,7 +303,7 @@ impl ProtocolHolepunch {
 
             // Replay protection
             if !self.check_nonce(req.nonce).await {
-                warn!(
+                verbose!(
                     target: "net::protocol_holepunch::handle_relay_requests",
                     "[QUIC-NAT-RELAY] Rejecting: nonce replay",
                 );
@@ -312,7 +312,7 @@ impl ProtocolHolepunch {
 
             // Address verification
             if !self.verify_claimed_addrs(&req.our_addrs) {
-                warn!(
+                verbose!(
                     target: "net::protocol_holepunch::handle_relay_requests",
                     "[QUIC-NAT-RELAY] Rejecting: addr verification failed",
                 );
@@ -322,7 +322,7 @@ impl ProtocolHolepunch {
             // Rate limiting
             let Some(peer_ip) = Self::get_ip(self.channel.address()) else { continue };
             if !self.check_rate_limit(peer_ip).await {
-                warn!(
+                verbose!(
                     target: "net::protocol_holepunch::handle_relay_requests",
                     "[QUIC-NAT-RELAY] Rejecting: ratelimit for {}", peer_ip,
                 );
@@ -382,7 +382,7 @@ impl ProtocolHolepunch {
                 continue
             }
 
-            info!(
+            verbose!(
                 target: "net::protocol_holepunch::handle_relay_requests",
                 "[QUIC-NAT-RELAY] Relayed punch {} <-> {}",
                 self.channel.display_address(),
@@ -438,7 +438,7 @@ impl ProtocolHolepunch {
                     // Connect
                     match p2p.session_direct().get_channel(&observed).await {
                         Ok(chan) => {
-                            info!(
+                            verbose!(
                                 target: "net::protocol_holepunch::handle_connect_instructions",
                                 "[QUIC-NAT-CONNECT] Punch succeeded: {}", chan.display_address(),
                             );

+ 4 - 3
src/net/protocol/protocol_ping.rs

@@ -24,7 +24,7 @@ use std::{
 use async_trait::async_trait;
 use rand::{rngs::OsRng, Rng};
 use smol::{lock::RwLock as AsyncRwLock, Executor};
-use tracing::{debug, error, warn};
+use tracing::debug;
 
 use super::{
     super::{
@@ -39,6 +39,7 @@ use super::{
 };
 use crate::{
     system::{sleep, timeout::timeout},
+    util::logger::verbose,
     Error, Result,
 };
 
@@ -116,7 +117,7 @@ impl ProtocolPing {
                 Err(_e) => {
                     // Pong timeout. We didn't receive any message back
                     // so close the connection.
-                    warn!(
+                    verbose!(
                         target: "net::protocol_ping::run_ping_pong",
                         "[P2P] Ping-Pong protocol timed out for {}", self.channel.display_address(),
                     );
@@ -126,7 +127,7 @@ impl ProtocolPing {
             };
 
             if pong_msg.nonce != nonce {
-                error!(
+                verbose!(
                     target: "net::protocol_ping::run_ping_pong",
                     "[P2P] Wrong nonce in pingpong, disconnecting {}",
                     self.channel.display_address(),

+ 7 - 6
src/net/protocol/protocol_version.rs

@@ -25,7 +25,7 @@ use std::{
     sync::Arc,
     time::{Duration, UNIX_EPOCH},
 };
-use tracing::{debug, error};
+use tracing::debug;
 
 use super::super::{
     channel::ChannelPtr,
@@ -35,6 +35,7 @@ use super::super::{
 };
 use crate::{
     net::{session::SESSION_OUTBOUND, BanPolicy},
+    util::logger::verbose,
     Error, Result,
 };
 
@@ -89,7 +90,7 @@ impl ProtocolVersion {
                 Ok(())
             }
             Either::Left((Err(e), _)) => {
-                error!(
+                verbose!(
                     target: "net::protocol_version::run",
                     "[P2P] Version Exchange failed [{}]: {e}",
                     self.channel.display_address()
@@ -100,7 +101,7 @@ impl ProtocolVersion {
             }
 
             Either::Right((_, _)) => {
-                error!(
+                verbose!(
                     target: "net::protocol_version::run",
                     "[P2P] Version Exchange timed out [{}]",
                     self.channel.display_address(),
@@ -124,7 +125,7 @@ impl ProtocolVersion {
 
         let rets = join_all(vec![send, recv]).await;
         if let Err(e) = &rets[0] {
-            error!(
+            verbose!(
                 target: "net::protocol_version::exchange_versions",
                 "send_version() failed: {e}"
             );
@@ -132,7 +133,7 @@ impl ProtocolVersion {
         }
 
         if let Err(e) = &rets[1] {
-            error!(
+            verbose!(
                 target: "net::protocol_version::exchange_versions",
                 "recv_version() failed: {e}"
             );
@@ -192,7 +193,7 @@ impl ProtocolVersion {
             app_version.minor != verack_msg.app_version.minor ||
             app_name != verack_msg.app_name
         {
-            error!(
+            verbose!(
                 target: "net::protocol_version::send_version",
                 "[P2P] Version mismatch from {}. Disconnecting...",
                 self.channel.display_address(),

+ 10 - 10
src/net/session/direct_session.rs

@@ -35,7 +35,7 @@ use std::{
 
 use async_trait::async_trait;
 use smol::lock::{Mutex as AsyncMutex, OnceCell};
-use tracing::{error, warn};
+use tracing::{info, warn};
 use url::Url;
 
 use super::{
@@ -242,7 +242,7 @@ impl DirectSession {
                 match res {
                     Ok(()) | Err(Error::DetachedTaskStopped) => { /* Do nothing */ }
                     Err(e) => {
-                        error!(target: "net::direct_session::get_channel_with_retries", "{e}")
+                        verbose!(target: "net::direct_session::get_channel_with_retries", "{e}")
                     }
                 }
             },
@@ -272,7 +272,7 @@ impl DirectSession {
         // Do not establish a connection to a host that is also configured as a seed.
         // This indicates a user misconfiguration.
         if seeds.contains(&addr) {
-            error!(
+            verbose!(
                 target: "net::direct_session",
                 "[P2P] Suspending direct connection to seed [{}]", addr.clone(),
             );
@@ -283,8 +283,8 @@ impl DirectSession {
         let hosts = self.p2p().hosts();
         let external_addrs = hosts.external_addrs().await;
         if external_addrs.contains(&addr) {
-            warn!(
-                target: "net::hosts::check_addrs",
+            verbose!(
+                target: "net::direct_session",
                 "[P2P] Suspending direct connection to external addr [{}]", addr.clone(),
             );
             return Err(Error::ConnectFailed(format!(
@@ -314,7 +314,7 @@ impl DirectSession {
                     }
                 }
 
-                error!(target: "net::direct_session",
+                verbose!(target: "net::direct_session",
                     "[P2P] Cannot connect to direct={addr}, err={e}");
                 return Err(e)
             }
@@ -328,7 +328,7 @@ impl DirectSession {
         // Attempt channel creation
         match self.connector.get().unwrap().connect(&addr).await {
             Ok((_, channel)) => {
-                verbose!(
+                info!(
                     target: "net::direct_session",
                     "[P2P] Direct outbound connected [{}]",
                     channel.display_address()
@@ -344,7 +344,7 @@ impl DirectSession {
                 match self.register_channel(channel.clone(), self.p2p().executor()).await {
                     Ok(()) => Ok(channel),
                     Err(e) => {
-                        warn!(
+                        verbose!(
                             target: "net::direct_session",
                             "[P2P] Unable to connect to direct outbound [{}]: {e}",
                             channel.display_address(),
@@ -357,7 +357,7 @@ impl DirectSession {
 
                         // Free up this addr for future operations.
                         if let Err(e) = self.p2p().hosts().unregister(channel.address()) {
-                            warn!(target: "net::direct_session", "[P2P] Error while unregistering addr={}, err={e}", channel.display_address());
+                            verbose!(target: "net::direct_session", "[P2P] Error while unregistering addr={}, err={e}", channel.display_address());
                         }
 
                         Err(e)
@@ -377,7 +377,7 @@ impl DirectSession {
 
                 // Free up this addr for future operations.
                 if let Err(e) = self.p2p().hosts().unregister(&addr) {
-                    warn!(target: "net::direct_session", "[P2P] Error while unregistering addr={addr}, err={e}");
+                    verbose!(target: "net::direct_session", "[P2P] Error while unregistering addr={addr}, err={e}");
                 }
 
                 Err(e)

+ 4 - 4
src/net/session/inbound_session.rs

@@ -27,7 +27,7 @@ use std::sync::{Arc, Weak};
 
 use async_trait::async_trait;
 use smol::lock::Mutex;
-use tracing::{debug, error, warn};
+use tracing::{debug, info};
 use url::Url;
 
 use super::{
@@ -138,11 +138,11 @@ impl InboundSession {
         acceptor: AcceptorPtr,
         ex: ExecutorPtr,
     ) -> Result<()> {
-        verbose!(target: "net::inbound_session", "[P2P] Starting Inbound session #{index} on {accept_addr}");
+        info!(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 {
-            error!(target: "net::inbound_session", "[P2P] Error starting listener #{index}: {e}");
+            verbose!(target: "net::inbound_session", "[P2P] Error starting listener #{index}: {e}");
             acceptor.stop().await;
         } else {
             self.acceptors.lock().await.push(acceptor);
@@ -195,7 +195,7 @@ impl InboundSession {
                 }
             }
             Err(e) => {
-                warn!(
+                verbose!(
                     target: "net::inbound_session::setup_channel",
                     "Channel setup failed! Err={e}"
                 );

+ 6 - 6
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, warn};
+use tracing::{debug, info, warn};
 use url::Url;
 
 use super::{
@@ -141,7 +141,7 @@ impl Slot {
             |res| async {
                 match res {
                     Ok(()) | Err(Error::NetworkServiceStopped) => {}
-                    Err(e) => error!("net::manual_session {e}"),
+                    Err(e) => verbose!("net::manual_session {e}"),
                 }
             },
             Error::NetworkServiceStopped,
@@ -171,7 +171,7 @@ impl Slot {
             // Do not establish a connection to a host that is also configured as a seed.
             // This indicates a user misconfiguration.
             if seeds.contains(&self.addr) {
-                error!(
+                verbose!(
                     target: "net::manual_session",
                     "[P2P] Suspending manual connection to seed [{}]", self.addr.clone(),
                 );
@@ -189,7 +189,7 @@ impl Slot {
 
             match self.connector.connect(&self.addr).await {
                 Ok((_, channel)) => {
-                    verbose!(
+                    info!(
                         target: "net::manual_session",
                         "[P2P] Manual outbound connected [{}]",
                         channel.display_address()
@@ -220,7 +220,7 @@ impl Slot {
 
                             // Free up this addr for future operations.
                             if let Err(e) = self.p2p().hosts().unregister(channel.address()) {
-                                warn!(target: "net::manual_session", "[P2P] Error while unregistering addr={}, err={e}", channel.display_address());
+                                verbose!(target: "net::manual_session", "[P2P] Error while unregistering addr={}, err={e}", channel.display_address());
                             }
                         }
                     }
@@ -233,7 +233,7 @@ impl Slot {
 
                     // Free up this addr for future operations.
                     if let Err(e) = self.p2p().hosts().unregister(&self.addr) {
-                        warn!(target: "net::manual_session", "[P2P] Error while unregistering addr={}, err={e}", self.addr);
+                        verbose!(target: "net::manual_session", "[P2P] Error while unregistering addr={}, err={e}", self.addr);
                     }
                 }
             }

+ 4 - 4
src/net/session/mod.rs

@@ -23,7 +23,7 @@ use std::{
 
 use async_trait::async_trait;
 use smol::Executor;
-use tracing::{debug, error, trace};
+use tracing::{debug, trace};
 
 use super::{
     channel::ChannelPtr,
@@ -95,12 +95,12 @@ pub async fn remove_sub_on_stop(
         match hosts.fetch_last_seen(addr) {
             Some(last_seen) => {
                 if let Err(e) = hosts.move_host(addr, last_seen, HostColor::Grey).await {
-                    error!(target: "net::session::remove_sub_on_stop",
+                    verbose!(target: "net::session::remove_sub_on_stop",
             "Failed to move host {} to Greylist! Err={e}", channel.display_address());
                 }
             }
             None => {
-                error!(target: "net::session::remove_sub_on_stop",
+                verbose!(target: "net::session::remove_sub_on_stop",
                "Failed to fetch last seen for {}", channel.display_address());
             }
         }
@@ -112,7 +112,7 @@ pub async fn remove_sub_on_stop(
     // happens in the refinery directly.
     if type_id & SESSION_REFINE == 0 {
         if let Err(e) = hosts.unregister(channel.address()) {
-            error!(target: "net::session::remove_sub_on_stop", "Error while unregistering addr={}, err={e}", channel.display_address());
+            verbose!(target: "net::session::remove_sub_on_stop", "Error while unregistering addr={}, err={e}", channel.display_address());
         }
     }
 

+ 13 - 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, info, trace};
 use url::Url;
 
 use super::{
@@ -82,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;
-        verbose!(target: "net::outbound_session", "[P2P] Starting {n_slots} outbound connection slots.");
+        info!(target: "net::outbound_session", "[P2P] Starting {n_slots} outbound connection slots.");
 
         // Activate mutex lock on connection slots.
         let mut slots = self.slots.lock().await;
@@ -161,7 +161,7 @@ impl OutboundSession {
             slot.clone().start().await;
             slots.push(slot);
         }
-        info!(target: "net::outbound_session",
+        verbose!(target: "net::outbound_session",
             "[P2P] Increased outbound slots from {slots_len} to {target}");
     }
 
@@ -193,7 +193,7 @@ impl OutboundSession {
             removed += 1;
         }
 
-        info!(target: "net::outbound_session",
+        verbose!(target: "net::outbound_session",
             "[P2P] Decreased outbound slots from {slots_len} to {target}");
     }
 }
@@ -246,7 +246,7 @@ impl Slot {
             |res| async {
                 match res {
                     Ok(()) | Err(Error::NetworkServiceStopped) => {}
-                    Err(e) => error!("net::outbound_session {e}"),
+                    Err(e) => verbose!("net::outbound_session {e}"),
                 }
             },
             Error::NetworkServiceStopped,
@@ -298,6 +298,7 @@ impl Slot {
         {
             addrs.push(addr);
         }
+        trace!(target: "net::outbound_session::fetch_addrs", "[P2P] fetch_addrs: collected {} gold addrs", addrs.len());
 
         // Add white to fill remaining known slots
         let remaining_known = known_count - addrs.len();
@@ -306,6 +307,7 @@ impl Slot {
         {
             addrs.push(addr);
         }
+        trace!(target: "net::outbound_session::fetch_addrs", "[P2P] fetch_addrs: collected {} white addrs (total: {})", remaining_known, addrs.len());
 
         // Add grey to fill remaining slots
         if !disable_greys {
@@ -315,6 +317,7 @@ impl Slot {
             {
                 addrs.push(addr);
             }
+            trace!(target: "net::outbound_session::fetch_addrs", "[P2P] fetch_addrs: collected {} grey addrs (total: {})", remaining, addrs.len());
         }
 
         hosts.check_addrs(addrs).await
@@ -436,7 +439,7 @@ impl Slot {
 
                 self.channel_id.store(0, Ordering::Relaxed);
 
-                warn!(
+                verbose!(
                     target: "net::outbound_session::try_connect",
                     "[P2P] Suspending addr=[{}] slot #{slot}",
                     channel.display_address()
@@ -449,7 +452,7 @@ impl Slot {
                     .move_host(channel.address(), last_seen, HostColor::Grey)
                     .await
                 {
-                    warn!(target: "net::outbound_session", "Error while moving addr={} to greylist: {e}", channel.display_address());
+                    verbose!(target: "net::outbound_session", "Error while moving addr={} to greylist: {e}", channel.display_address());
                     continue
                 }
 
@@ -457,7 +460,7 @@ impl Slot {
                 if let Err(e) =
                     self.p2p().hosts().try_register(channel.address().clone(), HostState::Suspend)
                 {
-                    warn!(target: "net::outbound_session", "Error while suspending addr={}: {e}", channel.display_address());
+                    verbose!(target: "net::outbound_session", "Error while suspending addr={}: {e}", channel.display_address());
                 }
 
                 continue
@@ -502,7 +505,7 @@ impl Slot {
 
                 // Mark its state as Suspend, which sends it to the Refinery for processing.
                 if let Err(e) = self.p2p().hosts().try_register(addr.clone(), HostState::Suspend) {
-                    warn!(target: "net::outbound_session::try_connect", "Error while suspending addr={addr}: {e}");
+                    verbose!(target: "net::outbound_session::try_connect", "Error while suspending addr={addr}: {e}");
                 }
 
                 // Notify that channel processing failed
@@ -694,7 +697,7 @@ impl PeerDiscoveryBase for PeerDiscovery {
                 store_sub.unsubscribe().await;
             } else if !seeds.is_empty() {
                 // Not connected, do seed sync
-                verbose!(
+                debug!(
                     target: "net::outbound_session::peer_discovery",
                     "[P2P] [PEER DISCOVERY] Not connected, asking seeds for new peers to connect to..."
                 );

+ 9 - 8
src/net/session/refine_session.rs

@@ -36,7 +36,7 @@ use std::{
 };
 
 use async_trait::async_trait;
-use tracing::{debug, error, warn};
+use tracing::debug;
 use url::Url;
 
 use super::super::p2p::{P2p, P2pPtr};
@@ -49,6 +49,7 @@ use crate::{
         session::{Session, SessionBitFlag, SESSION_REFINE},
     },
     system::{sleep, StoppableTask, StoppableTaskPtr},
+    util::logger::verbose,
     Error,
 };
 
@@ -75,7 +76,7 @@ impl RefineSession {
                     debug!(target: "net::refine_session::start", "Load hosts successful!");
                 }
                 Err(e) => {
-                    warn!(target: "net::refine_session::start", "Error loading hosts {e}");
+                    verbose!(target: "net::refine_session::start", "Error loading hosts {e}");
                 }
             }
         }
@@ -85,7 +86,7 @@ impl RefineSession {
                 debug!(target: "net::refine_session::start", "Import blacklist successful!");
             }
             Err(e) => {
-                warn!(target: "net::refine_session::start",
+                verbose!(target: "net::refine_session::start",
                     "Error importing blacklist from config file {e}");
             }
         }
@@ -105,7 +106,7 @@ impl RefineSession {
                     debug!(target: "net::refine_session::stop", "Save hosts successful!");
                 }
                 Err(e) => {
-                    warn!(target: "net::refine_session::stop", "Error saving hosts {e}");
+                    verbose!(target: "net::refine_session::stop", "Error saving hosts {e}");
                 }
             }
         }
@@ -254,7 +255,7 @@ impl GreylistRefinery {
             let offline_timer = { Instant::now().duration_since(*hosts.last_connection.lock()) };
 
             if !self.p2p().is_connected() && offline_timer >= offline_limit {
-                warn!(target: "net::refinery", "No connections for {}s. GreylistRefinery paused.",
+                verbose!(target: "net::refinery", "No connections for {}s. GreylistRefinery paused.",
                           offline_timer.as_secs());
 
                 // It is necessary to Free suspended hosts at this point, otherwise these
@@ -264,7 +265,7 @@ impl GreylistRefinery {
                 let suspended_hosts = hosts.suspended();
                 for host in suspended_hosts {
                     if let Err(e) = hosts.unregister(&host) {
-                        warn!(target: "net::refinery", "Error while unregistering addr={host}, err={e}");
+                        verbose!(target: "net::refinery", "Error while unregistering addr={host}, err={e}");
                     }
                 }
 
@@ -289,7 +290,7 @@ impl GreylistRefinery {
 
                         // Free up this addr for future operations.
                         if let Err(e) = hosts.unregister(&url) {
-                            warn!(target: "net::refinery", "Error while unregistering addr={url}, err={e}");
+                            verbose!(target: "net::refinery", "Error while unregistering addr={url}, err={e}");
                         }
 
                         continue
@@ -301,7 +302,7 @@ impl GreylistRefinery {
                     let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
 
                     if let Err(e) = hosts.whitelist_host(&url, last_seen).await {
-                        error!(target: "net::refinery", "Could not send {url} to the whitelist: {e}");
+                        verbose!(target: "net::refinery", "Could not send {url} to the whitelist: {e}");
                     }
 
                     debug!(target: "net::refinery", "GreylistRefinery complete!");

+ 9 - 9
src/net/session/seedsync_session.rs

@@ -202,11 +202,11 @@ impl Slot {
             self.wait().await;
 
             debug!(
-                target: "net::session::seedsync_session", "SeedSyncSession::start_seed() [START]",
+                target: "net::seedsync_session", "SeedSyncSession::start_seed() [START]",
             );
 
             if let Err(e) = hosts.try_register(self.addr.clone(), HostState::Connect) {
-                debug!(target: "net::session::seedsync_session",
+                debug!(target: "net::seedsync_session",
                     "Cannot connect to seed={}, err={e}", &self.addr);
 
                 // Reset the CondVar for future use.
@@ -218,7 +218,7 @@ impl Slot {
             match self.connector.connect(&self.addr).await {
                 Ok((_, ch)) => {
                     verbose!(
-                        target: "net::session::seedsync_session",
+                        target: "net::seedsync_session",
                         "[P2P] Connected seed [{}]",
                         ch.display_address()
                     );
@@ -228,7 +228,7 @@ impl Slot {
                             self.failed.store(false, SeqCst);
 
                             verbose!(
-                                target: "net::session::seedsync_session",
+                                target: "net::seedsync_session",
                                 "[P2P] Disconnecting from seed [{}]",
                                 ch.display_address()
                             );
@@ -236,7 +236,7 @@ impl Slot {
 
                             // Seed process complete
                             if hosts.container.is_empty(HostColor::Grey) {
-                                verbose!(target: "net::session::seedsync_session",
+                                verbose!(target: "net::seedsync_session",
                                 "[P2P] Greylist empty after seeding");
                             }
 
@@ -246,7 +246,7 @@ impl Slot {
 
                         Err(e) => {
                             warn!(
-                                target: "net::session::seedsync_session",
+                                target: "net::seedsync_session",
                                 "[P2P] Unable to connect to seed [{}]: {e}",
                                 ch.display_address()
                             );
@@ -259,7 +259,7 @@ impl Slot {
 
                 Err(e) => {
                     warn!(
-                        target: "net::session::seedsync_session",
+                        target: "net::seedsync_session",
                         "[P2P] Unable to connect to seed: {e}",
                     );
                     self.handle_failure(&self.addr);
@@ -268,7 +268,7 @@ impl Slot {
                 }
             }
             debug!(
-                target: "net::session::seedsync_session",
+                target: "net::seedsync_session",
                 "SeedSyncSession::start_seed() [END]",
             );
         }
@@ -279,7 +279,7 @@ impl Slot {
 
         // Free up this addr for future operations.
         if let Err(e) = self.p2p().hosts().unregister(addr) {
-            warn!(target: "net::session::seedsync_session", "[P2P] Error while unregistering addr={addr}, err={e}");
+            verbose!(target: "net::seedsync_session", "[P2P] Error while unregistering addr={addr}, err={e}");
         }
 
         // Reset the CondVar for future use.

+ 4 - 3
src/net/transport/mod.rs

@@ -20,9 +20,10 @@ use std::{io, time::Duration};
 
 use async_trait::async_trait;
 use smol::io::{AsyncRead, AsyncWrite};
-use tracing::error;
 use url::Url;
 
+use crate::util::logger::verbose;
+
 #[cfg(feature = "p2p-unix")]
 use std::io::ErrorKind;
 
@@ -264,7 +265,7 @@ impl Dialer {
             }
 
             x => {
-                error!("[P2P] Requested unsupported transport: {x}");
+                verbose!("[P2P] Requested unsupported transport: {x}");
                 Err(io::Error::from_raw_os_error(libc::ENETUNREACH))
             }
         }
@@ -414,7 +415,7 @@ impl Listener {
             }
 
             x => {
-                error!("[P2P] Requested unsupported transport: {x}");
+                verbose!("[P2P] Requested unsupported transport: {x}");
                 Err(io::Error::from_raw_os_error(libc::ENETUNREACH))
             }
         }

+ 8 - 7
src/net/transport/tls.rs

@@ -30,12 +30,13 @@ use futures_rustls::{
     TlsAcceptor, TlsConnector, TlsStream,
 };
 use rcgen::string::Ia5String;
-use tracing::error;
 use x509_parser::{
     parse_x509_certificate,
     prelude::{GeneralName, ParsedExtension, X509Certificate},
 };
 
+use crate::util::logger::verbose;
+
 /// The DNS name used for certificate validation across all transports
 pub(crate) const TLS_DNS_NAME: &str = "dark.fi";
 
@@ -83,22 +84,22 @@ fn verify_ed25519_signature(
 
     // Parse the cert and extract the public key
     let Ok((_, cert)) = parse_x509_certificate(&buf) else {
-        error!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed parsing TLS certificate");
+        verbose!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed parsing TLS certificate");
         return Err(rustls::CertificateError::BadEncoding.into())
     };
 
     let Ok(public_key) = ed25519_compact::PublicKey::from_der(cert.public_key().raw) else {
-        error!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed parsing public key");
+        verbose!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed parsing public key");
         return Err(rustls::CertificateError::BadEncoding.into())
     };
 
     let Ok(signature) = ed25519_compact::Signature::from_slice(dss.signature()) else {
-        error!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed verifying signature");
+        verbose!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed verifying signature");
         return Err(rustls::CertificateError::BadSignature.into())
     };
 
     if let Err(e) = public_key.verify(message, &signature) {
-        error!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed verifying signature: {e}");
+        verbose!(target: "net::tls::verify_ed25519_signature", "[net::tls] Failed verifying signature: {e}");
         return Err(rustls::CertificateError::BadSignature.into())
     }
 
@@ -122,7 +123,7 @@ impl ServerCertVerifier for ServerCertificateVerifier {
 
         // Parse the certificate
         let Ok((_, cert)) = parse_x509_certificate(&buf) else {
-            error!(target: "net::tls::verify_server_cert", "[net::tls] Failed parsing server TLS certificate");
+            verbose!(target: "net::tls::verify_server_cert", "[net::tls] Failed parsing server TLS certificate");
             return Err(rustls::CertificateError::BadEncoding.into())
         };
 
@@ -182,7 +183,7 @@ impl ClientCertVerifier for ClientCertificateVerifier {
 
         // Parse the certificate
         let Ok((_, cert)) = parse_x509_certificate(&buf) else {
-            error!(target: "net::tls::verify_server_cert", "[net::tls] Failed parsing server TLS certificate");
+            verbose!(target: "net::tls::verify_server_cert", "[net::tls] Failed parsing server TLS certificate");
             return Err(rustls::CertificateError::BadEncoding.into())
         };
 

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

@@ -45,7 +45,7 @@ use tor_error::ErrorReport;
 use tor_hsservice::{HsNickname, RendRequest, RunningOnionService};
 use tor_proto::client::stream::IncomingStreamRequest;
 use tor_rtcompat::PreferredRuntime;
-use tracing::{debug, error, warn};
+use tracing::debug;
 use url::Url;
 
 use super::{PtListener, PtStream};
@@ -101,7 +101,7 @@ impl TorDialer {
         {
             Ok(client) => client.isolated_client(),
             Err(e) => {
-                warn!(target: "net::tor::TorDialer", "{}", e.report());
+                verbose!(target: "net::tor::TorDialer", "{}", e.report());
                 return Err(io::Error::other("Internal Tor error, see logged warning"));
             }
         };
@@ -135,7 +135,7 @@ impl TorDialer {
                     Either::Left((Ok(stream), _)) => Ok(stream),
 
                     Either::Left((Err(e), _)) => {
-                        warn!(target: "net::tor::do_dial", "{}", e.report());
+                        verbose!(target: "net::tor::do_dial", "{}", e.report());
                         Err(io::Error::other("Internal Tor error, see logged warning"))
                     }
 
@@ -151,7 +151,7 @@ impl TorDialer {
                         // from arti-client in order to help debug Tor connections.
                         // https://docs.rs/arti-client/latest/arti_client/#reporting-arti-errors
                         // https://gitlab.torproject.org/tpo/core/arti/-/issues/1086
-                        warn!(target: "net::tor::do_dial", "{}", e.report());
+                        verbose!(target: "net::tor::do_dial", "{}", e.report());
                         Err(io::Error::other("Internal Tor error, see logged warning"))
                     }
                 }
@@ -207,7 +207,7 @@ impl TorListener {
         {
             Ok(client) => client.isolated_client(),
             Err(e) => {
-                warn!(target: "net::tor::do_listen", "{}", e.report());
+                verbose!(target: "net::tor::do_listen", "{}", e.report());
                 return Err(io::Error::other("Internal Tor error, see logged warning"));
             }
         };
@@ -217,7 +217,7 @@ impl TorListener {
         let hs_config = match OnionServiceConfigBuilder::default().nickname(hs_nick).build() {
             Ok(v) => v,
             Err(e) => {
-                error!(
+                verbose!(
                     target: "net::tor::do_listen",
                     "[P2P] Failed to create OnionServiceConfig: {e}"
                 );
@@ -228,14 +228,14 @@ impl TorListener {
         let (onion_service, rendreq_stream) = match client.launch_onion_service(hs_config) {
             Ok(Some(v)) => v,
             Ok(None) => {
-                error!(
+                verbose!(
                     target: "net::tor::do_listen",
                     "[P2P] Onion service disabled in config",
                 );
                 return Err(io::Error::other("Internal Tor error"));
             }
             Err(e) => {
-                error!(
+                verbose!(
                     target: "net::tor::do_listen",
                     "[P2P] Failed to launch Onion Service: {e}"
                 );
@@ -286,7 +286,7 @@ impl PtListener for TorListenerIntern {
         let mut streamreq_stream = match rendrequest.accept().await {
             Ok(v) => v,
             Err(e) => {
-                error!(
+                verbose!(
                     target: "net::tor::PtListener::next",
                     "[P2P] Failed accepting Tor RendRequest: {e}"
                 );
@@ -311,7 +311,7 @@ impl PtListener for TorListenerIntern {
         let stream = match streamrequest.accept(Connected::new_empty()).await {
             Ok(v) => v,
             Err(e) => {
-                error!(
+                verbose!(
                     target: "net::tor::PtListener::next",
                     "[P2P] Failed accepting Tor StreamRequest: {e}"
                 );

+ 3 - 3
src/net/upnp.rs

@@ -287,13 +287,13 @@ impl PortMapping for UpnpPortMapping {
                 match result {
                     Ok(()) => {
                         // Should never complete normally
-                        error!("[P2P] UPnP task completed unexpectedly");
+                        verbose!("[P2P] UPnP task completed unexpectedly");
                     }
                     Err(Error::NetworkServiceStopped) => {
                         // Expected when stopping
                     }
                     Err(e) => {
-                        error!("[P2P] UPnP task error: {e}");
+                        verbose!("[P2P] UPnP task error: {e}");
                     }
                 }
             },
@@ -400,7 +400,7 @@ pub fn setup_port_mappings(
     let Some(mapping) = create_upnp_from_url(actual_endpoint) else { return vec![] };
 
     if let Err(e) = Arc::clone(&mapping).start(settings.clone(), ex.clone()) {
-        error!(
+        verbose!(
             target: "net::upnp",
             "[P2P] UPnP port mapping: Failed to start for {}: {e}",
             actual_endpoint

+ 2 - 2
src/util/logger.rs

@@ -51,10 +51,10 @@ use crate::{util::time::DateTime, Error, Result};
 #[macro_export]
 macro_rules! verbose {
     (target: $target:expr, $($arg:tt)*) => {
-        tracing::info!(target: $target, verbose=true, $($arg)*);
+        tracing::info!(target: $target, verbose=true, $($arg)*)
     };
     ($($arg:tt)*) => {
-        tracing::info!(verbose=true, $($arg)*);
+        tracing::info!(verbose=true, $($arg)*)
     };
 }