added new logging mode to log peer errors

This commit is contained in:
Arvid Norberg 2008-02-07 07:09:52 +00:00
parent 92f4947bbe
commit a53473a65d
8 changed files with 69 additions and 78 deletions

View File

@ -161,8 +161,9 @@ feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
feature memdebug : off on : composite propagated ; feature memdebug : off on : composite propagated ;
feature.compose <memdebug>on : <define>TORRENT_MEMDEBUG ; feature.compose <memdebug>on : <define>TORRENT_MEMDEBUG ;
feature logging : none default verbose : composite propagated link-incompatible ; feature logging : none default errors verbose : composite propagated link-incompatible ;
feature.compose <logging>default : <define>TORRENT_LOGGING ; feature.compose <logging>default : <define>TORRENT_LOGGING ;
feature.compose <logging>errors : <define>TORRENT_ERRORLOGGING ;
feature.compose <logging>verbose : <define>TORRENT_VERBOSE_LOGGING ; feature.compose <logging>verbose : <define>TORRENT_VERBOSE_LOGGING ;
feature dht-support : on off logging : composite propagated link-incompatible ; feature dht-support : on off logging : composite propagated link-incompatible ;

View File

@ -205,6 +205,7 @@ boost directory.</li>
<li><tt class="docutils literal"><span class="pre">none</span></tt> - no logging.</li> <li><tt class="docutils literal"><span class="pre">none</span></tt> - no logging.</li>
<li><tt class="docutils literal"><span class="pre">default</span></tt> - basic session logging.</li> <li><tt class="docutils literal"><span class="pre">default</span></tt> - basic session logging.</li>
<li><tt class="docutils literal"><span class="pre">verbose</span></tt> - verbose peer wire logging.</li> <li><tt class="docutils literal"><span class="pre">verbose</span></tt> - verbose peer wire logging.</li>
<li><tt class="docutils literal"><span class="pre">errors</span></tt> - like verbose, but limited to errors.</li>
</ul> </ul>
</td> </td>
</tr> </tr>

View File

@ -209,6 +209,7 @@ Build features:
| ``logging`` | * ``none`` - no logging. | | ``logging`` | * ``none`` - no logging. |
| | * ``default`` - basic session logging. | | | * ``default`` - basic session logging. |
| | * ``verbose`` - verbose peer wire logging. | | | * ``verbose`` - verbose peer wire logging. |
| | * ``errors`` - like verbose, but limited to errors.|
+------------------------+----------------------------------------------------+ +------------------------+----------------------------------------------------+
| ``dht-support`` | * ``on`` - build with support for tracker less | | ``dht-support`` | * ``on`` - build with support for tracker less |
| | torrents and DHT support. | | | torrents and DHT support. |

View File

@ -86,7 +86,7 @@
<li><a class="reference" href="#name" id="id71" name="id71">name()</a></li> <li><a class="reference" href="#name" id="id71" name="id71">name()</a></li>
<li><a class="reference" href="#set-ratio" id="id72" name="id72">set_ratio()</a></li> <li><a class="reference" href="#set-ratio" id="id72" name="id72">set_ratio()</a></li>
<li><a class="reference" href="#set-upload-limit-set-download-limit-upload-limit-download-limit" id="id73" name="id73">set_upload_limit() set_download_limit() upload_limit() download_limit()</a></li> <li><a class="reference" href="#set-upload-limit-set-download-limit-upload-limit-download-limit" id="id73" name="id73">set_upload_limit() set_download_limit() upload_limit() download_limit()</a></li>
<li><a class="reference" href="#set-sequenced-download-threshold" id="id74" name="id74">set_sequenced_download_threshold()</a></li> <li><a class="reference" href="#set-sequential-download" id="id74" name="id74">set_sequential_download()</a></li>
<li><a class="reference" href="#set-peer-upload-limit-set-peer-download-limit" id="id75" name="id75">set_peer_upload_limit() set_peer_download_limit()</a></li> <li><a class="reference" href="#set-peer-upload-limit-set-peer-download-limit" id="id75" name="id75">set_peer_upload_limit() set_peer_download_limit()</a></li>
<li><a class="reference" href="#pause-resume-is-paused" id="id76" name="id76">pause() resume() is_paused()</a></li> <li><a class="reference" href="#pause-resume-is-paused" id="id76" name="id76">pause() resume() is_paused()</a></li>
<li><a class="reference" href="#resolve-countries" id="id77" name="id77">resolve_countries()</a></li> <li><a class="reference" href="#resolve-countries" id="id77" name="id77">resolve_countries()</a></li>
@ -1484,7 +1484,7 @@ struct torrent_handle
int upload_limit() const; int upload_limit() const;
void set_download_limit(int limit) const; void set_download_limit(int limit) const;
int download_limit() const; int download_limit() const;
void set_sequenced_download_threshold(int threshold) const; void set_sequential_download(bool sd) const;
void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const; void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const; void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
@ -1705,22 +1705,16 @@ limit.</p>
download, respectively.</p> download, respectively.</p>
</div> </div>
<div class="section"> <div class="section">
<h2><a id="set-sequenced-download-threshold" name="set-sequenced-download-threshold">set_sequenced_download_threshold()</a></h2> <h2><a id="set-sequential-download" name="set-sequential-download">set_sequential_download()</a></h2>
<blockquote> <blockquote>
<pre class="literal-block"> <pre class="literal-block">
void set_sequenced_download_threshold(int threshold); void set_sequential_download(bool sd);
</pre> </pre>
</blockquote> </blockquote>
<p>sequenced-download threshold is the limit on how popular a piece has to be <p>Enables or disables <em>sequential download</em>. When enabled, the piece picker will pick pieces in sequence
(popular == inverse of rarity) to be downloaded in sequence instead of in instead of rarest first.</p>
random (rarest first) order. It can be used to tweak disk performance in <p>Enabling sequential download will affect the piece distribution negatively in the swarm. It should be
settings where the random download property is less necessary. For example, if used sparingly.</p>
the threshold is 10, all pieces which 10 or more peers have, will be downloaded
in index order. This setting defaults to 100, which means that it is disabled
in practice.</p>
<p>Setting this threshold to a very small value will affect the piece distribution
negatively in the swarm. It should basically only be used in situations where
the random seeks on the disk is the download bottleneck.</p>
</div> </div>
<div class="section"> <div class="section">
<h2><a id="set-peer-upload-limit-set-peer-download-limit" name="set-peer-upload-limit-set-peer-download-limit">set_peer_upload_limit() set_peer_download_limit()</a></h2> <h2><a id="set-peer-upload-limit-set-peer-download-limit" name="set-peer-upload-limit-set-peer-download-limit">set_peer_upload_limit() set_peer_download_limit()</a></h2>

View File

@ -312,18 +312,10 @@ scrape. See <a class="reference" href="#actions">actions</a>.</td>
<td>transaction_id</td> <td>transaction_id</td>
<td>Randomized by client.</td> <td>Randomized by client.</td>
</tr> </tr>
<tr><td>int16_t</td>
<td>num_info_hashes</td>
<td>The number of info-hashes that will
follow.</td>
</tr>
<tr><td>uint16_t</td>
<td>extensions</td>
<td>Optional field. See <a class="reference" href="#extensions">extensions</a>.</td>
</tr>
</tbody> </tbody>
</table> </table>
<p>The following structure is repeated <tt class="docutils literal"><span class="pre">num_info_hashes</span></tt> times:</p> <p>The following structure is repeated for each info-hash to scrape, but limited by
the MTU.</p>
<table border="1" class="docutils"> <table border="1" class="docutils">
<colgroup> <colgroup>
<col width="18%" /> <col width="18%" />

View File

@ -286,7 +286,7 @@ namespace libtorrent
int desired_queue_size() const { return m_desired_queue_size; } int desired_queue_size() const { return m_desired_queue_size; }
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
boost::shared_ptr<logger> m_logger; boost::shared_ptr<logger> m_logger;
#endif #endif

View File

@ -129,7 +129,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
std::fill(m_country, m_country + 2, 0); std::fill(m_country, m_country + 2, 0);
#endif #endif
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
m_logger = m_ses.create_log(m_remote.address().to_string() + "_" m_logger = m_ses.create_log(m_remote.address().to_string() + "_"
+ boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port()); + boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port());
(*m_logger) << "*** OUTGOING CONNECTION\n"; (*m_logger) << "*** OUTGOING CONNECTION\n";
@ -224,7 +224,7 @@ namespace libtorrent
return; return;
} }
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
TORRENT_ASSERT(m_socket->remote_endpoint() == remote() || ec); TORRENT_ASSERT(m_socket->remote_endpoint() == remote() || ec);
m_logger = m_ses.create_log(remote().address().to_string(ec) + "_" m_logger = m_ses.create_log(remote().address().to_string(ec) + "_"
+ boost::lexical_cast<std::string>(remote().port()), m_ses.listen_port()); + boost::lexical_cast<std::string>(remote().port()), m_ses.listen_port());
@ -400,7 +400,7 @@ namespace libtorrent
TORRENT_ASSERT(!m_in_constructor); TORRENT_ASSERT(!m_in_constructor);
TORRENT_ASSERT(m_disconnecting); TORRENT_ASSERT(m_disconnecting);
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
if (m_logger) if (m_logger)
{ {
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
@ -591,7 +591,7 @@ namespace libtorrent
if (t && t->is_aborted()) if (t && t->is_aborted())
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << " *** the torrent has been aborted\n"; (*m_logger) << " *** the torrent has been aborted\n";
#endif #endif
t.reset(); t.reset();
@ -600,7 +600,7 @@ namespace libtorrent
if (!t) if (!t)
{ {
// we couldn't find the torrent! // we couldn't find the torrent!
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << " *** couldn't find a torrent with the given info_hash: " << ih << "\n"; (*m_logger) << " *** couldn't find a torrent with the given info_hash: " << ih << "\n";
(*m_logger) << " torrents:\n"; (*m_logger) << " torrents:\n";
session_impl::torrent_map const& torrents = m_ses.m_torrents; session_impl::torrent_map const& torrents = m_ses.m_torrents;
@ -618,7 +618,7 @@ namespace libtorrent
{ {
// paused torrents will not accept // paused torrents will not accept
// incoming connections // incoming connections
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << " rejected connection to paused torrent\n"; (*m_logger) << " rejected connection to paused torrent\n";
#endif #endif
disconnect("connection rejected bacause torrent is paused"); disconnect("connection rejected bacause torrent is paused");
@ -773,7 +773,7 @@ namespace libtorrent
p.abort_download(b); p.abort_download(b);
} }
} }
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
else else
{ {
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
@ -974,7 +974,7 @@ namespace libtorrent
if (m_have_piece[index]) if (m_have_piece[index])
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << " got redundant HAVE message for index: " << index << "\n"; (*m_logger) << " got redundant HAVE message for index: " << index << "\n";
#endif #endif
} }
@ -1154,7 +1154,7 @@ namespace libtorrent
{ {
// if we don't have valid metadata yet, // if we don't have valid metadata yet,
// we shouldn't get a request // we shouldn't get a request
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< " <== UNEXPECTED_REQUEST [ " << " <== UNEXPECTED_REQUEST [ "
"piece: " << r.piece << " | " "piece: " << r.piece << " | "
@ -1180,7 +1180,7 @@ namespace libtorrent
// memory consumption. // memory consumption.
// ignore requests if the client // ignore requests if the client
// is making too many of them. // is making too many of them.
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< " <== TOO MANY REQUESTS [ " << " <== TOO MANY REQUESTS [ "
"piece: " << r.piece << " | " "piece: " << r.piece << " | "
@ -1222,7 +1222,7 @@ namespace libtorrent
if (m_choked && m_accept_fast.find(r.piece) == m_accept_fast.end()) if (m_choked && m_accept_fast.find(r.piece) == m_accept_fast.end())
{ {
write_reject_request(r); write_reject_request(r);
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< " *** REJECTING REQUEST [ peer choked and piece not in allowed fast set ]\n"; << " *** REJECTING REQUEST [ peer choked and piece not in allowed fast set ]\n";
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
@ -1241,7 +1241,7 @@ namespace libtorrent
} }
else else
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< " <== INVALID_REQUEST [ " << " <== INVALID_REQUEST [ "
"piece: " << r.piece << " | " "piece: " << r.piece << " | "
@ -1348,7 +1348,7 @@ namespace libtorrent
if (!verify_piece(p)) if (!verify_piece(p))
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< " <== INVALID_PIECE [ piece: " << p.piece << " | " << " <== INVALID_PIECE [ piece: " << p.piece << " | "
"start: " << p.start << " | " "start: " << p.start << " | "
@ -1388,7 +1388,7 @@ namespace libtorrent
for (std::deque<piece_block>::iterator i = m_download_queue.begin(); for (std::deque<piece_block>::iterator i = m_download_queue.begin();
i != b; ++i) i != b; ++i)
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< " *** SKIPPED_PIECE [ piece: " << i->piece_index << " | " << " *** SKIPPED_PIECE [ piece: " << i->piece_index << " | "
"b: " << i->block_index << " ] ***\n"; "b: " << i->block_index << " ] ***\n";
@ -1422,7 +1422,7 @@ namespace libtorrent
, m_peer_id , m_peer_id
, "got a block that was not in the request queue")); , "got a block that was not in the request queue"));
} }
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << " *** The block we just got was not in the " (*m_logger) << " *** The block we just got was not in the "
"request queue ***\n"; "request queue ***\n";
#endif #endif
@ -1561,7 +1561,7 @@ namespace libtorrent
} }
else else
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << " *** GOT CANCEL NOT IN THE QUEUE\n"; (*m_logger) << time_now_string() << " *** GOT CANCEL NOT IN THE QUEUE\n";
#endif #endif
} }
@ -1696,7 +1696,7 @@ namespace libtorrent
if (index < 0 || index >= int(m_have_piece.size())) if (index < 0 || index >= int(m_have_piece.size()))
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << " <== INVALID_ALLOWED_FAST [ " << index << " | s: " (*m_logger) << time_now_string() << " <== INVALID_ALLOWED_FAST [ " << index << " | s: "
<< int(m_have_piece.size()) << " ]\n"; << int(m_have_piece.size()) << " ]\n";
#endif #endif
@ -1751,6 +1751,8 @@ namespace libtorrent
TORRENT_ASSERT(block.block_index < t->torrent_file().piece_size(block.piece_index)); TORRENT_ASSERT(block.block_index < t->torrent_file().piece_size(block.piece_index));
TORRENT_ASSERT(!t->picker().is_requested(block) || (t->picker().num_peers(block) > 0)); TORRENT_ASSERT(!t->picker().is_requested(block) || (t->picker().num_peers(block) > 0));
TORRENT_ASSERT(!t->have_piece(block.piece_index)); TORRENT_ASSERT(!t->have_piece(block.piece_index));
TORRENT_ASSERT(std::find(m_download_queue.begin(), m_download_queue.end(), block) == m_download_queue.end());
TORRENT_ASSERT(std::find(m_request_queue.begin(), m_request_queue.end(), block) == m_request_queue.end());
piece_picker::piece_state_t state; piece_picker::piece_state_t state;
peer_speed_t speed = peer_speed(); peer_speed_t speed = peer_speed();
@ -2032,7 +2034,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(m_connecting); TORRENT_ASSERT(m_connecting);
TORRENT_ASSERT(m_connection_ticket >= 0); TORRENT_ASSERT(m_connection_ticket >= 0);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << time_now_string() << " CONNECTION TIMED OUT: " << m_remote.address().to_string() (*m_ses.m_logger) << time_now_string() << " CONNECTION TIMED OUT: " << m_remote.address().to_string()
<< "\n"; << "\n";
#endif #endif
@ -2044,7 +2046,7 @@ namespace libtorrent
{ {
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
#if defined(TORRENT_VERBOSE_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << "*** CONNECTION FAILED " << message << "\n"; (*m_logger) << "*** CONNECTION FAILED " << message << "\n";
#endif #endif
// we cannot create an intrusive pointer to ourselves, since we // we cannot create an intrusive pointer to ourselves, since we
@ -2319,7 +2321,7 @@ namespace libtorrent
// requested (this has been observed by BitComet) // requested (this has been observed by BitComet)
// in this case we'll clear our download queue and // in this case we'll clear our download queue and
// re-request the blocks. // re-request the blocks.
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() (*m_logger) << time_now_string()
<< " *** PIECE_REQUESTS TIMED OUT [ " << (int)m_download_queue.size() << " *** PIECE_REQUESTS TIMED OUT [ " << (int)m_download_queue.size()
<< " " << total_seconds(now - m_last_piece) << "] ***\n"; << " " << total_seconds(now - m_last_piece) << "] ***\n";
@ -2419,7 +2421,7 @@ namespace libtorrent
} }
catch (std::exception& e) catch (std::exception& e)
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << "**ERROR**: " << e.what() << "\n"; (*m_logger) << "**ERROR**: " << e.what() << "\n";
#endif #endif
disconnect(e.what()); disconnect(e.what());
@ -2753,7 +2755,7 @@ namespace libtorrent
if (error) if (error)
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << " **ERROR**: " (*m_logger) << time_now_string() << " **ERROR**: "
<< error.message() << "[in peer_connection::on_receive_data]\n"; << error.message() << "[in peer_connection::on_receive_data]\n";
#endif #endif
@ -2875,7 +2877,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
asio::error_code ec; asio::error_code ec;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << time_now_string() << " CONNECTING: " << m_remote.address().to_string(ec) (*m_ses.m_logger) << time_now_string() << " CONNECTING: " << m_remote.address().to_string(ec)
<< ":" << m_remote.port() << "\n"; << ":" << m_remote.port() << "\n";
#endif #endif
@ -2931,7 +2933,7 @@ namespace libtorrent
if (e) if (e)
{ {
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << time_now_string() << " CONNECTION FAILED: " << m_remote.address().to_string() (*m_ses.m_logger) << time_now_string() << " CONNECTION FAILED: " << m_remote.address().to_string()
<< ": " << e.message() << "\n"; << ": " << e.message() << "\n";
#endif #endif
@ -2945,7 +2947,7 @@ namespace libtorrent
// this means the connection just succeeded // this means the connection just succeeded
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
(*m_ses.m_logger) << time_now_string() << " COMPLETED: " << m_remote.address().to_string() << "\n"; (*m_ses.m_logger) << time_now_string() << " COMPLETED: " << m_remote.address().to_string() << "\n";
#endif #endif
@ -2993,7 +2995,7 @@ namespace libtorrent
if (error) if (error)
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << "**ERROR**: " << error.message() << " [in peer_connection::on_send_data]\n"; (*m_logger) << "**ERROR**: " << error.message() << " [in peer_connection::on_send_data]\n";
#endif #endif
set_failed(); set_failed();
@ -3182,7 +3184,7 @@ namespace libtorrent
d = now - m_last_receive; d = now - m_last_receive;
if (d > seconds(m_timeout)) if (d > seconds(m_timeout))
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << " *** LAST ACTIVITY [ " (*m_logger) << time_now_string() << " *** LAST ACTIVITY [ "
<< total_seconds(d) << " seconds ago ] ***\n"; << total_seconds(d) << " seconds ago ] ***\n";
#endif #endif
@ -3192,7 +3194,7 @@ namespace libtorrent
// do not stall waiting for a handshake // do not stall waiting for a handshake
if (in_handshake() && d > seconds(m_ses.settings().handshake_timeout)) if (in_handshake() && d > seconds(m_ses.settings().handshake_timeout))
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << " *** NO HANDSHAKE [ waited " (*m_logger) << time_now_string() << " *** NO HANDSHAKE [ waited "
<< total_seconds(d) << " seconds ] ***\n"; << total_seconds(d) << " seconds ] ***\n";
#endif #endif
@ -3210,7 +3212,7 @@ namespace libtorrent
&& t && t->is_finished() && t && t->is_finished()
&& d > seconds(20)) && d > seconds(20))
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << " *** NO REQUEST [ t: " (*m_logger) << time_now_string() << " *** NO REQUEST [ t: "
<< total_seconds(d) << " ] ***\n"; << total_seconds(d) << " ] ***\n";
#endif #endif
@ -3241,7 +3243,7 @@ namespace libtorrent
&& (m_ses.num_connections() >= m_ses.max_connections() && (m_ses.num_connections() >= m_ses.max_connections()
|| (t && t->num_peers() >= t->max_connections()))) || (t && t->num_peers() >= t->max_connections())))
{ {
#ifdef TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_logger) << time_now_string() << " *** MUTUAL NO INTEREST [ " (*m_logger) << time_now_string() << " *** MUTUAL NO INTEREST [ "
"t1: " << total_seconds(d1) << " | " "t1: " << total_seconds(d1) << " | "
"t2: " << total_seconds(d2) << " ] ***\n"; "t2: " << total_seconds(d2) << " ] ***\n";

View File

@ -321,7 +321,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
for (peer_iterator i = m_connections.begin(); for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i) i != m_connections.end(); ++i)
{ {
@ -594,7 +594,7 @@ namespace libtorrent
// connect to random peers from the list // connect to random peers from the list
std::random_shuffle(peer_list.begin(), peer_list.end()); std::random_shuffle(peer_list.begin(), peer_list.end());
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
std::stringstream s; std::stringstream s;
s << "TRACKER RESPONSE:\n" s << "TRACKER RESPONSE:\n"
"interval: " << m_duration << "\n" "interval: " << m_duration << "\n"
@ -623,7 +623,7 @@ namespace libtorrent
if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked) if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
{ {
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
debug_log("blocked ip from tracker: " + i->ip); debug_log("blocked ip from tracker: " + i->ip);
#endif #endif
if (m_ses.m_alerts.should_post(alert::info)) if (m_ses.m_alerts.should_post(alert::info))
@ -670,7 +670,7 @@ namespace libtorrent
if (m_ses.m_ip_filter.access(host->endpoint().address()) & ip_filter::blocked) if (m_ses.m_ip_filter.access(host->endpoint().address()) & ip_filter::blocked)
{ {
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
debug_log("blocked ip from tracker: " + host->endpoint().address().to_string()); debug_log("blocked ip from tracker: " + host->endpoint().address().to_string());
#endif #endif
if (m_ses.m_alerts.should_post(alert::info)) if (m_ses.m_alerts.should_post(alert::info))
@ -1081,10 +1081,10 @@ namespace libtorrent
#ifdef TORRENT_LOGGING #ifdef TORRENT_LOGGING
(*m_ses.m_logger) << time_now_string() << " *** BANNING PEER [ " << p->ip (*m_ses.m_logger) << time_now_string() << " *** BANNING PEER [ " << p->ip
<< " ] 'too many corrupt pieces'\n"; << " ] 'too many corrupt pieces'\n";
#if defined(TORRENT_VERBOSE_LOGGING) #endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*p->connection->m_logger) << "*** BANNING PEER [ " << p->ip (*p->connection->m_logger) << "*** BANNING PEER [ " << p->ip
<< " ] 'too many corrupt pieces'\n"; << " ] 'too many corrupt pieces'\n";
#endif
#endif #endif
p->connection->disconnect("too many corrupt pieces, banning peer"); p->connection->disconnect("too many corrupt pieces, banning peer");
} }
@ -1131,7 +1131,7 @@ namespace libtorrent
// disconnect all peers and close all // disconnect all peers and close all
// files belonging to the torrents // files belonging to the torrents
#if defined(TORRENT_VERBOSE_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
for (peer_iterator i = m_connections.begin(); for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i) i != m_connections.end(); ++i)
{ {
@ -1640,7 +1640,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
(*m_ses.m_logger) << time_now_string() << " resolving web seed: " << url << "\n"; (*m_ses.m_logger) << time_now_string() << " resolving web seed: " << url << "\n";
#endif #endif
@ -1682,7 +1682,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
(*m_ses.m_logger) << time_now_string() << " completed resolve proxy hostname for: " << url << "\n"; (*m_ses.m_logger) << time_now_string() << " completed resolve proxy hostname for: " << url << "\n";
#endif #endif
@ -1738,7 +1738,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
(*m_ses.m_logger) << time_now_string() << " completed resolve: " << url << "\n"; (*m_ses.m_logger) << time_now_string() << " completed resolve: " << url << "\n";
#endif #endif
@ -1754,7 +1754,7 @@ namespace libtorrent
m_ses.m_alerts.post_alert( m_ses.m_alerts.post_alert(
url_seed_alert(get_handle(), url, msg.str())); url_seed_alert(get_handle(), url, msg.str()));
} }
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << url << "\n"; (*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << url << "\n";
#endif #endif
@ -1819,7 +1819,7 @@ namespace libtorrent
} }
catch (std::exception& e) catch (std::exception& e)
{ {
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << e.what() << "\n"; (*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << e.what() << "\n";
#endif #endif
@ -1957,7 +1957,7 @@ namespace libtorrent
{ {
// unknown country! // unknown country!
p->set_country("!!"); p->set_country("!!");
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << "IP " << p->remote().address() << " was mapped to unknown country: " << country << "\n"; (*m_ses.m_logger) << "IP " << p->remote().address() << " was mapped to unknown country: " << country << "\n";
#endif #endif
return; return;
@ -2250,7 +2250,7 @@ namespace libtorrent
peer_connection* p = *m_connections.begin(); peer_connection* p = *m_connections.begin();
TORRENT_ASSERT(p->associated_torrent().lock().get() == this); TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
#if defined(TORRENT_VERBOSE_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
if (m_abort) if (m_abort)
(*p->m_logger) << "*** CLOSING CONNECTION 'aborting'\n"; (*p->m_logger) << "*** CLOSING CONNECTION 'aborting'\n";
else else
@ -2381,7 +2381,7 @@ namespace libtorrent
TORRENT_ASSERT(p->associated_torrent().lock().get() == this); TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
if (p->is_seed()) if (p->is_seed())
{ {
#if defined(TORRENT_VERBOSE_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*p->m_logger) << "*** SEED, CLOSING CONNECTION\n"; (*p->m_logger) << "*** SEED, CLOSING CONNECTION\n";
#endif #endif
seeds.push_back(p); seeds.push_back(p);
@ -2486,7 +2486,7 @@ namespace libtorrent
{ {
m_ses.m_alerts.post_alert(fastresume_rejected_alert( m_ses.m_alerts.post_alert(fastresume_rejected_alert(
get_handle(), error_msg)); get_handle(), error_msg));
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << "fastresume data for " (*m_ses.m_logger) << "fastresume data for "
<< torrent_file().name() << " rejected: " << torrent_file().name() << " rejected: "
<< error_msg << "\n"; << error_msg << "\n";
@ -2861,7 +2861,7 @@ namespace libtorrent
void torrent::delete_files() void torrent::delete_files()
{ {
#if defined(TORRENT_VERBOSE_LOGGING) #if defined TORRENT_VERBOSE_LOGGING
for (peer_iterator i = m_connections.begin(); for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i) i != m_connections.end(); ++i)
{ {
@ -2898,7 +2898,7 @@ namespace libtorrent
} }
#endif #endif
#if defined(TORRENT_VERBOSE_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
for (peer_iterator i = m_connections.begin(); for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i) i != m_connections.end(); ++i)
{ {
@ -3022,7 +3022,7 @@ namespace libtorrent
} }
catch (std::exception& e) catch (std::exception& e)
{ {
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*p->m_logger) << "**ERROR**: " << e.what() << "\n"; (*p->m_logger) << "**ERROR**: " << e.what() << "\n";
#endif #endif
p->set_failed(); p->set_failed();
@ -3278,7 +3278,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
debug_log("*** tracker timed out"); debug_log("*** tracker timed out");
#endif #endif
@ -3311,7 +3311,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
debug_log(std::string("*** tracker error: ") + str); debug_log(std::string("*** tracker error: ") + str);
#endif #endif
if (m_ses.m_alerts.should_post(alert::warning)) if (m_ses.m_alerts.should_post(alert::warning))
@ -3334,7 +3334,7 @@ namespace libtorrent
} }
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
void torrent::debug_log(const std::string& line) void torrent::debug_log(const std::string& line)
{ {
(*m_ses.m_logger) << time_now_string() << " " << line << "\n"; (*m_ses.m_logger) << time_now_string() << " " << line << "\n";