From 732c3d86741bf8e4754f8efabd9ed3011c06849f Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sat, 17 Nov 2007 11:45:19 +0000 Subject: [PATCH] lt sync 1732 --- .../include/libtorrent/aux_/session_impl.hpp | 7 +++++- libtorrent/include/libtorrent/debug.hpp | 4 ++-- libtorrent/include/libtorrent/session.hpp | 12 ++++++++-- libtorrent/src/session.cpp | 24 +++++++++++++++---- libtorrent/src/session_impl.cpp | 11 +++++++-- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/libtorrent/include/libtorrent/aux_/session_impl.hpp b/libtorrent/include/libtorrent/aux_/session_impl.hpp index df39fabb0..090196a4f 100644 --- a/libtorrent/include/libtorrent/aux_/session_impl.hpp +++ b/libtorrent/include/libtorrent/aux_/session_impl.hpp @@ -184,7 +184,11 @@ namespace libtorrent session_impl( std::pair listen_port_range , fingerprint const& cl_fprint - , char const* listen_interface = "0.0.0.0"); + , char const* listen_interface +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , fs::path const& logpath +#endif + ); ~session_impl(); #ifndef TORRENT_DISABLE_EXTENSIONS @@ -575,6 +579,7 @@ namespace libtorrent // whe shutting down process std::list > m_tracker_loggers; + fs::path m_logpath; public: boost::shared_ptr m_logger; private: diff --git a/libtorrent/include/libtorrent/debug.hpp b/libtorrent/include/libtorrent/debug.hpp index 0d3158417..96c2c9dc7 100755 --- a/libtorrent/include/libtorrent/debug.hpp +++ b/libtorrent/include/libtorrent/debug.hpp @@ -58,11 +58,11 @@ namespace libtorrent struct logger { - logger(fs::path const& filename, int instance, bool append = true) + logger(fs::path const& logpath, fs::path const& filename, int instance, bool append = true) { try { - fs::path dir(fs::complete("libtorrent_logs" + boost::lexical_cast(instance))); + fs::path dir(fs::complete(logpath / ("libtorrent_logs" + boost::lexical_cast(instance)))); if (!fs::exists(dir)) fs::create_directories(dir); m_file.open((dir / filename).string().c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::out)); *this << "\n\n\n*** starting log ***\n"; diff --git a/libtorrent/include/libtorrent/session.hpp b/libtorrent/include/libtorrent/session.hpp index 5093e2336..1d29e03b3 100755 --- a/libtorrent/include/libtorrent/session.hpp +++ b/libtorrent/include/libtorrent/session.hpp @@ -121,11 +121,19 @@ namespace libtorrent public: session(fingerprint const& print = fingerprint("LT" - , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)); + , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0) +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , fs::path logpath = "." +#endif + ); session( fingerprint const& print , std::pair listen_port_range - , char const* listen_interface = "0.0.0.0"); + , char const* listen_interface = "0.0.0.0" +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , fs::path logpath = "." +#endif + ); ~session(); diff --git a/libtorrent/src/session.cpp b/libtorrent/src/session.cpp index 5bdb6b07e..0b8aecff7 100755 --- a/libtorrent/src/session.cpp +++ b/libtorrent/src/session.cpp @@ -106,8 +106,16 @@ namespace libtorrent session::session( fingerprint const& id , std::pair listen_port_range - , char const* listen_interface) - : m_impl(new session_impl(listen_port_range, id, listen_interface)) + , char const* listen_interface +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , fs::path logpath +#endif + ) + : m_impl(new session_impl(listen_port_range, id, listen_interface +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , logpath +#endif + )) { // turn off the filename checking in boost.filesystem TORRENT_ASSERT(listen_port_range.first > 0); @@ -121,8 +129,16 @@ namespace libtorrent #endif } - session::session(fingerprint const& id) - : m_impl(new session_impl(std::make_pair(0, 0), id)) + session::session(fingerprint const& id +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , fs::path logpath +#endif + ) +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + : m_impl(new session_impl(std::make_pair(0, 0), id, "0.0.0.0", logpath)) +#else + : m_impl(new session_impl(std::make_pair(0, 0), id, "0.0.0.0")) +#endif { #ifndef NDEBUG boost::function0 test = boost::ref(*m_impl); diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index b3eba0bf7..c41079fdc 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -545,7 +545,11 @@ namespace detail session_impl::session_impl( std::pair listen_port_range , fingerprint const& cl_fprint - , char const* listen_interface) + , char const* listen_interface +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , fs::path const& logpath +#endif + ) : m_send_buffers(send_buffer_size) , m_files(40) , m_strand(m_io_service) @@ -570,6 +574,9 @@ namespace detail #endif , m_timer(m_io_service) , m_next_connect_torrent(0) +#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) + , m_logpath(logpath) +#endif , m_checker_impl(*this) { #ifdef WIN32 @@ -1602,7 +1609,7 @@ namespace detail , int instance, bool append) { // current options are file_logger, cout_logger and null_logger - return boost::shared_ptr(new logger(name + ".log", instance, append)); + return boost::shared_ptr(new logger(m_logpath, name + ".log", instance, append)); } #endif