disable DHT logging with the TORRENT_DISABLE_LOGGING macros as well

This commit is contained in:
arvidn 2017-12-22 22:12:09 +01:00 committed by Arvid Norberg
parent b7decd452e
commit 62bf524e75
6 changed files with 16 additions and 2 deletions

View File

@ -579,10 +579,12 @@ namespace libtorrent
virtual void announce(sha1_hash const& ih, address const& addr, int port) TORRENT_OVERRIDE;
virtual void outgoing_get_peers(sha1_hash const& target
, sha1_hash const& sent_target, udp::endpoint const& ep) TORRENT_OVERRIDE;
#ifndef TORRENT_DISABLE_LOGGING
virtual void log(libtorrent::dht::dht_logger::module_t m, char const* fmt, ...)
TORRENT_OVERRIDE TORRENT_FORMAT(3,4);
virtual void log_packet(message_direction_t dir, char const* pkt, int len
, udp::endpoint node) TORRENT_OVERRIDE;
#endif
virtual bool on_dht_request(char const* query, int query_len
, dht::msg const& request, entry& response) TORRENT_OVERRIDE;

View File

@ -41,6 +41,7 @@ namespace libtorrent { namespace dht
{
struct TORRENT_EXTRA_EXPORT dht_logger
{
#ifndef TORRENT_DISABLE_LOGGING
enum module_t
{
tracker,
@ -62,6 +63,7 @@ namespace libtorrent { namespace dht
protected:
~dht_logger() {}
#endif
};
struct TORRENT_EXTRA_EXPORT dht_observer : dht_logger

View File

@ -52,6 +52,8 @@ namespace libtorrent { namespace dht
bool dos_blocker::incoming(address addr, time_point now, dht_logger* logger)
{
TORRENT_UNUSED(logger);
node_ban_entry* match = 0;
node_ban_entry* min = m_ban_nodes;
for (node_ban_entry* i = m_ban_nodes; i < m_ban_nodes + num_ban_nodes; ++i)

View File

@ -6929,8 +6929,7 @@ retry:
m_alerts.emplace_alert<dht_outgoing_get_peers_alert>(target, sent_target, ep);
}
// TODO: 2 perhaps DHT logging should be disabled by TORRENT_DISABLE_LOGGING
// too
#ifndef TORRENT_DISABLE_LOGGING
TORRENT_FORMAT(3,4)
void session_impl::log(libtorrent::dht::dht_logger::module_t m, char const* fmt, ...)
{
@ -6954,6 +6953,7 @@ retry:
m_alerts.emplace_alert<dht_pkt_alert>(pkt, len, d, node);
}
#endif
bool session_impl::on_dht_request(char const* query, int query_len
, dht::msg const& request, entry& response)

View File

@ -484,6 +484,7 @@ struct obs : dht::dht_observer
virtual void outgoing_get_peers(sha1_hash const& target
, sha1_hash const& sent_target, udp::endpoint const& ep) TORRENT_OVERRIDE {}
virtual void announce(sha1_hash const& ih, address const& addr, int port) TORRENT_OVERRIDE {}
#ifndef TORRENT_DISABLE_LOGGING
virtual void log(dht_logger::module_t l, char const* fmt, ...) TORRENT_OVERRIDE
{
va_list v;
@ -495,6 +496,7 @@ struct obs : dht::dht_observer
}
virtual void log_packet(message_direction_t dir, char const* pkt, int len
, udp::endpoint node) TORRENT_OVERRIDE {}
#endif
virtual bool on_dht_request(char const* query, int query_len
, dht::msg const& request, entry& response) TORRENT_OVERRIDE { return false; }
@ -2485,6 +2487,9 @@ TORRENT_TEST(read_only_node)
TEST_CHECK(!parsed[3]);
}
#ifndef TORRENT_DISABLE_LOGGING
// these tests rely on logging being enabled
TORRENT_TEST(invalid_error_msg)
{
dht_settings sett = test_settings();
@ -2582,6 +2587,7 @@ TORRENT_TEST(rpc_invalid_error_msg)
TEST_EQUAL(found, true);
}
#endif
// test bucket distribution
TORRENT_TEST(node_id_bucket_distribution)

View File

@ -44,6 +44,7 @@ using namespace libtorrent;
struct log_t : libtorrent::dht::dht_logger
{
#ifndef TORRENT_DISABLE_LOGGING
virtual void log(dht_logger::module_t m, char const* fmt, ...)
TORRENT_OVERRIDE TORRENT_FORMAT(3, 4)
{
@ -68,6 +69,7 @@ struct log_t : libtorrent::dht::dht_logger
printf("%s [%s] %s", prefix[dir], print_endpoint(node).c_str()
, msg.c_str());
}
#endif
};
TORRENT_TEST(dos_blocker)