diff --git a/cmd/ethrex/initializers.rs b/cmd/ethrex/initializers.rs index 8fa4abfd58..a823dce12a 100644 --- a/cmd/ethrex/initializers.rs +++ b/cmd/ethrex/initializers.rs @@ -55,22 +55,21 @@ pub fn init_tracing(opts: &Options) -> reload::Handle { let (filter, filter_handle) = reload::Layer::new(log_filter); - let mut layer = fmt::layer(); + let stdout_is_tty = std::io::stdout().is_terminal(); + let use_color = match opts.log_color { + LogColor::Always => true, + LogColor::Never => false, + LogColor::Auto => stdout_is_tty, + }; - if opts.log_color == LogColor::Never - || (opts.log_color == LogColor::Auto && !std::io::stdout().is_terminal()) - { - layer = layer.with_ansi(false); - } + let fmt_layer = fmt::layer() + .with_target(false) + .with_ansi(use_color) + .with_filter(filter); - let fmt_layer = layer.with_filter(filter); + let profiling_layer = opts.metrics_enabled.then_some(FunctionProfilingLayer); - let subscriber: Box = if opts.metrics_enabled { - let profiling_layer = FunctionProfilingLayer; - Box::new(Registry::default().with(fmt_layer).with(profiling_layer)) - } else { - Box::new(Registry::default().with(fmt_layer)) - }; + let subscriber = Registry::default().with(fmt_layer).with(profiling_layer); tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed"); diff --git a/crates/blockchain/blockchain.rs b/crates/blockchain/blockchain.rs index 9e58380a08..bfbdedb256 100644 --- a/crates/blockchain/blockchain.rs +++ b/crates/blockchain/blockchain.rs @@ -394,7 +394,7 @@ impl Blockchain { } // Store the added storage in the account's storage trie and compute its new root if !update.added_storage.is_empty() { - debug!(count = update.added_storage.len(), "With storages"); + trace!(count = update.added_storage.len(), "Update storages"); let (storage_trie, storage_updates_map) = storage_updates_map .entry(hashed_address_h256) .or_insert_with(|| { diff --git a/crates/networking/p2p/discv4/peer_table.rs b/crates/networking/p2p/discv4/peer_table.rs index 60fa065c6f..8185055d04 100644 --- a/crates/networking/p2p/discv4/peer_table.rs +++ b/crates/networking/p2p/discv4/peer_table.rs @@ -582,7 +582,7 @@ impl PeerTableServer { } } // No untried contact found, resetting tried peers. - tracing::info!("Resetting list of tried peers."); + tracing::trace!("Resetting list of tried peers."); self.already_tried_peers.clear(); None } diff --git a/crates/networking/p2p/tx_broadcaster.rs b/crates/networking/p2p/tx_broadcaster.rs index bafbb9626d..fba9bf693d 100644 --- a/crates/networking/p2p/tx_broadcaster.rs +++ b/crates/networking/p2p/tx_broadcaster.rs @@ -13,7 +13,7 @@ use spawned_concurrency::{ messages::Unused, tasks::{CastResponse, GenServer, GenServerHandle, send_interval}, }; -use tracing::{debug, error, info}; +use tracing::{debug, error, info, trace}; use crate::{ discv4::peer_table::{PeerTable, PeerTableError}, @@ -184,7 +184,7 @@ impl TxBroadcaster { .get_txs_for_broadcast() .map_err(|_| TxBroadcasterError::Broadcast)?; if txs_to_broadcast.is_empty() { - debug!("No transactions to broadcast"); + trace!("No transactions to broadcast"); return Ok(()); } let peers = self.peer_table.get_peers_with_capabilities().await?; @@ -321,7 +321,7 @@ impl GenServer for TxBroadcaster { ) -> CastResponse { match message { Self::CastMsg::BroadcastTxs => { - debug!(received = "BroadcastTxs"); + trace!(received = "BroadcastTxs"); let _ = self.broadcast_txs().await.inspect_err(|_| { error!("Failed to broadcast transactions");