forked from premiere/premiere-libtorrent
improve peer logging
This commit is contained in:
parent
7878f68370
commit
77be259938
|
@ -3979,6 +3979,9 @@ namespace libtorrent {
|
|||
if (m_request_large_blocks)
|
||||
{
|
||||
int const blocks_per_piece = t->torrent_file().piece_length() / t->block_size();
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
std::stringstream log_msg;
|
||||
#endif
|
||||
|
||||
while (!m_request_queue.empty())
|
||||
{
|
||||
|
@ -4000,10 +4003,11 @@ namespace libtorrent {
|
|||
if (m_queued_time_critical) --m_queued_time_critical;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::info, "MERGING_REQUEST"
|
||||
, "piece: %d block: %d"
|
||||
, static_cast<int>(block.block.piece_index)
|
||||
, block.block.block_index);
|
||||
if (should_log(peer_log_alert::info))
|
||||
{
|
||||
log_msg << " (" << block.block.piece_index << ", "
|
||||
<< block.block.block_index << ")";
|
||||
}
|
||||
#endif
|
||||
|
||||
block_offset = block.block.block_index * t->block_size();
|
||||
|
@ -4018,6 +4022,12 @@ namespace libtorrent {
|
|||
check_invariant();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::info, "MERGING_REQUEST"
|
||||
, "%s", log_msg.str().c_str());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// the verification will fail for coalesced blocks
|
||||
|
|
|
@ -300,6 +300,11 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
const int block_size = t->block_size();
|
||||
const int piece_size = t->torrent_file().piece_length();
|
||||
peer_request pr;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
std::stringstream log_msg;
|
||||
#endif
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
int request_offset = r.start + r.length - size;
|
||||
|
@ -309,8 +314,8 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
m_requests.push_back(pr);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::outgoing_message, "REQUESTING", "piece: %d start: %d len: %d"
|
||||
, static_cast<int>(pr.piece), pr.start, pr.length);
|
||||
if (should_log(peer_log_alert::info))
|
||||
log_msg << " (" << pr.piece << ", " << pr.start << ", " << pr.length << ")";
|
||||
#endif
|
||||
|
||||
if (m_web->restart_request == m_requests.front())
|
||||
|
@ -322,9 +327,9 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (should_log(peer_log_alert::info))
|
||||
{
|
||||
peer_log(peer_log_alert::info, "RESTART_DATA", "data: %d req: (%d, %d) size: %d"
|
||||
, int(m_piece.size()), static_cast<int>(front.piece), front.start
|
||||
, front.start + front.length - 1);
|
||||
log_msg << " (restart data: " << m_piece.size()
|
||||
<< " req: (" << front.piece << ", " << front.start << ") size: "
|
||||
<< (front.start + front.length - 1);
|
||||
}
|
||||
#else
|
||||
TORRENT_UNUSED(front);
|
||||
|
@ -345,6 +350,10 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
size -= pr.length;
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::outgoing_message, "REQUESTING", "%s", log_msg.str().c_str());
|
||||
#endif
|
||||
|
||||
bool const single_file_request = t->torrent_file().num_files() == 1;
|
||||
int const proxy_type = m_settings.get_int(settings_pack::proxy_type);
|
||||
bool const using_proxy = (proxy_type == settings_pack::http
|
||||
|
|
Loading…
Reference in New Issue