improved logging

This commit is contained in:
Arvid Norberg
2010-08-18 17:14:40 +00:00
parent e7f4d6984f
commit a85f1f5c61
4 changed files with 44 additions and 26 deletions

View File

@@ -500,12 +500,8 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i)
{
(*(*i)->m_logger) << "*** DESTRUCTING TORRENT\n";
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
log_to_all_peers("DESTRUCTING TORRENT");
#endif
TORRENT_ASSERT(m_abort);
@@ -2491,12 +2487,8 @@ namespace libtorrent
stop_announcing();
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i)
{
(*(*i)->m_logger) << time_now_string() << " *** ABORTING TORRENT\n";
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
log_to_all_peers("ABORTING TORRENT");
#endif
// disconnect all peers and close all
@@ -5217,12 +5209,9 @@ namespace libtorrent
void torrent::delete_files()
{
TORRENT_ASSERT(m_ses.is_network_thread());
#if defined TORRENT_VERBOSE_LOGGING
for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i)
{
(*(*i)->m_logger) << "*** DELETING FILES IN TORRENT\n";
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
log_to_all_peers("DELETING FILES IN TORRENT");
#endif
disconnect_all(errors::torrent_removed);
@@ -5257,6 +5246,16 @@ namespace libtorrent
bool checking_files = should_check_files();
m_error = ec;
m_error_file = error_file;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
if (ec)
{
char buf[1024];
snprintf(buf, sizeof(buf), "TORRENT ERROR: %s: %s", ec.message().c_str(), error_file.c_str());
log_to_all_peers(buf);
}
#endif
if (checking_files && !should_check_files())
{
// stop checking
@@ -5456,12 +5455,8 @@ namespace libtorrent
}
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i)
{
(*(*i)->m_logger) << "*** PAUSING TORRENT\n";
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
log_to_all_peers("PAUSING TORRENT");
#endif
// this will make the storage close all
@@ -5483,6 +5478,17 @@ namespace libtorrent
stop_announcing();
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
void torrent::log_to_all_peers(char const* message)
{
for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i)
{
(*(*i)->m_logger) << time_now_string() << " *** " << message << "\n";
}
}
#endif
void torrent::set_allow_peers(bool b)
{
TORRENT_ASSERT(m_ses.is_network_thread());