From 24d99df5e31188bcf4daed8f85ab915e2b0aff76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Wed, 1 May 2024 13:38:05 +0200 Subject: [PATCH] Better logging --- nano/node/transport/tcp_listener.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/nano/node/transport/tcp_listener.cpp b/nano/node/transport/tcp_listener.cpp index 2fbf5fbe..5fba0a6e 100644 --- a/nano/node/transport/tcp_listener.cpp +++ b/nano/node/transport/tcp_listener.cpp @@ -419,8 +419,8 @@ auto nano::transport::tcp_listener::check_limits (asio::ip::address const & ip, if (auto count = count_per_ip (ip); count >= node.network_params.network.max_peers_per_ip) { stats.inc (nano::stat::type::tcp_listener_rejected, nano::stat::detail::max_per_ip, to_stat_dir (type)); - logger.debug (nano::log::type::tcp_listener, "Max connections per IP reached (ip: {}, count: {}), unable to open new connection", - ip.to_string (), count); + logger.debug (nano::log::type::tcp_listener, "Max connections per IP reached ({}), unable to open new connection: {}", + count, ip.to_string ()); return accept_result::rejected; } @@ -432,8 +432,8 @@ auto nano::transport::tcp_listener::check_limits (asio::ip::address const & ip, if (auto count = count_per_subnetwork (ip); count >= node.network_params.network.max_peers_per_subnetwork) { stats.inc (nano::stat::type::tcp_listener_rejected, nano::stat::detail::max_per_subnetwork, to_stat_dir (type)); - logger.debug (nano::log::type::tcp_listener, "Max connections per subnetwork reached (ip: {}, count: {}), unable to open new connection", - ip.to_string (), count); + logger.debug (nano::log::type::tcp_listener, "Max connections per subnetwork reached ({}), unable to open new connection: {}", + count, ip.to_string ()); return accept_result::rejected; } @@ -446,7 +446,8 @@ auto nano::transport::tcp_listener::check_limits (asio::ip::address const & ip, if (auto count = count_per_type (connection_type::inbound); count >= config.max_inbound_connections) { stats.inc (nano::stat::type::tcp_listener_rejected, nano::stat::detail::max_attempts, to_stat_dir (type)); - logger.debug (nano::log::type::tcp_listener, "Max inbound connections reached ({}), unable to accept new connection", count); + logger.debug (nano::log::type::tcp_listener, "Max inbound connections reached ({}), unable to accept new connection: {}", + count, ip.to_string ()); return accept_result::rejected; } @@ -456,15 +457,17 @@ auto nano::transport::tcp_listener::check_limits (asio::ip::address const & ip, if (auto count = count_per_type (connection_type::outbound); count >= config.max_outbound_connections) { stats.inc (nano::stat::type::tcp_listener_rejected, nano::stat::detail::max_attempts, to_stat_dir (type)); - logger.debug (nano::log::type::tcp_listener, "Max outbound connections reached ({}), unable to initiate new connection", count); + logger.debug (nano::log::type::tcp_listener, "Max outbound connections reached ({}), unable to initiate new connection: {}", + count, ip.to_string ()); return accept_result::rejected; } - if (attempts.size () > config.max_attempts) + if (auto count = attempts.size (); count > config.max_attempts) { stats.inc (nano::stat::type::tcp_listener_rejected, nano::stat::detail::max_attempts, to_stat_dir (type)); - logger.debug (nano::log::type::tcp_listener, "Max connection attempts reached ({}), unable to initiate new connection", attempts.size ()); + logger.debug (nano::log::type::tcp_listener, "Max connection attempts reached ({}), unable to initiate new connection: {}", + count, ip.to_string ()); return accept_result::rejected; } @@ -472,7 +475,8 @@ auto nano::transport::tcp_listener::check_limits (asio::ip::address const & ip, if (auto count = count_attempts (ip); count >= config.max_attempts_per_ip) { stats.inc (nano::stat::type::tcp_listener_rejected, nano::stat::detail::max_attempts_per_ip, to_stat_dir (type)); - logger.debug (nano::log::type::tcp_listener, "Connection attempt already in progress ({}), unable to initiate new connection", ip.to_string ()); + logger.debug (nano::log::type::tcp_listener, "Connection attempt already in progress ({}), unable to initiate new connection: {}", + count, ip.to_string ()); return accept_result::rejected; }