debug logging fixes

This commit is contained in:
Arvid Norberg
2010-04-14 18:52:13 +00:00
parent 954b25f356
commit 2a55fe8c70
4 changed files with 70 additions and 55 deletions

View File

@@ -116,7 +116,7 @@ namespace libtorrent
#endif
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "*** bt_peer_connection\n";
(*m_logger) << time_now_string() << "*** bt_peer_connection\n";
#endif
#ifdef TORRENT_DEBUG
@@ -1499,13 +1499,13 @@ namespace libtorrent
if (root.type() != lazy_entry::dict_t)
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "invalid extended handshake\n";
(*m_logger) << time_now_string() << " invalid extended handshake\n";
#endif
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "<== EXTENDED HANDSHAKE: \n" << root;
(*m_logger) << time_now_string() << " <== EXTENDED HANDSHAKE: \n" << root;
#endif
#ifndef TORRENT_DISABLE_EXTENSIONS
@@ -1937,7 +1937,7 @@ namespace libtorrent
#if defined TORRENT_VERBOSE_LOGGING && TORRENT_USE_IOSTREAM
std::stringstream ext;
handshake.print(ext);
(*m_logger) << "==> EXTENDED HANDSHAKE: \n" << ext.str();
(*m_logger) << time_now_string() << " ==> EXTENDED HANDSHAKE: \n" << ext.str();
#endif
setup_send();
@@ -2144,7 +2144,7 @@ namespace libtorrent
}
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " received DH key\n";
(*m_logger) << time_now_string() << " received DH key\n";
#endif
// PadA/B can be a max of 512 bytes, and 20 bytes more for
@@ -2245,7 +2245,7 @@ namespace libtorrent
{
std::size_t bytes_processed = syncoffset + 20;
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " sync point (hash) found at offset "
(*m_logger) << time_now_string << " sync point (hash) found at offset "
<< m_sync_bytes_read + bytes_processed - 20 << "\n";
#endif
m_state = read_pe_skey_vc;
@@ -2296,7 +2296,7 @@ namespace libtorrent
init_pe_RC4_handler(m_dh_key_exchange->get_secret(), ti.info_hash());
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " stream key found, torrent located.\n";
(*m_logger) << time_now_string() << " stream key found, torrent located.\n";
#endif
break;
}
@@ -2321,7 +2321,7 @@ namespace libtorrent
}
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " verification constant found\n";
(*m_logger) << time_now_string() << " verification constant found\n";
#endif
m_state = read_pe_cryptofield;
reset_recv_buffer(4 + 2);
@@ -2385,7 +2385,7 @@ namespace libtorrent
{
std::size_t bytes_processed = syncoffset + 8;
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " sync point (verification constant) found at offset "
(*m_logger) << time_now_string() << " sync point (verification constant) found at offset "
<< m_sync_bytes_read + bytes_processed - 8 << "\n";
#endif
int transferred_used = bytes_processed - recv_buffer.left() + bytes_transferred;
@@ -2421,9 +2421,9 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING
if (!is_local())
(*m_logger) << " crypto provide : [ ";
(*m_logger) << time_now_string() << " crypto provide : [ ";
else
(*m_logger) << " crypto select : [ ";
(*m_logger) << time_now_string() << " crypto select : [ ";
if (crypto_field & 0x01)
(*m_logger) << "plaintext ";
@@ -2558,7 +2558,7 @@ namespace libtorrent
}
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " len(IA) : " << len_ia << "\n";
(*m_logger) << time_now_string() << " len(IA) : " << len_ia << "\n";
#endif
if (len_ia == 0)
{
@@ -2594,14 +2594,14 @@ namespace libtorrent
m_RC4_handler->decrypt(wr_buf.begin, packet_size());
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " decrypted ia : " << packet_size() << " bytes\n";
(*m_logger) << time_now_string() << " decrypted ia : " << packet_size() << " bytes\n";
#endif
if (!m_rc4_encrypted)
{
m_RC4_handler.reset();
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " destroyed rc4 keys\n";
(*m_logger) << time_now_string() << " destroyed rc4 keys\n";
#endif
}
@@ -2625,14 +2625,14 @@ namespace libtorrent
wr_buf.begin += packet_size();
m_RC4_handler->decrypt(wr_buf.begin, wr_buf.left());
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " decrypted remaining " << wr_buf.left() << " bytes\n";
(*m_logger) << time_now_string() << " decrypted remaining " << wr_buf.left() << " bytes\n";
#endif
}
else // !m_rc4_encrypted
{
m_RC4_handler.reset();
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " destroyed rc4 keys\n";
(*m_logger) << time_now_string() << " destroyed rc4 keys\n";
#endif
}
@@ -2681,7 +2681,7 @@ namespace libtorrent
if (!m_encrypted && !is_local())
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " attempting encrypted connection\n";
(*m_logger) << time_now_string() << " attempting encrypted connection\n";
#endif
m_state = read_pe_dhkey;
cut_receive_buffer(0, dh_key_len);
@@ -2708,7 +2708,7 @@ namespace libtorrent
#endif
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " BitTorrent protocol\n";
(*m_logger) << time_now_string() << " BitTorrent protocol\n";
#endif
m_state = read_info_hash;
@@ -2737,11 +2737,11 @@ namespace libtorrent
}
(*m_logger) << "\n";
if (recv_buffer[7] & 0x01)
(*m_logger) << "supports DHT port message\n";
(*m_logger) << " supports DHT port message\n";
if (recv_buffer[7] & 0x04)
(*m_logger) << "supports FAST extensions\n";
(*m_logger) << " supports FAST extensions\n";
if (recv_buffer[5] & 0x10)
(*m_logger) << "supports extensions protocol\n";
(*m_logger) << " supports extensions protocol\n";
#endif
#ifndef DISABLE_EXTENSIONS
@@ -2775,14 +2775,14 @@ namespace libtorrent
, (const char*)t->torrent_file().info_hash().begin()))
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " received invalid info_hash\n";
(*m_logger) << time_now_string() << " received invalid info_hash\n";
#endif
disconnect(errors::invalid_info_hash, 2);
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << " info_hash received\n";
(*m_logger) << time_now_string() << " info_hash received\n";
#endif
}