simplify the debug logging mechanism. There's now only one build option, logging=on or logging=off. When logging is enabled, the log level is controlled by the alert mask. All log events are delivered as alerts and it's up to the client to write them to disk in whatever way seems appropriate. removed the pointless logger plugin

This commit is contained in:
Arvid Norberg 2014-12-09 09:08:26 +00:00
parent 4eaec6d87f
commit 09bc1550e9
46 changed files with 650 additions and 1147 deletions

View File

@ -84,7 +84,6 @@ set(sources
upnp
utp_socket_manager
utp_stream
logger
file_pool
lsd
disk_io_job
@ -151,7 +150,6 @@ option(unicode "enable unicode support" ON)
option(deprecated-functions "enable deprecated functions for backwards compatibility" ON)
option(exceptions "build with exception support" ON)
option(logging "build with logging" OFF)
option(verbose-logging "build with verbose logging" OFF)
option(build_tests "build tests" OFF)
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
@ -190,9 +188,6 @@ endif (encryption)
if (logging)
add_definitions(-DTORRENT_LOGGING)
endif()
if (verbose-logging)
add_definitions(-DTORRENT_VERBOSE_LOGGING)
endif()
foreach(s ${sources})
list(APPEND sources2 src/${s})

View File

@ -1,3 +1,5 @@
* greatly simplify the debug logging infrastructure. logs are now delivered
as alerts, and log level is controlled by the alert mask.
* removed auto_expand_choker. use rate_based_choker instead
* optimize UDP tracker packet handling
* support SSL over uTP connections

11
Jamfile
View File

@ -399,10 +399,8 @@ feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
feature simulate-slow-read : off on : composite propagated ;
feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ;
feature logging : none default errors verbose : composite propagated link-incompatible ;
feature.compose <logging>default : <define>TORRENT_LOGGING ;
feature.compose <logging>errors : <define>TORRENT_ERROR_LOGGING ;
feature.compose <logging>verbose : <define>TORRENT_VERBOSE_LOGGING ;
feature logging : off on : composite propagated link-incompatible ;
feature.compose <logging>on : <define>TORRENT_LOGGING ;
feature dht : on off logging : composite propagated link-incompatible ;
feature.compose <dht>off : <define>TORRENT_DISABLE_DHT ;
@ -455,13 +453,13 @@ variant test_release
<export-extra>on <debug-iterators>on <boost>source <threading>multi
;
variant test_debug : debug
: <encryption>openssl <logging>verbose <disk-stats>on
: <encryption>openssl <logging>on <disk-stats>on
<dht>logging <request-log>on <allocator>debug <debug-iterators>on
<invariant-checks>full <boost-link>shared
<export-extra>on <debug-iterators>on <boost>source <threading>multi
;
variant test_barebones : debug
: <ipv6>off <dht>off <extensions>off <logging>none <boost-link>shared
: <ipv6>off <dht>off <extensions>off <logging>off <boost-link>shared
<deprecated-functions>off <invariant-checks>off
<export-extra>on <debug-iterators>on <boost>source <threading>multi
;
@ -604,7 +602,6 @@ SOURCES =
utf8
utp_socket_manager
utp_stream
logger
file_pool
lsd
disk_buffer_pool

View File

@ -379,24 +379,14 @@ AC_MSG_CHECKING([whether logging to disk should be enabled])
AS_CASE(["$ARG_ENABLE_LOGGING"],
["yes"|"default"], [
AC_MSG_RESULT([yes])
AC_DEFINE([TORRENT_LOGGING],[1],[Define to enable logging of the session events.])
AC_DEFINE([TORRENT_LOGGING],[1],[Define to enable support for logging alerts])
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_LOGGING "
],
["no"|"none"], [
AC_MSG_RESULT([no])
],
["verbose"], [
AC_MSG_RESULT([verbose])
AC_DEFINE([TORRENT_VERBOSE_LOGGING],[1],[Define to enable logging of the session events and every peer connection.])
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_VERBOSE_LOGGING "
],
["errors"], [
AC_MSG_RESULT([errors])
AC_DEFINE([TORRENT_ERROR_LOGGING],[1],[Define to enable logging of the session events and every peer connection limited to errors.])
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_ERROR_LOGGING "
],
[AC_MSG_RESULT([$ARG_ENABLE_LOGGING])
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_LOGGING". Use either "yes", "no", "verbose" or "errors".])]
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_LOGGING". Use either "yes" or "no"])]
)
AC_MSG_CHECKING([whether disk activity logging should be enabled])

View File

@ -249,10 +249,11 @@ Build features:
| | * ``shared`` - links dynamically against the boost |
| | libraries. |
+--------------------------+----------------------------------------------------+
| ``logging`` | * ``none`` - no logging. |
| | * ``default`` - basic session logging. |
| | * ``verbose`` - verbose peer wire logging. |
| | * ``errors`` - like verbose, but limited to errors.|
| ``logging`` | * ``off`` - default. logging disabled. |
| | * ``on`` - logging alerts available, still need to |
| | be enabled by the alert mask. The reason logging |
| | is disabled by default is to keep the binary |
| | size down. |
+--------------------------+----------------------------------------------------+
| ``dht`` | * ``on`` - build with support for tracker less |
| | torrents and DHT support. |
@ -552,13 +553,10 @@ defines you can use to control the build.
| | compilation units having different views of |
| | structs and class layouts and sizes. |
+----------------------------------------+-------------------------------------------------+
| ``TORRENT_LOGGING`` | This macro will enable logging of the session |
| | events, such as tracker announces and incoming |
| | connections (as well as blocked connections). |
+----------------------------------------+-------------------------------------------------+
| ``TORRENT_VERBOSE_LOGGING`` | If you define this macro, every peer connection |
| | will log its traffic to a log file as well as |
| | the session log. |
| ``TORRENT_LOGGING`` | This macro will enable support for logging |
| | alerts, like log_alert, torrent_log_alert and |
| | peer_log_alert. Without this build flag, you |
| | cannot enable those alerts. |
+----------------------------------------+-------------------------------------------------+
| ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant |
| | checks in the storage, including logging of |

View File

@ -153,7 +153,6 @@ nobase_include_HEADERS = \
aux_/session_impl.hpp \
aux_/session_settings.hpp\
\
extensions/logger.hpp \
extensions/lt_trackers.hpp \
extensions/metadata_transfer.hpp \
extensions/smart_ban.hpp \

View File

@ -165,6 +165,23 @@ namespace libtorrent {
// will make you receive rss_alert alerts.
rss_notification = 0x1000,
// Enables debug logging alerts. These are only available when
// libtorrent is built with logging enabled (``TORRENT_LOGGING``).
// The alerts being posted are log_alert and are session wide.
session_log_notification = 0x2000,
// Enables debug logging alerts for torrents. These are only available
// when libtorrent is built with logging enabled
// (``TORRENT_LOGGING``). The alerts being posted are
// torrent_log_alert and are torrent wide debug events.
torrent_log_notification = 0x4000,
// Enables debug logging alerts for peers. These are only available
// when libtorrent is built with logging enabled
// (``TORRENT_LOGGING``). The alerts being posted are peer_log_alert
// and low-level peer events and messages.
peer_log_notification = 0x8000,
// The full bitmask, representing all available categories.
//
// since the enum is signed, make sure this isn't

View File

@ -2178,9 +2178,78 @@ namespace libtorrent
udp::endpoint ip;
};
// This alert is posted by some session wide event. Its main purpose is
// trouble shooting and debugging. It's not enabled by the default alert
// mask and is enabled by the ``alert::session_log_notification`` bit.
// Furhtermore, it's by default disabled as a build configuration. To
// enable, build libtorrent with logging support enabled (``logging=on``
// with bjam or define ``TORRENT_LOGGING``).
struct TORRENT_EXPORT log_alert : alert
{
// internal
log_alert(char const* log)
: msg(log)
{}
TORRENT_DEFINE_ALERT(log_alert, 79);
const static int static_category = alert::session_log_notification;
virtual std::string message() const;
// the log message
std::string msg;
};
// This alert is posted by torrent wide events. It's meant to be used for
// trouble shooting and debugging. It's not enabled by the default alert
// mask and is enabled by the ``alert::torrent_log_notification`` bit. By
// default it is disabled as a build configuration. To enable, build
// libtorrent with logging support enabled (``logging=on`` with bjam or
// define ``TORRENT_LOGGING``).
struct TORRENT_EXPORT torrent_log_alert : torrent_alert
{
// internal
torrent_log_alert(torrent_handle h, char const* log)
: torrent_alert(h)
, msg(log)
{}
TORRENT_DEFINE_ALERT(torrent_log_alert, 80);
const static int static_category = alert::torrent_log_notification;
virtual std::string message() const;
// the log message
std::string msg;
};
// This alert is posted by events specific to a peer. It's meant to be used
// for trouble shooting and debugging. It's not enabled by the default alert
// mask and is enabled by the ``alert::peer_log_notification`` bit. By
// default it is disabled as a build configuration. To enable, build
// libtorrent with logging support enabled (``logging=on`` with bjam or
// define ``TORRENT_LOGGING``).
struct TORRENT_EXPORT peer_log_alert : peer_alert
{
// internal
peer_log_alert(torrent_handle const& h, tcp::endpoint const& i
, peer_id const& pi, char const* log)
: peer_alert(h, i, pi)
, msg(log)
{}
TORRENT_DEFINE_ALERT(peer_log_alert, 81);
const static int static_category = alert::peer_log_notification;
virtual std::string message() const;
// the log message
std::string msg;
};
#undef TORRENT_DEFINE_ALERT
enum { num_alert_types = 79 };
enum { num_alert_types = 82 };
}

View File

@ -154,7 +154,7 @@ namespace libtorrent
struct session_impl;
struct session_settings;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
struct tracker_logger;
#endif
@ -179,13 +179,6 @@ namespace libtorrent
, uncork_interface
, single_threaded
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
// this needs to be destructed last, since other components may log
// things as they are being destructed. That's why it's declared at
// the top of session_impl
boost::shared_ptr<logger> m_logger;
#endif
// the size of each allocation that is chained in the send buffer
enum { send_buffer_size_impl = 128 };
@ -206,9 +199,6 @@ namespace libtorrent
void init();
void start_session(settings_pack const& pack);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
void set_log_path(std::string const& p) { m_logpath = p; }
#endif
void set_load_function(user_load_function_t fun)
{ m_user_load_torrent = fun; }
@ -699,7 +689,7 @@ namespace libtorrent
#endif
// handles delayed alerts
alert_manager m_alerts;
mutable alert_manager m_alerts;
// handles disk io requests asynchronously
// peers have pointers into the disk buffer
@ -1117,35 +1107,21 @@ namespace libtorrent
// accumulated error
boost::uint16_t m_tick_residual;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
virtual boost::shared_ptr<logger> create_log(std::string const& name
, int instance, bool append = true);
#if defined TORRENT_LOGGING
virtual void session_log(char const* fmt, ...) const;
virtual void session_vlog(char const* fmt, va_list& va) const;
#if defined TORRENT_VERBOSE_LOGGING
void log_all_torrents(peer_connection* p);
#endif
// this list of tracker loggers serves as tracker_callbacks when
// shutting down. This list is just here to keep them alive during
// whe shutting down process
std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
std::string get_log_path() const
{ return m_logpath; }
std::string m_logpath;
FILE* m_request_logger;
#endif
private:
#ifdef TORRENT_UPNP_LOGGING
std::ofstream m_upnp_log;
#endif
// state for keeping track of external IPs
external_ip m_external_ip;
@ -1202,7 +1178,7 @@ namespace libtorrent
#endif
};
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
struct tracker_logger : request_callback
{
tracker_logger(session_interface& ses);

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
#include <boost/shared_ptr.hpp>
#endif
@ -70,9 +70,6 @@ namespace libtorrent
struct bandwidth_manager;
struct peer_class_pool;
struct disk_observer;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
struct logger;
#endif
struct torrent_peer;
class alert_manager;
struct disk_interface;
@ -305,16 +302,11 @@ namespace libtorrent { namespace aux
virtual FILE* get_request_log() = 0;
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
virtual boost::shared_ptr<logger> create_log(std::string const& name
, int instance, bool append = true) = 0;
#if defined TORRENT_LOGGING
virtual void session_log(char const* fmt, ...) const = 0;
virtual void session_vlog(char const* fmt, va_list& va) const = 0;
virtual std::string get_log_path() const = 0;
#if defined TORRENT_VERBOSE_LOGGING
virtual void log_all_torrents(peer_connection* p) = 0;
#endif
#endif
#ifdef TORRENT_BUFFER_STATS
virtual void log_buffer_usage() = 0;

View File

@ -388,11 +388,6 @@ int snprintf(char* buf, int len, char const* fmt, ...)
#include <limits.h>
#endif
#if (defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)) \
&& !defined (TORRENT_UPNP_LOGGING) && TORRENT_USE_IOSTREAM
#define TORRENT_UPNP_LOGGING
#endif
#ifndef TORRENT_ICONV_ARG
#define TORRENT_ICONV_ARG (char**)
#endif

View File

@ -195,116 +195,5 @@ namespace libtorrent
#endif
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#include <cstring>
#include "libtorrent/config.hpp"
#include "libtorrent/file.hpp"
#include "libtorrent/thread.hpp"
#if TORRENT_USE_IOSTREAM
#include <string>
#include <fstream>
#include <iostream>
#endif
namespace libtorrent
{
// DEBUG API
// TODO: rewrite this class to use FILE* instead and
// have a printf-like interface
struct logger
{
#if TORRENT_USE_IOSTREAM
// all log streams share a single file descriptor
// and re-opens the file for each log line
// these members are defined in session_impl.cpp
static std::ofstream log_file;
static std::string open_filename;
static mutex file_mutex;
#endif
~logger()
{
mutex::scoped_lock l(file_mutex);
log_file.close();
open_filename.clear();
}
logger(std::string const& logpath, std::string const& filename
, int instance, bool append)
{
char log_name[512];
snprintf(log_name, sizeof(log_name), "libtorrent_logs%d", instance);
std::string dir(complete(combine_path(combine_path(logpath, log_name), filename)) + ".log");
error_code ec;
if (!exists(parent_path(dir)))
create_directories(parent_path(dir), ec);
m_filename = dir;
mutex::scoped_lock l(file_mutex);
open(!append);
log_file << "\n\n\n*** starting log ***\n";
}
void move_log_file(std::string const& logpath, std::string const& new_name, int instance)
{
mutex::scoped_lock l(file_mutex);
if (open_filename == m_filename)
{
log_file.close();
open_filename.clear();
}
char log_name[512];
snprintf(log_name, sizeof(log_name), "libtorrent_logs%d", instance);
std::string dir(combine_path(combine_path(complete(logpath), log_name), new_name) + ".log");
error_code ec;
create_directories(parent_path(dir), ec);
if (ec)
fprintf(stderr, "Failed to create logfile directory %s: %s\n"
, parent_path(dir).c_str(), ec.message().c_str());
ec.clear();
rename(m_filename, dir, ec);
if (ec)
fprintf(stderr, "Failed to move logfile %s: %s\n"
, parent_path(dir).c_str(), ec.message().c_str());
m_filename = dir;
}
#if TORRENT_USE_IOSTREAM
void open(bool truncate)
{
if (open_filename == m_filename) return;
log_file.close();
log_file.clear();
log_file.open(m_filename.c_str(), truncate ? std::ios_base::trunc : std::ios_base::app);
open_filename = m_filename;
if (!log_file.good())
fprintf(stderr, "Failed to open logfile %s: %s\n", m_filename.c_str(), strerror(errno));
}
#endif
template <class T>
logger& operator<<(T const& v)
{
#if TORRENT_USE_IOSTREAM
mutex::scoped_lock l(file_mutex);
open(false);
log_file << v;
#endif
return *this;
}
std::string m_filename;
};
}
#endif // TORRENT_VERBOSE_LOGGING || TORRENT_LOGGING || TORRENT_ERROR_LOGGING
#endif // TORRENT_DEBUG_HPP_INCLUDED

View File

@ -1,60 +0,0 @@
/*
Copyright (c) 2006, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_LOGGER_HPP_INCLUDED
#define TORRENT_LOGGER_HPP_INCLUDED
#ifdef _MSC_VER
#pragma warning(push, 1)
#endif
#include <boost/shared_ptr.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "libtorrent/config.hpp"
#if TORRENT_USE_IOSTREAM
namespace libtorrent
{
struct torrent_plugin;
class torrent;
boost::shared_ptr<torrent_plugin> create_logger_plugin(torrent*);
}
#endif
#endif // TORRENT_LOGGER_HPP_INCLUDED

View File

@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
#include <stdio.h>
#endif
@ -96,7 +96,7 @@ private:
#if TORRENT_USE_IPV6
bool m_disabled6;
#endif
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
FILE* m_log;
#endif
};

View File

@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <string>
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
#include "libtorrent/debug.hpp"
#endif
@ -417,7 +417,7 @@ namespace libtorrent
void set_holepunch_mode()
{
m_holepunch_mode = true;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** HOLEPUNCH MODE ***");
#endif
}
@ -553,12 +553,11 @@ namespace libtorrent
void decrease_est_reciprocation_rate();
int est_reciprocation_rate() const { return m_est_reciprocation_rate; }
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
virtual void peer_log(char const* fmt, ...) const;
boost::shared_ptr<logger> m_logger;
#endif
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
ptime m_connect_time;
ptime m_bitfield_time;
ptime m_unchoke_time;
@ -654,7 +653,7 @@ namespace libtorrent
virtual boost::optional<piece_block_progress>
downloading_piece_progress() const
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** downloading_piece_progress() dispatched to the base class!");
#endif
return boost::optional<piece_block_progress>();

View File

@ -85,7 +85,7 @@ namespace libtorrent
virtual bool failed() const = 0;
virtual stat const& statistics() const = 0;
virtual void get_peer_info(peer_info& p) const = 0;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
virtual void peer_log(char const* fmt, ...) const = 0;
#endif

View File

@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct logger;
struct external_ip;
struct ip_filter;
class port_filter;

View File

@ -70,7 +70,6 @@ namespace libtorrent
class torrent;
class peer_connection;
struct bitfield;
struct logger;
struct counters;
struct TORRENT_EXTRA_EXPORT piece_block

View File

@ -164,12 +164,6 @@ namespace libtorrent
boost::shared_ptr<aux::session_impl> m_impl;
};
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#define TORRENT_LOGPATH_ARG_DEFAULT , std::string logpath = "."
#else
#define TORRENT_LOGPATH_ARG_DEFAULT
#endif
// This free function returns the list of available metrics exposed by
// libtorrent's statistics API. Each metric has a name and a *value index*.
// The value index is the index into the array in session_stats_alert where
@ -221,8 +215,7 @@ namespace libtorrent
session(fingerprint const& print = fingerprint("LT"
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
, int flags = start_default_features | add_default_plugins
, boost::uint32_t alert_mask = alert::error_notification
TORRENT_LOGPATH_ARG_DEFAULT)
, boost::uint32_t alert_mask = alert::error_notification)
{
TORRENT_CFG();
settings_pack pack;
@ -236,17 +229,13 @@ namespace libtorrent
}
init(print);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
set_log_path(logpath);
#endif
start(flags, pack);
}
session(fingerprint const& print
, std::pair<int, int> listen_port_range
, char const* listen_interface = "0.0.0.0"
, int flags = start_default_features | add_default_plugins
, int alert_mask = alert::error_notification
TORRENT_LOGPATH_ARG_DEFAULT)
, int alert_mask = alert::error_notification)
{
TORRENT_CFG();
TORRENT_ASSERT(listen_port_range.first > 0);
@ -267,9 +256,6 @@ namespace libtorrent
pack.set_bool(settings_pack::enable_dht, false);
}
init(print);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
set_log_path(logpath);
#endif
start(flags, pack);
}
@ -1233,7 +1219,6 @@ namespace libtorrent
private:
void init(fingerprint const& id);
void set_log_path(std::string const& p);
void start(int flags, settings_pack const& pack);
// data shared between the main thread

View File

@ -93,10 +93,6 @@ namespace libtorrent
{
class http_parser;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
struct logger;
#endif
class piece_manager;
struct torrent_plugin;
struct bitfield;
@ -977,11 +973,9 @@ namespace libtorrent
time_t last_seen_complete() const { return m_last_seen_complete; }
// LOGGING
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
virtual void debug_log(const char* fmt, ...) const;
void log_to_all_peers(char const* message);
boost::shared_ptr<logger> m_logger;
ptime m_logger_time;
ptime m_dht_start_time;
#endif

View File

@ -221,7 +221,7 @@ namespace libtorrent
, const std::string& msg
, int retry_interval) = 0;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
virtual void debug_log(const char* fmt, ...) const = 0;
#endif
};

View File

@ -49,11 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/shared_ptr.hpp>
#include <set>
#if defined(TORRENT_UPNP_LOGGING)
#include <fstream>
#endif
namespace libtorrent
{

View File

@ -156,7 +156,7 @@ void utp_send_ack(utp_socket_impl* s);
void utp_socket_drained(utp_socket_impl* s);
void utp_writable(utp_socket_impl* s);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
int socket_impl_size();
#endif

View File

@ -77,7 +77,6 @@ libtorrent_rasterbar_la_SOURCES = \
ip_filter.cpp \
ip_voter.cpp \
lazy_bdecode.cpp \
logger.cpp \
lsd.cpp \
lt_trackers.cpp \
magnet_uri.cpp \

View File

@ -715,5 +715,20 @@ namespace libtorrent {
return msg;
}
std::string log_alert::message() const
{
return msg;
}
std::string torrent_log_alert::message() const
{
return torrent_alert::message() + ": " + msg;
}
std::string peer_log_alert::message() const
{
return torrent_alert::message() + " [" + print_endpoint(ip) + "] " + msg;
}
} // namespace libtorrent

View File

@ -125,7 +125,7 @@ namespace libtorrent
, m_in_constructor(true)
#endif
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** bt_peer_connection");
#endif
@ -173,7 +173,7 @@ namespace libtorrent
if (t->graceful_pause())
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** ON_CONNECTED [ graceful-paused ]");
#endif
disconnect(error_code(errors::torrent_paused), op_bittorrent);
@ -193,7 +193,7 @@ namespace libtorrent
if (is_ssl(*get_socket()))
out_enc_policy = settings_pack::pe_disabled;
#endif
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
char const* policy_name[] = {"forced", "enabled", "disabled"};
peer_log("*** outgoing encryption policy: %s", policy_name[out_enc_policy]);
#endif
@ -254,7 +254,7 @@ namespace libtorrent
void bt_peer_connection::on_metadata()
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** ON_METADATA");
#endif
// connections that are still in the handshake
@ -278,7 +278,7 @@ namespace libtorrent
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> DHT_PORT [ %d ]", listen_port);
#endif
char msg[] = {0,0,0,3, msg_dht_port, 0, 0};
@ -294,7 +294,7 @@ namespace libtorrent
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake);
m_sent_bitfield = true;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> HAVE_ALL");
#endif
char msg[] = {0,0,0,1, msg_have_all};
@ -308,7 +308,7 @@ namespace libtorrent
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake);
m_sent_bitfield = true;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> HAVE_NONE");
#endif
char msg[] = {0,0,0,1, msg_have_none};
@ -325,7 +325,7 @@ namespace libtorrent
if (!m_supports_fast) return;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]"
, r.piece, r.start, r.length);
#endif
@ -371,7 +371,7 @@ namespace libtorrent
TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata());
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> SUGGEST [ piece: %d num_peers: %d ]", piece
, t->has_picker() ? t->picker().get_availability(piece) : -1);
#endif
@ -436,7 +436,7 @@ namespace libtorrent
TORRENT_ASSERT(!m_dh_key_exchange.get());
TORRENT_ASSERT(!m_sent_handshake);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
if (is_outgoing())
peer_log("*** initiating encrypted handshake");
#endif
@ -450,7 +450,7 @@ namespace libtorrent
int pad_size = random() % 512;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log(" pad size: %d", pad_size);
#endif
@ -464,7 +464,7 @@ namespace libtorrent
std::generate(ptr, ptr + pad_size, random_byte);
send_buffer(msg, buf_size);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log(" sent DH key");
#endif
}
@ -528,7 +528,7 @@ namespace libtorrent
if ((crypto_provide & settings_pack::pe_both) == 0)
crypto_provide = settings_pack::pe_both;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
char const* level[] = {"plaintext", "rc4", "plaintext rc4"};
peer_log(" crypto provide : [ %s ]"
, level[crypto_provide-1]);
@ -568,7 +568,7 @@ namespace libtorrent
else // 0x01
m_rc4_encrypted = false;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log(" crypto select : [ %s ]"
, (crypto_select == 0x01) ? "plaintext" : "rc4");
#endif
@ -645,7 +645,7 @@ namespace libtorrent
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log(" computed RC4 keys");
#endif
}
@ -777,7 +777,7 @@ namespace libtorrent
// we support FAST extension
*(ptr + 7) |= 0x04;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
std::string bitmask;
for (int k = 0; k < 8; ++k)
{
@ -808,7 +808,7 @@ namespace libtorrent
memcpy(ptr, &m_our_peer_id[0], 20);
ptr += 20;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
{
char hex_pid[41];
to_hex((char const*)&m_our_peer_id[0], 20, hex_pid);
@ -891,7 +891,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== KEEPALIVE");
#endif
incoming_keepalive();
@ -1231,7 +1231,7 @@ namespace libtorrent
if (recv_pos < header_size) return;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
// peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d"
// , p.piece, p.start, p.length);
#endif
@ -1251,7 +1251,7 @@ namespace libtorrent
if (merkle && list_size > 0)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size);
#endif
lazy_entry hash_list;
@ -1502,7 +1502,7 @@ namespace libtorrent
#endif
else
{
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
error_code ec;
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]"
@ -1520,7 +1520,7 @@ namespace libtorrent
{
case hp_rendezvous: // rendezvous
{
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]"
, print_address(ep.address()).c_str());
#endif
@ -1554,7 +1554,7 @@ namespace libtorrent
torrent_peer* p = t->add_peer(ep, peer_info::pex);
if (p == 0 || p->connection)
{
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: failed to add peer ]"
, print_address(ep.address()).c_str());
#endif
@ -1564,7 +1564,7 @@ namespace libtorrent
}
if (p->banned)
{
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]"
, print_address(ep.address()).c_str());
#endif
@ -1583,7 +1583,7 @@ namespace libtorrent
t->update_want_peers();
if (p->connection)
p->connection->set_holepunch_mode();
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
peer_log("<== HOLEPUNCH [ msg:connect to: %s ]"
, print_address(ep.address()).c_str());
#endif
@ -1591,7 +1591,7 @@ namespace libtorrent
case hp_failed:
{
boost::uint32_t error = detail::read_uint32(ptr);
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
error_code ec;
char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"};
peer_log("<== HOLEPUNCH [ msg:failed error: %d msg: %s ]", error
@ -1600,7 +1600,7 @@ namespace libtorrent
// #error deal with holepunch errors
(void)error;
} break;
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
default:
{
error_code ec;
@ -1620,7 +1620,7 @@ namespace libtorrent
else detail::write_uint8(1, ptr);
detail::write_endpoint(ep, ptr);
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
error_code ec;
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
static const char* hp_error_string[] = {"", "no such peer", "not connected", "no support", "no self"};
@ -1691,13 +1691,13 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return;
if (m_recv_buffer.packet_size() != 3)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== UPLOAD_ONLY [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
#endif
return;
}
bool ul = detail::read_uint8(recv_buffer.begin) != 0;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false"));
#endif
set_upload_only(ul);
@ -1709,13 +1709,13 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return;
if (m_recv_buffer.packet_size() != 3)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== SHARE_MODE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
#endif
return;
}
bool sm = detail::read_uint8(recv_buffer.begin) != 0;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== SHARE_MODE [ %s ]", (sm?"true":"false"));
#endif
set_share_mode(sm);
@ -1725,7 +1725,7 @@ namespace libtorrent
if (extended_id == holepunch_msg)
{
if (!m_recv_buffer.packet_finished()) return;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== HOLEPUNCH");
#endif
on_holepunch();
@ -1737,7 +1737,7 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return;
if (m_recv_buffer.packet_size() != 6)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== DONT_HAVE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
#endif
return;
@ -1747,7 +1747,7 @@ namespace libtorrent
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
if (m_recv_buffer.packet_finished())
peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]"
, extended_id, m_recv_buffer.packet_size());
@ -1780,14 +1780,14 @@ namespace libtorrent
int ret = lazy_bdecode(recv_buffer.begin + 2, recv_buffer.end, root, ec, &pos);
if (ret != 0 || ec || root.type() != lazy_entry::dict_t)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** invalid extended handshake: %s pos: %d"
, ec.message().c_str(), pos);
#endif
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str());
#endif
@ -1972,7 +1972,7 @@ namespace libtorrent
// connections, don't sent upload-only
if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> UPLOAD_ONLY [ %d ]"
, int(t->is_upload_only() && !t->super_seeding()));
#endif
@ -2073,7 +2073,7 @@ namespace libtorrent
if (t->super_seeding())
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log(" *** NOT SENDING BITFIELD, super seeding");
#endif
if (m_supports_fast) write_have_none();
@ -2104,7 +2104,7 @@ namespace libtorrent
else if (t->num_have() == 0)
{
// don't send a bitfield if we don't have any pieces
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log(" *** NOT SENDING BITFIELD");
#endif
m_sent_bitfield = true;
@ -2175,7 +2175,7 @@ namespace libtorrent
, end(t->predictive_pieces().end()); i != end; ++i)
msg[5 + *i / 8] |= (0x80 >> (*i & 7));
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
std::string bitfield_string;
bitfield_string.resize(num_pieces);
@ -2196,7 +2196,7 @@ namespace libtorrent
{
for (int i = 0; i < num_lazy_pieces; ++i)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]);
#endif
write_have(lazy_pieces[i]);
@ -2312,7 +2312,7 @@ namespace libtorrent
stats_counters().inc_stats_counter(counters::num_outgoing_ext_handshake);
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str());
#endif
}
@ -2526,7 +2526,7 @@ namespace libtorrent
if (!m_enc_handler.is_recv_plaintext())
{
int consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
if (consumed + bytes_transferred > 0)
peer_log("<== decrypted block [ s = %d ]", consumed + bytes_transferred);
#endif
@ -2598,7 +2598,7 @@ namespace libtorrent
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** received DH key");
#endif
@ -2697,7 +2697,7 @@ namespace libtorrent
else
{
std::size_t bytes_processed = syncoffset + 20;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** sync point (hash) found at offset %d"
, m_sync_bytes_read + bytes_processed - 20);
#endif
@ -2746,7 +2746,7 @@ namespace libtorrent
}
init_pe_rc4_handler(m_dh_key_exchange->get_secret(), ti->info_hash());
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** stream key found, torrent located");
#endif
}
@ -2769,7 +2769,7 @@ namespace libtorrent
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** verification constant found");
#endif
m_state = read_pe_cryptofield;
@ -2833,7 +2833,7 @@ namespace libtorrent
else
{
std::size_t bytes_processed = syncoffset + 8;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** sync point (verification constant) found at offset %d"
, m_sync_bytes_read + bytes_processed - 8);
#endif
@ -2868,7 +2868,7 @@ namespace libtorrent
boost::uint32_t crypto_field = detail::read_uint32(recv_buffer.begin);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** crypto %s : [%s%s ]"
, is_outgoing() ? "select" : "provide"
, (crypto_field & 1) ? " plaintext" : ""
@ -2982,7 +2982,7 @@ namespace libtorrent
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** len(IA) : %d", len_ia);
#endif
if (len_ia == 0)
@ -3028,7 +3028,7 @@ namespace libtorrent
buffer::interval wr_buf = m_recv_buffer.mutable_buffer();
rc4_decrypt(wr_buf.begin, m_recv_buffer.packet_size());
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** decrypted ia : %d bytes", m_recv_buffer.packet_size());
#endif
@ -3077,7 +3077,7 @@ namespace libtorrent
wr_buf.begin += m_recv_buffer.packet_size();
rc4_decrypt(wr_buf.begin, wr_buf.left());
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** decrypted remaining %d bytes", wr_buf.left());
#endif
}
@ -3118,14 +3118,14 @@ namespace libtorrent
memcmp(recv_buffer.begin, protocol_string, 20) != 0)
{
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** unrecognized protocol header");
#endif
#ifdef TORRENT_USE_OPENSSL
if (is_ssl(*get_socket()))
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** SSL peers are not allowed to use any other encryption");
#endif
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
@ -3151,7 +3151,7 @@ namespace libtorrent
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** attempting encrypted connection");
#endif
m_state = read_pe_dhkey;
@ -3179,7 +3179,7 @@ namespace libtorrent
}
#endif
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== BitTorrent protocol");
#endif
}
@ -3199,7 +3199,7 @@ namespace libtorrent
recv_buffer = m_recv_buffer.get();
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
std::string extensions;
extensions.resize(8 * 8);
for (int i=0; i < 8; ++i)
@ -3255,14 +3255,14 @@ namespace libtorrent
if (!std::equal(recv_buffer.begin + 8, recv_buffer.begin + 28
, (const char*)t->torrent_file().info_hash().begin()))
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** received invalid info_hash");
#endif
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
return;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<<< info_hash received");
#endif
}
@ -3298,7 +3298,7 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return;
recv_buffer = m_recv_buffer.get();
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
{
char hex_pid[41];
to_hex(recv_buffer.begin, 20, hex_pid);
@ -3380,7 +3380,7 @@ namespace libtorrent
if (m_supports_extensions) write_extensions();
#endif
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("<== HANDSHAKE");
#endif
// consider this a successful connection, reset the failcount
@ -3496,7 +3496,7 @@ namespace libtorrent
int bt_peer_connection::hit_send_barrier(std::vector<asio::mutable_buffer>& iovec)
{
int next_barrier = m_enc_handler.encrypt(iovec);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
if (next_barrier != 0)
peer_log("==> encrypted block [ s = %d ]", next_barrier);
#endif

View File

@ -77,7 +77,7 @@ namespace libtorrent
prefer_whole_pieces(1);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** http_seed_connection");
#endif
}
@ -195,7 +195,7 @@ namespace libtorrent
request += "\r\n\r\n";
m_first_request = false;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> %s", request.c_str());
#endif
@ -214,7 +214,7 @@ namespace libtorrent
if (error)
{
received_bytes(0, bytes_transferred);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** http_seed_connection error: %s", error.message().c_str());
#endif
return;
@ -376,7 +376,7 @@ namespace libtorrent
}
else
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
#endif
TORRENT_ASSERT(bytes_transferred >= size_t(header_size - m_partial_chunk_header));
@ -414,7 +414,7 @@ namespace libtorrent
int retry_time = atol(std::string(recv_buffer.begin, recv_buffer.end).c_str());
if (retry_time <= 0) retry_time = 60;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** retrying in %d seconds", retry_time);
#endif

View File

@ -240,7 +240,7 @@ namespace libtorrent
// the url + 100 estimated header size
sent_bytes(url.size() + 100);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb)
@ -274,7 +274,7 @@ namespace libtorrent
++i;
}
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb)
{

View File

@ -1,237 +0,0 @@
/*
Copyright (c) 2006-2014, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef _MSC_VER
#pragma warning(push, 1)
#endif
#include <boost/shared_ptr.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include <vector>
#include "libtorrent/extensions/logger.hpp"
#include "libtorrent/extensions.hpp"
#include "libtorrent/entry.hpp"
#include "libtorrent/peer_request.hpp"
#if TORRENT_USE_IOSTREAM && !defined TORRENT_DISABLE_EXTENSIONS
#include <fstream>
#include "libtorrent/file.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/lazy_entry.hpp"
#include "libtorrent/peer_connection.hpp"
namespace libtorrent {
class peer_connection;
namespace
{
struct logger_peer_plugin : peer_plugin
{
logger_peer_plugin(std::string const& filename)
{
error_code ec;
std::string dir = complete("libtorrent_ext_logs");
if (!exists(dir)) create_directories(dir, ec);
m_file.open(combine_path(dir, filename).c_str(), std::ios_base::out);
m_file << "\n\n\n";
log_timestamp();
m_file << "*** starting log ***\n";
}
void log_timestamp()
{
m_file << time_now_string() << ": ";
}
// can add entries to the extension handshake
virtual void add_handshake(entry&) {}
// called when the extension handshake from the other end is received
virtual bool on_extension_handshake(lazy_entry const& h)
{
log_timestamp();
m_file << "<== EXTENSION_HANDSHAKE\n" << print_entry(h);
return true;
}
// returning true from any of the message handlers
// indicates that the plugin has handeled the message.
// it will break the plugin chain traversing and not let
// anyone else handle the message, including the default
// handler.
virtual bool on_choke()
{
log_timestamp();
m_file << "<== CHOKE\n";
m_file.flush();
return false;
}
virtual bool on_unchoke()
{
log_timestamp();
m_file << "<== UNCHOKE\n";
m_file.flush();
return false;
}
virtual bool on_interested()
{
log_timestamp();
m_file << "<== INTERESTED\n";
m_file.flush();
return false;
}
virtual bool on_not_interested()
{
log_timestamp();
m_file << "<== NOT_INTERESTED\n";
m_file.flush();
return false;
}
virtual bool on_have(int index)
{
log_timestamp();
m_file << "<== HAVE [" << index << "]\n";
m_file.flush();
return false;
}
virtual bool on_bitfield(bitfield const& bitfield_)
{
log_timestamp();
m_file << "<== BITFIELD\n";
m_file.flush();
return false;
}
virtual bool on_request(peer_request const& r)
{
log_timestamp();
m_file << "<== REQUEST [ piece: " << r.piece << " | s: " << r.start
<< " | l: " << r.length << " ]\n";
m_file.flush();
return false;
}
virtual bool on_piece(peer_request const& r, disk_buffer_holder& data)
{
log_timestamp();
m_file << "<== PIECE [ piece: " << r.piece << " | s: " << r.start
<< " | l: " << r.length << " ]\n";
m_file.flush();
return false;
}
virtual bool on_cancel(peer_request const& r)
{
log_timestamp();
m_file << "<== CANCEL [ piece: " << r.piece << " | s: " << r.start
<< " | l: " << r.length << " ]\n";
m_file.flush();
return false;
}
// called when an extended message is received. If returning true,
// the message is not processed by any other plugin and if false
// is returned the next plugin in the chain will receive it to
// be able to handle it
virtual bool on_extended(int length
, int msg, buffer::const_interval body)
{ return false; }
virtual bool on_unknown_message(int length, int msg
, buffer::const_interval body)
{
if (body.left() < length) return false;
log_timestamp();
m_file << "<== UNKNOWN [ msg: " << msg
<< " | l: " << length << " ]\n";
m_file.flush();
return false;
}
virtual void on_piece_pass(int index)
{
log_timestamp();
m_file << "*** HASH PASSED *** [ piece: " << index << " ]\n";
m_file.flush();
}
virtual void on_piece_failed(int index)
{
log_timestamp();
m_file << "*** HASH FAILED *** [ piece: " << index << " ]\n";
m_file.flush();
}
private:
std::ofstream m_file;
};
struct logger_plugin : torrent_plugin
{
virtual boost::shared_ptr<peer_plugin> new_connection(
peer_connection* pc)
{
error_code ec;
return boost::shared_ptr<peer_plugin>(new logger_peer_plugin(
pc->remote().address().to_string(ec) + "_"
+ to_string(pc->remote().port()).elems + ".log"));
}
};
} }
namespace libtorrent
{
boost::shared_ptr<torrent_plugin> create_logger_plugin(torrent*)
{
return boost::shared_ptr<torrent_plugin>(new logger_plugin());
}
}
#endif

View File

@ -80,7 +80,8 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
, m_disabled6(false)
#endif
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
// TODO: instead if writing to a file, post alerts. Or call a log callback
m_log = fopen("lsd.log", "w+");
if (m_log == NULL)
{
@ -92,7 +93,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
error_code ec;
m_socket.open(ios, ec);
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (ec)
{
if (m_log) fprintf(m_log, "FAILED TO OPEN SOCKET: (%d) %s\n"
@ -102,7 +103,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
#if TORRENT_USE_IPV6
m_socket6.open(ios, ec);
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (ec)
{
if (m_log) fprintf(m_log, "FAILED TO OPEN SOCKET6: (%d) %s\n"
@ -114,7 +115,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
lsd::~lsd()
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fclose(m_log);
#endif
}
@ -149,7 +150,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
to_hex((char const*)&ih[0], 20, ih_hex);
char msg[200];
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s ==> announce: ih: %s port: %u\n"
, time_now_string(), ih_hex, listen_port);
#endif
@ -163,7 +164,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
if (ec)
{
m_disabled = true;
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s failed to send message: (%d) %s"
, time_now_string(), ec.value(), ec.message().c_str());
#endif
@ -179,7 +180,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
if (ec)
{
m_disabled6 = true;
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s failed to send message6: (%d) %s"
, time_now_string(), ec.value(), ec.message().c_str());
#endif
@ -228,7 +229,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
if (!p.header_finished() || error)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s <== announce: incomplete HTTP message\n", time_now_string());
#endif
return;
@ -236,7 +237,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
if (p.method() != "bt-search")
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s <== announce: invalid HTTP method: %s\n"
, time_now_string(), p.method().c_str());
#endif
@ -246,7 +247,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
std::string const& port_str = p.header("port");
if (port_str.empty())
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s <== announce: invalid BT-SEARCH, missing port\n"
, time_now_string());
#endif
@ -266,7 +267,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
boost::int32_t cookie = strtol(cookie_iter->second.c_str(), NULL, 16);
if (cookie == m_cookie)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s <== announce: ignoring packet (cookie matched our own): %x == %x\n"
, time_now_string(), cookie, m_cookie);
#endif
@ -282,7 +283,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
std::string const& ih_str = i->second;
if (ih_str.size() != 40)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s <== announce: invalid BT-SEARCH, invalid infohash: %s\n"
, time_now_string(), ih_str.c_str());
#endif
@ -294,7 +295,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
if (!ih.is_all_zeros() && port != 0)
{
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
#if defined TORRENT_LOGGING
if (m_log) fprintf(m_log, "%s *** incoming local announce %s:%d ih: %s\n"
, time_now_string(), print_address(from.address()).c_str()
, port, ih_str.c_str());

View File

@ -210,27 +210,23 @@ namespace libtorrent { namespace
// invalid tex message
if (added == 0)
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_pc.m_logger) << time_now_string() << " <== LT_TEX [ NOT A DICTIONARY ]\n";
#ifdef TORRENT_LOGGING
m_pc.peer_log(" <== LT_TEX [ NOT A DICTIONARY ]");
#endif
return true;
}
#ifdef TORRENT_VERBOSE_LOGGING
std::stringstream log_line;
#endif
if (m_tp.num_tex_trackers() >= 50)
{
#ifdef TORRENT_VERBOSE_LOGGING
log_line << time_now_string() << " <== LT_TEX [ "
"we already have " << m_tp.num_tex_trackers() << " trackers "
"from tex, don't add any more";
(*m_pc.m_logger) << log_line.str();
#ifdef TORRENT_LOGGING
m_pc.peer_log(" <== LT_TEX [ we already have %d trackers "
"from tex, don't add any more", m_tp.num_tex_trackers());
#endif
return true;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
std::stringstream log_line;
log_line << time_now_string() << " <== LT_TEX [ "
"added: ";
#endif
@ -264,7 +260,7 @@ namespace libtorrent { namespace
if (m_tp.num_tex_trackers() >= 50)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
log_line << "**reached-limit** ";
#endif
break;
@ -276,13 +272,13 @@ namespace libtorrent { namespace
if (m_torrent.add_tracker(e))
m_tp.increment_tracker_counter();
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
log_line << e.url << " ";
#endif
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
log_line << "]\n";
(*m_pc.m_logger) << log_line.str();
m_pc.peer_log("%s", log_line.str().c_str());
#endif
return true;
}
@ -334,7 +330,7 @@ namespace libtorrent { namespace
if (!m_torrent.valid_metadata() || m_torrent.torrent_file().priv())
return false;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
std::stringstream log_line;
log_line << time_now_string() << " ==> LT_TEX [ "
"added: ";
@ -346,16 +342,16 @@ namespace libtorrent { namespace
{
if (!send_tracker(*i)) continue;
added.push_back(i->url);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
log_line << i->url << " ";
#endif
}
std::vector<char> tex_msg;
bencode(std::back_inserter(tex_msg), tex);
#ifdef TORRENT_VERBOSE_LOGGING
log_line << "]\n";
(*m_pc.m_logger) << log_line.str();
#ifdef TORRENT_LOGGING
log_line << "]";
m_pc.peer_log("%s", log_line.str().c_str());
#endif
char msg[6];

View File

@ -304,7 +304,7 @@ namespace libtorrent { namespace
// abort if the peer doesn't support the metadata extension
if (m_message_index == 0) return;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("==> METADATA_REQUEST [ start: %d | size: %d ]\n"
, start, size);
#endif
@ -342,7 +342,7 @@ namespace libtorrent { namespace
char msg[15];
char* ptr = msg;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("==> METADATA [ start: %d | total_size: %d | offset: %d | data_size: %d ]"
, req.first, req.second, offset.first, offset.second);
#endif
@ -363,7 +363,7 @@ namespace libtorrent { namespace
}
else
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("==> DONT HAVE METADATA\n");
#endif
char msg[4+3];
@ -404,7 +404,7 @@ namespace libtorrent { namespace
int start = detail::read_uint8(body.begin);
int size = detail::read_uint8(body.begin) + 1;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== METADATA_REQUEST [ start: %d | size: %d ]\n"
, start, size);
#endif
@ -427,7 +427,7 @@ namespace libtorrent { namespace
int offset = detail::read_int32(body.begin);
int data_size = length - 9;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== METADATA [ total_size: %d | offset: %d | data_size: %d ]"
,total_size, offset, data_size);
#endif
@ -470,7 +470,7 @@ namespace libtorrent { namespace
if (m_waiting_metadata_request)
m_tp.cancel_metadata_request(m_last_metadata_request);
m_waiting_metadata_request = false;
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== DONT HAVE METADATA\n");
#endif
break;

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_io.hpp" // for print_endpoint
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
#include "libtorrent/socket_io.hpp" // for print_endpoint
#include "libtorrent/ip_voter.hpp" // for external_ip
#endif
@ -603,7 +603,7 @@ namespace libtorrent
TORRENT_ASSERT(i->connection != &c);
TORRENT_ASSERT(i->address() == c.remote().address());
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
c.peer_log("*** DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]"
, print_address(c.remote().address()).c_str()
, print_address(i->address()).c_str());
@ -660,7 +660,7 @@ namespace libtorrent
if (our_port < other_port)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
#endif
@ -678,7 +678,7 @@ namespace libtorrent
}
else
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
#endif

View File

@ -90,7 +90,7 @@ namespace libtorrent
- (int)c.download_queue().size()
- (int)c.request_queue().size();
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
c.peer_log("*** PIECE_PICKER [ dlq: %d rqq: %d target: %d req: %d engame: %d ]"
, int(c.download_queue().size()), int(c.request_queue().size())
, c.desired_queue_size(), num_requests, c.endgame());
@ -167,7 +167,7 @@ namespace libtorrent
, state, c.picker_options(), suggested, t.num_peers()
, ses.stats_counters());
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
c.peer_log("*** PIECE_PICKER [ prefer_whole: %d picked: %d ]"
, prefer_whole_pieces, int(interesting_pieces.size()));
#endif
@ -232,7 +232,7 @@ namespace libtorrent
= std::find_if(dq.begin(), dq.end(), has_block(*i));
if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted);
#endif
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
c.peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in queue ]"
, i->piece_index, i->block_index);
#endif

View File

@ -404,14 +404,6 @@ namespace libtorrent
m_impl.reset(new session_impl(id));
}
void session::set_log_path(std::string const& p)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING \
|| defined TORRENT_ERROR_LOGGING
m_impl->set_log_path(p);
#endif
}
void session::start(int flags, settings_pack const& pack)
{
#ifndef TORRENT_DISABLE_EXTENSIONS
@ -419,6 +411,7 @@ namespace libtorrent
{
add_extension(create_ut_pex_plugin);
add_extension(create_ut_metadata_plugin);
// TODO: 3 lt_trackers should not be on by default
add_extension(create_lt_trackers_plugin);
add_extension(create_smart_ban_plugin);
}

View File

@ -95,15 +95,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/torrent_peer.hpp"
#include "libtorrent/choker.hpp"
#if defined TORRENT_VERBOSE_LOGGING
#include "libtorrent/socket_io.hpp"
#endif
#ifndef TORRENT_WINDOWS
#include <sys/resource.h>
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
#include "libtorrent/socket_io.hpp"
// for logging stat layout
#include "libtorrent/stat.hpp"
@ -120,17 +118,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/http_tracker_connection.hpp"
#include "libtorrent/udp_tracker_connection.hpp"
#include "libtorrent/debug.hpp"
#if TORRENT_USE_IOSTREAM
namespace libtorrent {
std::ofstream logger::log_file;
std::string logger::open_filename;
mutex logger::file_mutex;
}
#endif // TORRENT_USE_IOSTREAM
#endif
#endif // TORRENT_LOGGING
#ifdef TORRENT_USE_GCRYPT
@ -415,9 +403,6 @@ namespace aux {
, m_host_resolver(m_io_service)
, m_download_connect_attempts(0)
, m_tick_residual(0)
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
, m_logpath(".")
#endif
, m_deferred_submit_disk_jobs(false)
, m_pending_auto_manage(false)
, m_need_auto_manage(false)
@ -475,9 +460,8 @@ namespace aux {
void session_impl::start_session(settings_pack const& pack)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
m_logger = create_log("main_session", listen_port(), false);
session_log("log created");
#if defined TORRENT_LOGGING
session_log("start session");
#endif
error_code ec;
@ -533,22 +517,16 @@ namespace aux {
// TODO: there's no rule here to make uTP connections not have the global or
// local rate limits apply to it. This used to be the default.
#ifdef TORRENT_UPNP_LOGGING
m_upnp_log.open("upnp.log", std::ios::in | std::ios::out | std::ios::trunc);
#endif
#if defined TORRENT_LOGGING
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
char tmp[300];
snprintf(tmp, sizeof(tmp), "libtorrent configuration: %s\n"
session_log("libtorrent configuration: %s\n"
"libtorrent version: %s\n"
"libtorrent revision: %s\n\n"
, TORRENT_CFG_STRING
, LIBTORRENT_VERSION
, LIBTORRENT_REVISION);
(*m_logger) << tmp;
#endif // TORRENT_VERBOSE_LOGGING
#endif // TORRENT_LOGGING
#if TORRENT_USE_RLIMIT
// ---- auto-cap max connections ----
@ -556,7 +534,7 @@ namespace aux {
struct rlimit rl;
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log(" max number of open files: %d", rl.rlim_cur);
#endif
// deduct some margin for epoll/kqueue, log files,
@ -568,7 +546,7 @@ namespace aux {
m_settings.get_int(settings_pack::connections_limit)
, int(rl.rlim_cur * 8 / 10)));
// 20% goes towards regular files (see disk_io_thread)
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log(" max connections: %d", m_settings.get_int(settings_pack::connections_limit));
session_log(" max files: %d", int(rl.rlim_cur * 2 / 10));
#endif
@ -576,7 +554,7 @@ namespace aux {
#endif // TORRENT_USE_RLIMIT
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log(" generated peer ID: %s", m_peer_id.to_string().c_str());
#endif
@ -585,7 +563,7 @@ namespace aux {
// call update_* after settings set initialized
m_io_service.post(boost::bind(&session_impl::init_settings, this));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log(" spawning network thread");
#endif
m_thread.reset(new thread(boost::bind(&session_impl::main_thread, this)));
@ -675,7 +653,7 @@ namespace aux {
void session_impl::init()
{
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
session_log(" *** session thread init");
#endif
@ -704,7 +682,7 @@ namespace aux {
update_dht_announce_interval();
#endif
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
session_log(" done starting session");
#endif
}
@ -964,7 +942,7 @@ namespace aux {
TORRENT_ASSERT(is_single_thread());
if (m_paused) return;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
session_log(" *** session paused ***");
#endif
m_paused = true;
@ -1046,7 +1024,7 @@ namespace aux {
m_i2p_listen_socket.reset();
#endif
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" aborting all torrents (%d)", m_torrents.size());
#endif
// abort all torrents
@ -1057,12 +1035,12 @@ namespace aux {
}
m_torrents.clear();
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" aborting all tracker requests");
#endif
m_tracker_manager.abort_all_requests();
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" aborting all connections (%d)", m_connections.size());
#endif
// abort all connections
@ -1587,7 +1565,7 @@ namespace aux {
if (m_alerts.should_post<listen_failed_alert>())
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("failed to open socket: %s: %s"
, device.c_str(), ec.message().c_str());
#endif
@ -1629,7 +1607,7 @@ namespace aux {
while (ec && retries > 0)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("failed to bind to interface [%s] \"%s\": %s"
, device.c_str(), bind_ip.to_string(ec).c_str()
, ec.message().c_str());
@ -1657,7 +1635,7 @@ namespace aux {
// not even that worked, give up
if (m_alerts.should_post<listen_failed_alert>())
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("cannot bind to interface \"%s\": %s"
, device.c_str(), ec.message().c_str());
#endif
@ -1675,7 +1653,7 @@ namespace aux {
{
if (m_alerts.should_post<listen_failed_alert>())
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("cannot listen on interface \"%s\": %s"
, device.c_str(), ec.message().c_str());
#endif
@ -1692,11 +1670,9 @@ namespace aux {
{
if (m_alerts.should_post<listen_failed_alert>())
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
char msg[200];
snprintf(msg, 200, "failed to get peer name \"%s\": %s"
#if defined TORRENT_LOGGING
session_log("failed to get peer name \"%s\": %s"
, device.c_str(), ec.message().c_str());
(*m_logger) << time_now_string() << msg << "\n";
#endif
}
}
@ -1706,7 +1682,7 @@ namespace aux {
, (flags & open_ssl_socket) ? listen_succeeded_alert::tcp_ssl
: listen_succeeded_alert::tcp));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log(" listening on: %s external port: %d"
, print_endpoint(tcp::endpoint(bind_ip, port)).c_str(), ret.external_port);
#endif
@ -1715,9 +1691,8 @@ namespace aux {
void session_impl::open_listen_port()
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
m_logger = create_log("main_session", listen_port(), false);
session_log("log created");
#if defined TORRENT_LOGGING
session_log("open listen port");
#endif
TORRENT_ASSERT(is_single_thread());
@ -1909,11 +1884,9 @@ retry:
if (m_listen_sockets.empty() && ec)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
char msg[200];
snprintf(msg, sizeof(msg), "cannot bind TCP listen socket to interface \"%s\": %s"
#if defined TORRENT_LOGGING
session_log("cannot bind TCP listen socket to interface \"%s\": %s"
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
(*m_logger) << msg << "\n";
#endif
if (m_listen_port_retries > 0)
{
@ -1934,7 +1907,7 @@ retry:
m_ssl_udp_socket.bind(ssl_bind_if, ec);
if (ec)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("SSL: cannot bind to UDP interface \"%s\": %s"
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
#endif
@ -1959,7 +1932,7 @@ retry:
m_udp_socket.bind(udp::endpoint(m_listen_interface.address(), m_listen_interface.port()), ec);
if (ec)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("cannot bind to UDP interface \"%s\": %s"
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
#endif
@ -2014,10 +1987,6 @@ retry:
tcp::endpoint local = m_listen_sockets.front().sock->local_endpoint(ec);
if (!ec) remap_tcp_ports(3, local.port(), ssl_listen_port());
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
m_logger = create_log("main_session", listen_port(), false);
#endif
}
void session_impl::remap_tcp_ports(boost::uint32_t mask, int tcp_port, int ssl_port)
@ -2109,10 +2078,8 @@ retry:
if (m_alerts.should_post<i2p_alert>())
m_alerts.post_alert(i2p_alert(ec));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
char msg[200];
snprintf(msg, sizeof(msg), "i2p open failed (%d) %s", ec.value(), ec.message().c_str());
(*m_logger) << msg << "\n";
#if defined TORRENT_LOGGING
session_log("i2p open failed (%d) %s", ec.value(), ec.message().c_str());
#endif
}
// now that we have our i2p connection established
@ -2156,7 +2123,7 @@ retry:
if (m_alerts.should_post<listen_failed_alert>())
m_alerts.post_alert(listen_failed_alert("i2p", listen_failed_alert::accept
, e, listen_failed_alert::i2p));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("cannot bind to port %d: %s"
, m_listen_interface.port(), e.message().c_str());
#endif
@ -2179,7 +2146,7 @@ retry:
&& m_alerts.should_post<udp_error_alert>())
m_alerts.post_alert(udp_error_alert(ep, ec));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("UDP socket error: (%d) %s", ec.value(), ec.message().c_str());
#endif
}
@ -2236,7 +2203,7 @@ retry:
if (e)
{
tcp::endpoint ep = listener->local_endpoint(ec);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("error accepting connection on '%s': %s"
, print_endpoint(ep).c_str(), e.message().c_str());
#endif
@ -2333,7 +2300,7 @@ retry:
tcp::endpoint endp = s->remote_endpoint(e);
if (e) return;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" *** peer SSL handshake done [ ip: %s ec: %s socket: %s ]"
, print_endpoint(endp).c_str(), ec.message().c_str(), s->type_name());
#endif
@ -2366,7 +2333,7 @@ retry:
if (m_paused)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" <== INCOMING CONNECTION [ ignored, paused ]");
#endif
return;
@ -2378,7 +2345,7 @@ retry:
if (ec)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("%s <== INCOMING CONNECTION FAILED, could "
"not retrieve remote endpoint "
, print_endpoint(endp).c_str(), ec.message().c_str());
@ -2386,7 +2353,7 @@ retry:
return;
}
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" <== INCOMING CONNECTION %s type: %s"
, print_endpoint(endp).c_str(), s->type_name());
#endif
@ -2394,7 +2361,7 @@ retry:
if (!m_settings.get_bool(settings_pack::enable_incoming_utp)
&& is_utp(*s))
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" rejected uTP connection");
#endif
if (m_alerts.should_post<peer_blocked_alert>())
@ -2406,7 +2373,7 @@ retry:
if (!m_settings.get_bool(settings_pack::enable_incoming_tcp)
&& s->get<stream_socket>())
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" rejected TCP connection");
#endif
if (m_alerts.should_post<peer_blocked_alert>())
@ -2423,7 +2390,7 @@ retry:
tcp::endpoint local = s->local_endpoint(ec);
if (ec)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" rejected connection: (%d) %s", ec.value()
, ec.message().c_str());
#endif
@ -2434,14 +2401,14 @@ retry:
{
if (ec)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" rejected connection, not allowed local interface: (%d) %s"
, ec.value(), ec.message().c_str());
#endif
return;
}
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" rejected connection, not allowed local interface: %s"
, local.address().to_string(ec).c_str());
#endif
@ -2465,7 +2432,7 @@ retry:
if (m_stats_counters[counters::non_filter_torrents] == 0
&& (m_ip_filter.access(endp.address()) & ip_filter::blocked))
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("filtered blocked ip");
#endif
if (m_alerts.should_post<peer_blocked_alert>())
@ -2478,7 +2445,7 @@ retry:
// if we don't reject the connection
if (m_torrents.empty())
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" There are no torrents, disconnect");
#endif
return;
@ -2514,7 +2481,7 @@ retry:
, peer_connection::op_bittorrent
, error_code(errors::too_many_connections, get_libtorrent_category())));
}
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("number of connections limit exceeded (conns: %d, limit: %d, slack: %d), connection rejected"
, num_connections(), m_settings.get_int(settings_pack::connections_limit)
, m_settings.get_int(settings_pack::connections_slack));
@ -2541,7 +2508,7 @@ retry:
}
if (!has_active_torrent)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" There are no _active_ torrents, disconnect");
#endif
return;
@ -2638,7 +2605,7 @@ retry:
// TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p));
#endif
#if defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" CLOSING CONNECTION %s : %s"
, print_endpoint(p->remote()).c_str(), ec.message().c_str());
#endif
@ -2818,7 +2785,7 @@ retry:
if (e)
{
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
session_log("*** TICK TIMER FAILED %s", e.message().c_str());
#endif
::abort();
@ -3299,7 +3266,7 @@ retry:
TORRENT_ASSERT(m_dht);
m_dht_torrents.push_back(t);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
boost::shared_ptr<torrent> tor = t.lock();
if (tor)
session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str());
@ -3328,7 +3295,7 @@ retry:
TORRENT_ASSERT(is_single_thread());
if (e)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("aborting DHT announce timer (%d): %s"
, e.value(), e.message().c_str());
#endif
@ -3337,7 +3304,7 @@ retry:
if (m_abort)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("aborting DHT announce timer: m_abort set");
#endif
return;
@ -3471,7 +3438,7 @@ retry:
{
--hard_limit;
--type_limit;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (!t->allows_peers())
t->log_to_all_peers("AUTO MANAGER STARTING TORRENT");
#endif
@ -3479,7 +3446,7 @@ retry:
}
else
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (t->allows_peers())
t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT");
#endif
@ -4032,7 +3999,7 @@ retry:
stop_loop = m_abort;
}
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" locking mutex");
#endif
@ -4045,7 +4012,7 @@ retry:
}
#endif
*/
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log(" cleaning up torrents");
#endif
@ -4250,18 +4217,10 @@ retry:
return i->second;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
boost::shared_ptr<logger> session_impl::create_log(std::string const& name
, int instance, bool append)
{
error_code ec;
// current options are file_logger, cout_logger and null_logger
return boost::shared_ptr<logger>(new logger(m_logpath, name, instance, append));
}
#if defined TORRENT_LOGGING
void session_impl::session_log(char const* fmt, ...) const
{
if (!m_logger) return;
if (!m_alerts.should_post<log_alert>()) return;
va_list v;
va_start(v, fmt);
@ -4271,15 +4230,15 @@ retry:
void session_impl::session_vlog(char const* fmt, va_list& v) const
{
char usr[400];
vsnprintf(usr, sizeof(usr), fmt, v);
if (!m_alerts.should_post<log_alert>()) return;
char buf[1024];
vsnprintf(buf, sizeof(buf), fmt, v);
va_end(v);
char buf[450];
snprintf(buf, sizeof(buf), "%s: %s\n", time_now_string(), usr);
(*m_logger) << buf;
m_alerts.post_alert(log_alert(buf));
}
#if defined TORRENT_VERBOSE_LOGGING
void session_impl::log_all_torrents(peer_connection* p)
{
for (session_impl::torrent_map::const_iterator i = m_torrents.begin()
@ -4288,7 +4247,6 @@ retry:
p->peer_log(" %s", to_hex(i->second->torrent_file().info_hash().to_string()).c_str());
}
}
#endif
#endif
void session_impl::get_torrent_status(std::vector<torrent_status>* ret
@ -4553,7 +4511,7 @@ retry:
error_code ec;
lazy_entry tmp;
lazy_entry const* info = 0;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
session_log("adding magnet link with resume data");
#endif
if (lazy_bdecode(&params.resume_data[0], &params.resume_data[0]
@ -4561,7 +4519,7 @@ retry:
&& tmp.type() == lazy_entry::dict_t
&& (info = tmp.dict_find_dict("info")))
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
session_log("found metadata in resume data");
#endif
// verify the info-hash of the metadata stored in the resume file matches
@ -4577,14 +4535,14 @@ retry:
|| !params.url.empty()
|| params.info_hash.is_all_zeros())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
session_log("info-hash matched");
#endif
params.ti = boost::make_shared<torrent_info>(resume_ih);
if (params.ti->parse_info_section(*info, ec, 0))
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
session_log("successfully loaded metadata from resume file");
#endif
// make the info-hash be the one in the resume file
@ -4593,20 +4551,20 @@ retry:
}
else
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
session_log("failed to load metadata from resume file: %s"
, ec.message().c_str());
#endif
}
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
else
{
session_log("metadata info-hash failed");
}
#endif
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
else
{
session_log("no metadata found");
@ -4934,7 +4892,7 @@ retry:
// declared in string_util.hpp
parse_comma_separated_string_port(net_interfaces, new_listen_interfaces);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("update listen interfaces: %s", net_interfaces.c_str());
#endif
@ -4962,14 +4920,14 @@ retry:
device_name[0] == '[' ? device_name + 1 : device_name, ec));
if (ec)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("failed to treat %s as an IP address [ %s ]"
, device_name, ec.message().c_str());
#endif
// it may have been a device name.
std::vector<ip_interface> ifs = enum_net_interfaces(m_io_service, ec);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
if (ec)
session_log("failed to enumerate interfaces [ %s ]"
, ec.message().c_str());
@ -4983,7 +4941,7 @@ retry:
// connecting to)
if (strcmp(ifs[i].name, device_name) != 0) continue;
m_listen_interface.address(ifs[i].interface_address);
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("binding to %s"
, m_listen_interface.address().to_string(ec).c_str());
#endif
@ -4993,7 +4951,7 @@ retry:
if (!found)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("failed to find device %s", device_name);
#endif
// effectively disable whatever socket decides to bind to this
@ -5155,7 +5113,7 @@ retry:
if (t->torrent_file().priv() || (t->torrent_file().is_i2p()
&& !m_settings.get_bool(settings_pack::allow_i2p_mixed))) return;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("added peer from local discovery: %s", print_endpoint(peer).c_str());
#endif
t->add_peer(peer, peer_info::lsd);
@ -5170,11 +5128,6 @@ retry:
{
TORRENT_ASSERT(map_transport >= 0 && map_transport <= 1);
// log message
#ifdef TORRENT_UPNP_LOGGING
char const* transport_names[] = {"NAT-PMP", "UPnP"};
m_upnp_log << time_now_string() << " "
<< transport_names[map_transport] << ": " << msg;
#endif
if (m_alerts.should_post<portmap_log_alert>())
m_alerts.post_alert(portmap_log_alert(map_transport, msg));
}
@ -5706,7 +5659,7 @@ retry:
m_ssl_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec);
#endif
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
session_log(">>> SET_TOS [ udp_socket tos: %x e: %s ]"
, m_settings.get_int(settings_pack::peer_tos)
, ec.message().c_str());
@ -5910,7 +5863,7 @@ retry:
#ifndef TORRENT_DISABLE_DHT
if (!m_dht)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("not starting DHT announce timer: m_dht == NULL");
#endif
return;
@ -5921,7 +5874,7 @@ retry:
// if we haven't started yet, don't actually trigger this
if (!m_thread)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("not starting DHT announce timer: thread not running yet");
#endif
return;
@ -5929,7 +5882,7 @@ retry:
if (m_abort)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
session_log("not starting DHT announce timer: m_abort set");
#endif
return;
@ -6338,14 +6291,14 @@ retry:
void session_impl::set_external_address(address const& ip
, int source_type, address const& source)
{
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
session_log(": set_external_address(%s, %d, %s)", print_address(ip).c_str()
, source_type, print_address(source).c_str());
#endif
if (!m_external_ip.cast_vote(ip, source_type, source)) return;
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
session_log(" external IP updated");
#endif
@ -6616,7 +6569,7 @@ retry:
}
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
tracker_logger::tracker_logger(session_interface& ses): m_ses(ses) {}
void tracker_logger::tracker_warning(tracker_request const& req
, std::string const& str)
@ -6629,7 +6582,7 @@ retry:
, std::list<address> const& ip_list
, struct tracker_response const& resp)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("TRACKER RESPONSE\n"
"interval: %d\n"
"external ip: %s\n"

View File

@ -61,7 +61,7 @@ POSSIBILITY OF SUCH DAMAGE.
//#define TORRENT_LOG_HASH_FAILURES
#ifdef TORRENT_LOGGING
#if defined TORRENT_LOGGING
#include "libtorrent/socket_io.hpp"
#endif
@ -138,7 +138,7 @@ namespace
void on_piece_pass(int p)
{
#ifdef TORRENT_LOGGING
#if defined TORRENT_LOGGING
m_torrent.debug_log(" PIECE PASS [ p: %d | block_hash_size: %d ]"
, p, int(m_block_hashes.size()));
#endif
@ -274,7 +274,7 @@ namespace
// this time the digest of the block is different
// from the first time it sent it
// at least one of them must be bad
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
char const* client = "-";
peer_info info;
if (p->connection)
@ -349,7 +349,7 @@ namespace
}
if (p == NULL) return;
#ifdef TORRENT_LOGGING
#if defined TORRENT_LOGGING
char const* client = "-";
peer_info info;
if (p->connection)

View File

@ -95,7 +95,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif // BOOST_VERSION
#endif // TORRENT_USE_OPENSSL
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
#include "libtorrent/aux_/session_impl.hpp" // for tracker_logger
#endif
@ -255,16 +255,6 @@ namespace libtorrent
m_save_path = canonicalize_path(m_save_path);
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
m_logger_time = time_now_hires();
error_code ec;
char buf[50];
snprintf(buf, sizeof(buf), "torrent_%p", this);
m_logger = m_ses.create_log(buf, m_ses.listen_port());
debug_log("torrent started");
#endif
if (!m_apply_ip_filter)
{
inc_stats_counter(counters::non_filter_torrents);
@ -304,9 +294,6 @@ namespace libtorrent
if (!m_url.empty() && m_uuid.empty()) m_uuid = m_url;
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
debug_log("creating torrent: %s", torrent_file().name().c_str());
#endif
m_file_priority = p.file_priorities;
if (m_seed_mode)
@ -703,12 +690,12 @@ namespace libtorrent
// TODO: 2 post alert
#if defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** FAILED SEED MODE, rechecking");
#endif
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** LEAVING SEED MODE (%s)", seed ? "as seed" : "as non-seed");
#endif
m_seed_mode = false;
@ -739,7 +726,7 @@ namespace libtorrent
void torrent::start()
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("starting torrent");
#endif
std::vector<boost::uint64_t>().swap(m_file_progress);
@ -752,7 +739,7 @@ namespace libtorrent
+ m_resume_data->buf.size(), m_resume_data->entry, ec, &pos) != 0)
{
m_resume_data.reset();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("resume data rejected: %s pos: %d", ec.message().c_str(), pos);
#endif
if (m_ses.alerts().should_post<fastresume_rejected_alert>())
@ -1055,7 +1042,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
if (!j->error) return;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("disk error: (%d) %s in file: %s", j->error.ec.value(), j->error.ec.message().c_str()
, resolve_filename(j->error.file).c_str());
#endif
@ -1456,7 +1443,7 @@ namespace libtorrent
GENERAL_NAMES* gens = static_cast<GENERAL_NAMES*>(
X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0));
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
std::string names;
bool match = false;
#endif
@ -1469,14 +1456,14 @@ namespace libtorrent
const char* torrent_name = reinterpret_cast<const char*>(domain->data);
std::size_t name_length = domain->length;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
if (i > 1) names += " | n: ";
names.append(torrent_name, name_length);
#endif
if (strncmp(torrent_name, "*", name_length) == 0
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
match = true;
// if we're logging, keep looping over all names,
// for completeness of the log
@ -1501,7 +1488,7 @@ namespace libtorrent
const char* torrent_name = reinterpret_cast<const char*>(common_name->data);
std::size_t name_length = common_name->length;
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_LOGGING
if (!names.empty()) names += " | n: ";
names.append(torrent_name, name_length);
#endif
@ -1509,7 +1496,7 @@ namespace libtorrent
if (strncmp(torrent_name, "*", name_length) == 0
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
{
#if !defined(TORRENT_VERBOSE_LOGGING) && !defined(TORRENT_LOGGING)
#if !defined TORRENT_LOGGING
return true;
#else
match = true;
@ -1517,7 +1504,7 @@ namespace libtorrent
}
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("<== incoming SSL CONNECTION [ n: %s | match: %s ]"
, names.c_str(), match?"yes":"no");
return match;
@ -1691,6 +1678,10 @@ namespace libtorrent
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_LOGGING
debug_log("init torrent: %s", torrent_file().name().c_str());
#endif
if (!need_loaded()) return;
TORRENT_ASSERT(m_torrent_file->num_files() > 0);
TORRENT_ASSERT(m_torrent_file->is_valid());
@ -1745,7 +1736,7 @@ namespace libtorrent
if (ev)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("fastresume data rejected: %s"
, error_code(ev, get_libtorrent_category()).message().c_str());
#endif
@ -1906,7 +1897,7 @@ namespace libtorrent
m_storage.get(), m_resume_data ? &m_resume_data->entry : NULL
, boost::bind(&torrent::on_resume_data_checked
, shared_from_this(), _1));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("init, async_check_fastresume");
#endif
@ -2221,7 +2212,7 @@ namespace libtorrent
}
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
if (m_peer_list && m_peer_list->num_peers() > 0)
debug_log("resume added peers (%d)", m_peer_list->num_peers());
#endif
@ -2234,13 +2225,13 @@ namespace libtorrent
, resolve_filename(j->error.file), j->error.operation_str()));
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
if (j->ret != 0)
{
debug_log("fastresume data rejected: ret: %d (%d) %s"
, j->ret, j->error.ec.value(), j->error.ec.message().c_str());
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
else
debug_log("fastresume data accepted");
#endif
@ -2462,7 +2453,7 @@ namespace libtorrent
// resumed quickly, before the outstanding jobs completed
if (m_checking_piece >= m_torrent_file->num_pieces())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("start_checking, checking_piece >= num_pieces. %d >= %d"
, m_checking_piece, m_torrent_file->num_pieces());
#endif
@ -2475,7 +2466,7 @@ namespace libtorrent
if (!need_loaded())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("start_checking, need_loaded() failed");
#endif
return;
@ -2490,7 +2481,7 @@ namespace libtorrent
, shared_from_this(), _1), (void*)1);
if (m_checking_piece >= m_torrent_file->num_pieces()) break;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("start_checking, m_checking_piece: %d", m_checking_piece);
#endif
}
@ -2513,7 +2504,7 @@ namespace libtorrent
{
m_checking_piece = 0;
m_num_checked_pieces = 0;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("on_piece_hashed, disk_check_aborted");
#endif
pause();
@ -2554,7 +2545,7 @@ namespace libtorrent
m_ses.alerts().post_alert(file_error_alert(j->error.ec,
resolve_filename(j->error.file), j->error.operation_str(), get_handle()));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("on_piece_hashed, fatal disk error: (%d) %s", j->error.ec.value(), j->error.ec.message().c_str());
#endif
auto_managed(false);
@ -2573,7 +2564,7 @@ namespace libtorrent
// we're using the piece hashes here, we need the torrent to be loaded
if (!need_loaded())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("on_piece_hashed, need_loaded failed");
#endif
return;
@ -2619,7 +2610,7 @@ namespace libtorrent
// we paused the checking
if (!should_check_files())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("on_piece_hashed, checking paused");
#endif
return;
@ -2627,7 +2618,7 @@ namespace libtorrent
if (!need_loaded())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("on_piece_hashed, need_loaded failed");
#endif
return;
@ -2638,13 +2629,13 @@ namespace libtorrent
, disk_io_job::sequential_access | disk_io_job::volatile_read
, boost::bind(&torrent::on_piece_hashed
, shared_from_this(), _1), (void*)1);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("on_piece_hashed, m_checking_piece: %d", m_checking_piece);
#endif
return;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("on_piece_hashed, completed");
#endif
// we're done checking!
@ -2734,14 +2725,14 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
if (!m_ses.dht())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("DHT: no dht initialized");
#endif
return;
}
if (!should_announce_dht())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
if (!m_ses.announce_dht())
debug_log("DHT: no listen sockets");
@ -2782,7 +2773,7 @@ namespace libtorrent
int port = m_ses.listen_port();
#endif
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("START DHT announce");
m_dht_start_time = time_now_hires();
#endif
@ -2814,7 +2805,7 @@ namespace libtorrent
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("END DHT announce (%d ms) (%d peers)"
, int(total_milliseconds(time_now_hires() - m_dht_start_time))
, int(peers.size()));
@ -2849,7 +2840,7 @@ namespace libtorrent
if (m_trackers.empty())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** announce_with_tracker: no trackers");
#endif
return;
@ -2861,7 +2852,7 @@ namespace libtorrent
// stopping
if (e != tracker_request::stopped && !m_announce_to_trackers)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** announce_with_tracker: event != stopped && !m_announce_to_trackers");
#endif
return;
@ -2870,7 +2861,7 @@ namespace libtorrent
// if we're not allowing peers, there's no point in announcing
if (e != tracker_request::stopped && !m_allow_peers)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** announce_with_tracker: event != stopped && !m_allow_peers");
#endif
return;
@ -2922,7 +2913,7 @@ namespace libtorrent
for (int i = 0; i < int(m_trackers.size()); ++i)
{
announce_entry& ae = m_trackers[i];
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** announce with tracker: considering \"%s\" "
"[ announce_to_all_tiers: %d announce_to_all_trackers: %d"
" i->tier: %d tier: %d "
@ -3003,7 +2994,7 @@ namespace libtorrent
continue;
}
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d"
, req.url.c_str()
, (req.event==tracker_request::stopped?"stopped"
@ -3179,7 +3170,7 @@ namespace libtorrent
if (resp.complete >= 0 && resp.incomplete >= 0)
m_last_scrape = m_ses.session_time();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("TRACKER RESPONSE\n"
"interval: %d\n"
"external ip: %s\n"
@ -3319,7 +3310,7 @@ namespace libtorrent
?m_ses.get_ipv6_interface().address()
:m_ses.get_ipv4_interface().address();
announce_with_tracker(r.event, bind_interface);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("announce again using %s as the bind interface"
, print_address(bind_interface).c_str());
#endif
@ -3385,7 +3376,7 @@ namespace libtorrent
continue;
}
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
external_ip const& external = m_ses.external_address();
debug_log(" *** FOUND CONNECTION CANDIDATE ["
" ip: %s rank: %u external: %s t: %d ]"
@ -3491,7 +3482,7 @@ namespace libtorrent
if (m_apply_ip_filter
&& m_ses.get_ip_filter().access(host.address()) & ip_filter::blocked)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
error_code ec;
debug_log("blocked ip from tracker: %s", host.address().to_string(ec).c_str());
#endif
@ -3852,7 +3843,7 @@ namespace libtorrent
// -1: disk failure
// -2: piece failed check
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** PIECE_FINISHED [ p: %d | chk: %s | size: %d ]"
, j->piece, ((ret == 0)
?"passed":ret == -1
@ -4092,7 +4083,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
TORRENT_ASSERT(!m_picker->has_piece_passed(index));
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("PIECE_PASSED (%d)", num_passed());
#endif
@ -4167,7 +4158,7 @@ namespace libtorrent
for (peer_iterator p = m_connections.begin()
, end(m_connections.end()); p != end; ++p)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
(*p)->peer_log(">>> PREDICTIVE_HAVE [ piece: %d expected in %d ms]"
, index, milliseconds);
#endif
@ -4309,11 +4300,11 @@ namespace libtorrent
if (p->connection)
{
peer_connection* peer = static_cast<peer_connection*>(p->connection);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** BANNING PEER: \"%s\" Too many corrupt pieces"
, print_endpoint(p->ip()).c_str());
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
peer->peer_log("*** BANNING PEER: Too many corrupt pieces");
#endif
peer->disconnect(errors::too_many_corrupt_pieces, peer_connection_interface::op_bittorrent);
@ -4671,7 +4662,7 @@ namespace libtorrent
error_code ec;
m_inactivity_timer.cancel(ec);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
log_to_all_peers("ABORTING TORRENT");
#endif
@ -5419,7 +5410,7 @@ namespace libtorrent
p->update_interest();
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** UPDATE_PEER_INTEREST [ finished: %d was_finished %d ]"
, is_finished(), was_finished);
#endif
@ -5898,7 +5889,7 @@ namespace libtorrent
if (ec)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("failed to parse web seed url: %s", ec.message().c_str());
#endif
if (m_ses.alerts().should_post<url_seed_alert>())
@ -5913,7 +5904,7 @@ namespace libtorrent
if (web->peer_info.banned)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("banned web seed: %s", web->url.c_str());
#endif
if (m_ses.alerts().should_post<url_seed_alert>())
@ -5985,7 +5976,7 @@ namespace libtorrent
return;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("resolving web seed: %s", web->url.c_str());
#endif
@ -5993,7 +5984,7 @@ namespace libtorrent
if (ps.type == settings_pack::http
|| ps.type == settings_pack::http_pw)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("resolving proxy for web seed: %s", web->url.c_str());
#endif
@ -6011,7 +6002,7 @@ namespace libtorrent
}
else
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("resolving web seed: %s", web->url.c_str());
#endif
@ -6031,10 +6022,8 @@ namespace libtorrent
INVARIANT_CHECK;
TORRENT_ASSERT(web->resolving == true);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("completed resolve proxy hostname for: %s", web->url.c_str());
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
if (e)
debug_log("proxy name lookup error: %s", e.message().c_str());
#endif
@ -6042,7 +6031,7 @@ namespace libtorrent
if (web->removed)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("removed web seed");
#endif
remove_web_seed(web);
@ -6118,13 +6107,13 @@ namespace libtorrent
INVARIANT_CHECK;
TORRENT_ASSERT(web->resolving == true);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("completed resolve: %s", web->url.c_str());
#endif
web->resolving = false;
if (web->removed)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("removed web seed");
#endif
remove_web_seed(web);
@ -6137,7 +6126,7 @@ namespace libtorrent
{
if (m_ses.alerts().should_post<url_seed_alert>())
m_ses.alerts().post_alert(url_seed_alert(get_handle(), web->url, e));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** HOSTNAME LOOKUP FAILED: %s: (%d) %s"
, web->url.c_str(), e.value(), e.message().c_str());
#endif
@ -6153,7 +6142,7 @@ namespace libtorrent
// fill in the peer struct's address field
web->endpoints.push_back(tcp::endpoint(*i, port));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log(" -> %s", print_endpoint(tcp::endpoint(*i, port)).c_str());
#endif
}
@ -6319,7 +6308,7 @@ namespace libtorrent
, boost::int64_t(web->peer_info.prev_amount_upload) << 10);
web->peer_info.prev_amount_download = 0;
web->peer_info.prev_amount_upload = 0;
#if defined TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
debug_log("web seed connection started: [%s] %s"
, print_endpoint(a).c_str(), web->url.c_str());
#endif
@ -6328,7 +6317,7 @@ namespace libtorrent
if (c->is_disconnecting()) return;
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("START queue peer [%p] (%d)", c.get(), num_peers());
#endif
}
@ -6336,7 +6325,7 @@ namespace libtorrent
{
TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** PEER_ERROR: %s", e.what());
#endif
c->disconnect(errors::no_error, peer_connection_interface::op_bittorrent, 1);
@ -6489,7 +6478,7 @@ namespace libtorrent
{
// unknown country!
p->set_country("!!");
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("IP \"%s\" was mapped to unknown country: %d"
, print_address(p->remote().address()).c_str(), country);
#endif
@ -7666,7 +7655,7 @@ namespace libtorrent
++m_num_seeds;
}
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("incoming peer (%d)", int(m_connections.size()));
#endif
@ -7819,9 +7808,6 @@ namespace libtorrent
peer_connection* p = *m_connections.begin();
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
p->peer_log("*** CLOSING CONNECTION \"%s\"", ec.message().c_str());
#endif
#if TORRENT_USE_ASSERTS
std::size_t size = m_connections.size();
#endif
@ -7945,7 +7931,7 @@ namespace libtorrent
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
if (p->upload_only())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
p->peer_log("*** SEED, CLOSING CONNECTION");
#endif
seeds.push_back(p);
@ -7986,7 +7972,7 @@ namespace libtorrent
|| m_state == torrent_status::checking_files
|| m_state == torrent_status::allocating)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** RESUME_DOWNLOAD [ skipping, state: %d ]"
, int(m_state));
#endif
@ -7999,7 +7985,7 @@ namespace libtorrent
m_completed_time = 0;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** RESUME_DOWNLOAD");
#endif
send_upload_only();
@ -8095,7 +8081,7 @@ namespace libtorrent
if (m_abort)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("files_checked(), paused");
#endif
return;
@ -8186,7 +8172,7 @@ namespace libtorrent
pc->init();
}
#ifdef TORRENT_VERBOSE_LOGGING
#if defined TORRENT_LOGGING
pc->peer_log("*** ON_FILES_CHECKED");
#endif
if (pc->is_interesting() && !pc->has_peer_choked())
@ -8665,7 +8651,7 @@ namespace libtorrent
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
log_to_all_peers("DELETING FILES IN TORRENT");
#endif
@ -8737,7 +8723,7 @@ namespace libtorrent
if (alerts().should_post<torrent_error_alert>())
alerts().post_alert(torrent_error_alert(get_handle(), ec, resolve_filename(error_file)));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (ec)
{
char buf[1024];
@ -9077,7 +9063,7 @@ namespace libtorrent
update_want_peers();
update_want_scrape();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
log_to_all_peers("PAUSING TORRENT");
#endif
@ -9134,7 +9120,7 @@ namespace libtorrent
if (p->outstanding_bytes() > 0)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
p->peer_log("*** CHOKING PEER: torrent graceful paused");
#endif
// remove any un-sent requests from the queue
@ -9144,7 +9130,7 @@ namespace libtorrent
continue;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
p->peer_log("*** CLOSING CONNECTION: torrent_paused");
#endif
p->disconnect(errors::torrent_paused, peer_connection_interface::op_bittorrent);
@ -9166,11 +9152,11 @@ namespace libtorrent
}
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
void torrent::log_to_all_peers(char const* message)
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i)
{
@ -9295,7 +9281,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
if (!m_announcing)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** update tracker timer: not announcing");
#endif
return;
@ -9309,7 +9295,7 @@ namespace libtorrent
for (std::vector<announce_entry>::iterator i = m_trackers.begin()
, end(m_trackers.end()); i != end; ++i)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
char msg[1000];
snprintf(msg, sizeof(msg), "*** update tracker timer: considering \"%s\" "
"[ announce_to_all_tiers: %d announce_to_all_trackers: %d"
@ -9347,7 +9333,7 @@ namespace libtorrent
&& !settings().get_bool(settings_pack::announce_to_all_tiers)) break;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
char msg[200];
snprintf(msg, sizeof(msg), "*** update tracker timer: next_announce < now %d"
" m_waiting_tracker: %d next_announce_in: %d"
@ -9377,7 +9363,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
if (is_paused())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("start_announcing(), paused");
#endif
return;
@ -9387,14 +9373,14 @@ namespace libtorrent
// request the metadata from
if (!m_files_checked && valid_metadata())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("start_announcing(), files not checked (with valid metadata)");
#endif
return;
}
if (!m_torrent_file->is_valid() && !m_url.empty())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("start_announcing(), downloading URL");
#endif
return;
@ -9626,7 +9612,7 @@ namespace libtorrent
{
TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
p->peer_log("*** ERROR %s", e.what());
#endif
p->disconnect(errors::no_error, peer_connection_interface::op_bittorrent, 1);
@ -10558,7 +10544,7 @@ namespace libtorrent
TORRENT_ASSERT(i->resolving == false);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("disconnect web seed: \"%s\"", i->url.c_str());
#endif
TORRENT_ASSERT(i->peer_info.connection);
@ -11127,7 +11113,7 @@ namespace libtorrent
m_state = s;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
debug_log("set_state() %d", m_state);
#endif
@ -11466,7 +11452,7 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** tracker error: (%d) %s %s", ec.value(), ec.message().c_str(), msg.c_str());
#endif
if (r.kind == tracker_request::announce_request)
@ -11478,7 +11464,7 @@ namespace libtorrent
ae->last_error = ec;
ae->message = msg;
int tracker_index = ae - &m_trackers[0];
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
debug_log("*** increment tracker fail count [%d]", ae->fails);
#endif
// never talk to this tracker again
@ -11512,20 +11498,20 @@ namespace libtorrent
update_tracker_timer(time_now());
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
void torrent::debug_log(char const* fmt, ...) const
{
if (!m_logger) return;
if (!alerts().should_post<torrent_log_alert>()) return;
va_list v;
va_start(v, fmt);
char usr[400];
vsnprintf(usr, sizeof(usr), fmt, v);
char buf[400];
vsnprintf(buf, sizeof(buf), fmt, v);
va_end(v);
char buf[450];
snprintf(buf, sizeof(buf), "%" PRId64 ": %s\n", total_microseconds(time_now_hires() - m_logger_time), usr);
(*m_logger) << buf;
alerts().post_alert(torrent_log_alert(
const_cast<torrent*>(this)->get_handle(), buf));
}
#endif

View File

@ -359,7 +359,7 @@ namespace libtorrent
close_http_connections.push_back(*i);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> rc = c->requester();
if (rc) rc->debug_log("aborting: %s", req.url.c_str());
#endif
@ -374,7 +374,7 @@ namespace libtorrent
close_udp_connections.push_back(c);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> rc = c->requester();
if (rc) rc->debug_log("aborting: %s", req.url.c_str());
#endif

View File

@ -55,7 +55,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/resolver_interface.hpp"
#include "libtorrent/ip_filter.hpp"
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
#include "libtorrent/socket_io.hpp"
#endif
@ -124,7 +124,7 @@ namespace libtorrent
, boost::bind(&udp_tracker_connection::name_lookup
, shared_from_this(), _1, _2, port));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]"
, hostname.c_str());
@ -153,7 +153,7 @@ namespace libtorrent
return;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ host: \"%s\" ip: \"%s\" | error: \"%s\" ]"
, m_hostname.c_str(), print_endpoint(m_target).c_str(), ec.message().c_str());
@ -162,7 +162,7 @@ namespace libtorrent
// pick another target endpoint and try again
m_target = pick_target_endpoint();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER trying next IP [ host: \"%s\" ip: \"%s\" ]"
, m_hostname.c_str(), print_endpoint(m_target).c_str());
#endif
@ -185,7 +185,7 @@ namespace libtorrent
}
boost::shared_ptr<request_callback> cb = requester();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]");
#endif
if (cancelled())
@ -212,7 +212,7 @@ namespace libtorrent
{
if (m_man.ip_filter().access(k->address()) == ip_filter::blocked)
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: %s ]"
, print_address(k->address()).c_str());
#endif
@ -306,7 +306,7 @@ namespace libtorrent
return;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
#endif
@ -346,7 +346,7 @@ namespace libtorrent
if (e) fail(e);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb)
{
@ -361,7 +361,7 @@ namespace libtorrent
int action = detail::read_int32(ptr);
boost::uint32_t transaction = detail::read_uint32(ptr);
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (cb)
{
cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action);
@ -382,7 +382,7 @@ namespace libtorrent
restart_read_timeout();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (cb)
{
cb->debug_log("*** UDP_TRACKER_RESPONSE [ tid: %x ]"
@ -443,7 +443,7 @@ namespace libtorrent
void udp_tracker_connection::send_udp_connect()
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb)
{
@ -547,7 +547,7 @@ namespace libtorrent
}
boost::shared_ptr<request_callback> cb = requester();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
if (cb)
{
boost::shared_ptr<request_callback> cb = requester();
@ -695,7 +695,7 @@ namespace libtorrent
TORRENT_ASSERT(out - buf <= int(sizeof(buf)));
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#if defined TORRENT_LOGGING
boost::shared_ptr<request_callback> cb = requester();
if (cb)
{

View File

@ -258,7 +258,7 @@ namespace libtorrent { namespace
TORRENT_ASSERT(type >= 0 && type <= 2);
TORRENT_ASSERT(!m_pc.associated_torrent().expired());
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
char const* names[] = {"request", "data", "dont-have"};
char const* n = "";
if (type >= 0 && type < 3) n = names[type];
@ -280,7 +280,7 @@ namespace libtorrent { namespace
if (piece < 0 || piece >= int(m_tp.get_metadata_size() + 16 * 1024 - 1)/(16*1024))
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("*** UT_METADATA [ invalid piece %d metadata size: %d ]"
, piece, int(m_tp.get_metadata_size()));
#endif
@ -330,7 +330,7 @@ namespace libtorrent { namespace
if (length > 17 * 1024)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== UT_METADATA [ packet too big %d ]", length);
#endif
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
@ -343,7 +343,7 @@ namespace libtorrent { namespace
entry msg = bdecode(body.begin, body.end, len);
if (msg.type() != entry::dictionary_t)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== UT_METADATA [ not a dictionary ]");
#endif
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
@ -355,7 +355,7 @@ namespace libtorrent { namespace
if (type_ent == 0 || type_ent->type() != entry::int_t
|| piece_ent == 0 || piece_ent->type() != entry::int_t)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== UT_METADATA [ missing or invalid keys ]");
#endif
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
@ -364,7 +364,7 @@ namespace libtorrent { namespace
int type = type_ent->integer();
int piece = piece_ent->integer();
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== UT_METADATA [ type: %d | piece: %d ]", type, piece);
#endif
@ -393,7 +393,7 @@ namespace libtorrent { namespace
// unwanted piece?
if (i == m_sent_requests.end())
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("*** UT_METADATA [ UNWANTED / TIMED OUT ]");
#endif
return true;
@ -541,7 +541,7 @@ namespace libtorrent { namespace
{
if (m_torrent.valid_metadata())
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ ALREADY HAVE METADATA ]");
#endif
m_torrent.add_redundant_bytes(size, torrent::piece_unknown);
@ -553,7 +553,7 @@ namespace libtorrent { namespace
// verify the total_size
if (total_size <= 0 || total_size > m_torrent.session().settings().get_int(settings_pack::max_metadata_size))
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ metadata size too big: %d ]", total_size);
#endif
// #error post alert
@ -567,7 +567,7 @@ namespace libtorrent { namespace
if (piece < 0 || piece >= int(m_requested_metadata.size()))
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ piece: %d INVALID ]", piece);
#endif
return false;
@ -575,7 +575,7 @@ namespace libtorrent { namespace
if (total_size != m_metadata_size)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ total_size: %d INCONSISTENT WITH: %d ]"
, total_size, m_metadata_size);
#endif

View File

@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/extensions/ut_pex.hpp"
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
#include "libtorrent/lazy_entry.hpp"
#endif
@ -311,7 +311,7 @@ namespace libtorrent { namespace
lazy_entry const* p = pex_msg.dict_find_string("dropped");
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
int num_dropped = 0;
int num_added = 0;
if (p) num_dropped += p->string_length()/6;
@ -333,7 +333,7 @@ namespace libtorrent { namespace
p = pex_msg.dict_find_string("added");
lazy_entry const* pf = pex_msg.dict_find_string("added.f");
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
if (p) num_added += p->string_length() / 6;
#endif
if (p != 0
@ -367,7 +367,7 @@ namespace libtorrent { namespace
#if TORRENT_USE_IPV6
lazy_entry const* p6 = pex_msg.dict_find("dropped6");
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
if (p6) num_dropped += p6->string_length() / 18;
#endif
if (p6 != 0 && p6->type() == lazy_entry::string_t)
@ -385,7 +385,7 @@ namespace libtorrent { namespace
}
p6 = pex_msg.dict_find("added6");
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
if (p6) num_added += p6->string_length() / 18;
#endif
lazy_entry const* p6f = pex_msg.dict_find("added6.f");
@ -417,7 +417,7 @@ namespace libtorrent { namespace
}
}
#endif
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("<== PEX [ dropped: %d added: %d ]"
, num_dropped, num_added);
#endif
@ -436,7 +436,7 @@ namespace libtorrent { namespace
ptime now = time_now();
if (now - seconds(60) < m_last_msg)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("*** PEX [ waiting: %d seconds to next msg ]"
, total_seconds(seconds(60) - (now - m_last_msg)));
#endif
@ -454,7 +454,7 @@ namespace libtorrent { namespace
if (now - milliseconds(delay) < global_last)
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("*** PEX [ global-wait: %d ]", total_seconds(milliseconds(delay) - (now - global_last)));
#endif
return;
@ -499,7 +499,7 @@ namespace libtorrent { namespace
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
lazy_entry m;
error_code ec;
int ret = lazy_bdecode(&pex_msg[0], &pex_msg[0] + pex_msg.size(), m, ec);
@ -607,7 +607,7 @@ namespace libtorrent { namespace
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size()));
#endif
}

View File

@ -654,7 +654,7 @@ struct utp_socket_impl
bool m_stalled:1;
};
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
int socket_impl_size() { return sizeof(utp_socket_impl); }
#endif

View File

@ -97,7 +97,7 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack
// into single larger ones
request_large_blocks(true);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** web_peer_connection %s", m_url.c_str());
#endif
}
@ -369,7 +369,7 @@ void web_peer_connection::write_request(peer_request const& r)
}
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("==> %s", request.c_str());
#endif
@ -488,7 +488,7 @@ void web_peer_connection::on_receive(error_code const& error
if (error)
{
received_bytes(0, bytes_transferred);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** web_peer_connection error: %s", error.message().c_str());
#endif
#ifdef TORRENT_DEBUG
@ -526,7 +526,7 @@ void web_peer_connection::on_receive(error_code const& error
if (failed)
{
received_bytes(0, bytes_transferred);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** %s", std::string(recv_buffer.begin, recv_buffer.end).c_str());
#endif
disconnect(errors::http_parse_error, op_bittorrent, 2);
@ -583,7 +583,7 @@ void web_peer_connection::on_receive(error_code const& error
m_web->supports_keepalive = false;
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** STATUS: %d %s", m_parser.status_code(), m_parser.message().c_str());
std::multimap<std::string, std::string> const& headers = m_parser.headers();
for (std::multimap<std::string, std::string>::const_iterator i = headers.begin()
@ -681,7 +681,7 @@ void web_peer_connection::on_receive(error_code const& error
location = resolve_redirect_location(m_url, location);
}
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** LOCATION: %s", location.c_str());
#endif
t->add_web_seed(location, web_seed_entry::url_seed, m_external_auth, m_extra_headers);
@ -790,7 +790,7 @@ void web_peer_connection::on_receive(error_code const& error
}
else
{
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
#endif
TORRENT_ASSERT(int(bytes_transferred) >= header_size - m_partial_chunk_header);
@ -840,7 +840,7 @@ void web_peer_connection::on_receive(error_code const& error
TORRENT_ASSERT(m_block_pos >= 0);
#ifdef TORRENT_VERBOSE_LOGGING
#ifdef TORRENT_LOGGING
peer_log("*** payload_transferred: %d [ %d:%d = %d ]"
, payload_transferred, front_request.piece
, front_request.start, front_request.length);

View File

@ -63,7 +63,7 @@ struct mock_peer_connection : peer_connection_interface
for (int i = 0; i < 20; ++i) m_id[i] = rand();
}
virtual ~mock_peer_connection() {}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
virtual void peer_log(char const* fmt, ...) const
{
va_list v;
@ -114,7 +114,7 @@ struct mock_torrent
return true;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#if defined TORRENT_LOGGING
void debug_log(const char* fmt, ...) const
{
va_list v;