Better logging

This commit is contained in:
Piotr Wójcik 2024-05-01 13:38:05 +02:00
commit 24d99df5e3

View file

@ -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;
}