From a63cfd2a95ddd4da9a4ecea8e94e95abe75de8b4 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 5 Jul 2015 18:44:02 -0400 Subject: [PATCH] improve logging (specifically don't emit bandwidth limiter logs when it's disabled) --- src/peer_connection.cpp | 25 +++++++++---------------- src/session_impl.cpp | 4 +--- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 1d8a5f9e8..c22ea94f0 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5259,7 +5259,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING peer_log(channel == upload_channel ? peer_log_alert::outgoing : peer_log_alert::incoming - , "ASSIGN BANDWIDHT", "bytes: %d", amount); + , "ASSIGN_BANDWIDHT", "bytes: %d", amount); #endif TORRENT_ASSERT(amount > 0 || is_disconnecting()); @@ -5352,15 +5352,6 @@ namespace libtorrent } #endif -#ifndef TORRENT_DISABLE_LOGGING - peer_log( - channel == download_channel ? peer_log_alert::incoming - : peer_log_alert::outgoing, - "REQUEST_BANDWIDTH", "bytes: %d quota: %d wanted_transfer: %d " - "prio: %d num_channels: %d", bytes, m_quota[channel] - , wanted_transfer(channel), priority, c); -#endif - TORRENT_ASSERT((m_channel_state[channel] & peer_info::bw_limit) == 0); bandwidth_manager* manager = m_ses.get_bandwidth_manager(channel); @@ -5370,16 +5361,18 @@ namespace libtorrent if (ret == 0) { +#ifndef TORRENT_DISABLE_LOGGING + peer_log( + channel == download_channel ? peer_log_alert::incoming + : peer_log_alert::outgoing, + "REQUEST_BANDWIDTH", "bytes: %d quota: %d wanted_transfer: %d " + "prio: %d num_channels: %d", bytes, m_quota[channel] + , wanted_transfer(channel), priority, c); +#endif m_channel_state[channel] |= peer_info::bw_limit; } else { -#ifndef TORRENT_DISABLE_LOGGING - peer_log( - channel == download_channel ? peer_log_alert::incoming - : peer_log_alert::outgoing - , "ASSIGN_BANDWIDTH", "bytes: %d", ret); -#endif m_quota[channel] += ret; } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index d220913ea..76af44f53 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -519,9 +519,7 @@ namespace aux { #ifndef TORRENT_DISABLE_LOGGING - session_log("config: %s\n" - "version: %s\n" - "revision: %s\n\n" + session_log("config: %s version: %s revision: %s" , TORRENT_CFG_STRING , LIBTORRENT_VERSION , LIBTORRENT_REVISION);