verbose logging fixes
This commit is contained in:
parent
94a25a3953
commit
79f6b5856b
|
@ -69,19 +69,20 @@ namespace libtorrent
|
||||||
error_code ec;
|
error_code ec;
|
||||||
if (!exists(dir)) create_directories(dir, ec);
|
if (!exists(dir)) create_directories(dir, ec);
|
||||||
m_filename = combine_path(dir, filename);
|
m_filename = combine_path(dir, filename);
|
||||||
m_truncate = !append;
|
|
||||||
*this << "\n\n\n*** starting log ***\n";
|
mutex::scoped_lock l(file_mutex);
|
||||||
|
open(!append);
|
||||||
|
log_file << "\n\n\n*** starting log ***\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
#if TORRENT_USE_IOSTREAM
|
||||||
void open()
|
void open(bool truncate)
|
||||||
{
|
{
|
||||||
if (open_filename == m_filename) return;
|
if (open_filename == m_filename) return;
|
||||||
log_file.close();
|
log_file.close();
|
||||||
log_file.clear();
|
log_file.clear();
|
||||||
log_file.open(m_filename.c_str(), m_truncate ? std::ios_base::trunc : std::ios_base::app);
|
log_file.open(m_filename.c_str(), truncate ? std::ios_base::trunc : std::ios_base::app);
|
||||||
open_filename = m_filename;
|
open_filename = m_filename;
|
||||||
m_truncate = false;
|
|
||||||
if (!log_file.good())
|
if (!log_file.good())
|
||||||
fprintf(stderr, "Failed to open logfile %s: %s\n", m_filename.c_str(), strerror(errno));
|
fprintf(stderr, "Failed to open logfile %s: %s\n", m_filename.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -92,14 +93,13 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
#if TORRENT_USE_IOSTREAM
|
#if TORRENT_USE_IOSTREAM
|
||||||
mutex::scoped_lock l(file_mutex);
|
mutex::scoped_lock l(file_mutex);
|
||||||
open();
|
open(false);
|
||||||
log_file << v;
|
log_file << v;
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
bool m_truncate;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -595,13 +595,19 @@ namespace aux {
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
|
|
||||||
(*m_logger) << "libtorrent configuration: " << TORRENT_CFG_STRING << "\n"
|
char tmp[300];
|
||||||
<< "libtorrent version: " << LIBTORRENT_VERSION << "\n"
|
snprintf(tmp, sizeof(tmp), "libtorrent configuration: %s\n"
|
||||||
<< "libtorrent revision: " << LIBTORRENT_REVISION << "\n\n";
|
"libtorrent version: %d\n"
|
||||||
|
"libtorrent revision: %d\n\n"
|
||||||
|
, TORRENT_CFG_STRING
|
||||||
|
, LIBTORRENT_VERSION
|
||||||
|
, LIBTORRENT_REVISION);
|
||||||
|
(*m_logger) << tmp;
|
||||||
|
|
||||||
|
|
||||||
#define PRINT_SIZEOF(x) (*m_logger) << "sizeof(" #x "): " << sizeof(x) << "\n";
|
#define PRINT_SIZEOF(x) snprintf(tmp, sizeof(tmp), "sizeof(" #x ") = %d\n", int(sizeof(x))); (*m_logger) << tmp;
|
||||||
#define PRINT_OFFSETOF(x, y) (*m_logger) << " offsetof(" #x "," #y "): " << offsetof(x, y) << "\n";
|
#define PRINT_OFFSETOF(x, y) snprintf(tmp, sizeof(tmp), " offsetof(" #x "," #y "): %d\n", int(offsetof(x, y))); \
|
||||||
|
(*m_logger) << tmp;
|
||||||
|
|
||||||
PRINT_SIZEOF(announce_entry)
|
PRINT_SIZEOF(announce_entry)
|
||||||
PRINT_OFFSETOF(announce_entry, url)
|
PRINT_OFFSETOF(announce_entry, url)
|
||||||
|
@ -632,6 +638,8 @@ namespace aux {
|
||||||
PRINT_SIZEOF(bandwidth_channel)
|
PRINT_SIZEOF(bandwidth_channel)
|
||||||
PRINT_SIZEOF(policy)
|
PRINT_SIZEOF(policy)
|
||||||
|
|
||||||
|
PRINT_SIZEOF(file_entry)
|
||||||
|
|
||||||
// PRINT_SIZEOF(stat_channel)
|
// PRINT_SIZEOF(stat_channel)
|
||||||
// PRINT_OFFSETOF(stat_channel, m_counter)
|
// PRINT_OFFSETOF(stat_channel, m_counter)
|
||||||
// PRINT_OFFSETOF(stat_channel, m_average)
|
// PRINT_OFFSETOF(stat_channel, m_average)
|
||||||
|
|
Loading…
Reference in New Issue