mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 22:22:31 +00:00
Added logging, currently shows failed torrent creations but does not
time out the log messages. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@307 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -5,16 +5,18 @@ libsub_core_a_SOURCES = \
|
||||
curl_get.h \
|
||||
curl_stack.cc \
|
||||
curl_stack.h \
|
||||
hash_queue.cc \
|
||||
hash_queue.h \
|
||||
http_queue.cc \
|
||||
http_queue.h \
|
||||
download.cc \
|
||||
download.h \
|
||||
download_list.cc \
|
||||
download_list.h \
|
||||
download_store.cc \
|
||||
download_store.h \
|
||||
hash_queue.cc \
|
||||
hash_queue.h \
|
||||
http_queue.cc \
|
||||
http_queue.h \
|
||||
log.cc \
|
||||
log.h \
|
||||
manager.cc \
|
||||
manager.h \
|
||||
poll.cc \
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "log.h"
|
||||
#include "utils/functional.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
void
|
||||
Log::push_front(const std::string& msg) {
|
||||
Base::push_front(Type(utils::Timer::cache(), msg));
|
||||
|
||||
m_signalUpdate.emit();
|
||||
}
|
||||
|
||||
Log::iterator
|
||||
Log::find_older(utils::Timer t) {
|
||||
return std::find_if(begin(), end(), func::on(func::mem_ptr_ref(&Type::first),
|
||||
std::bind1st(std::less_equal<utils::Timer>(), t)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef RTORRENT_CORE_LOG_H
|
||||
#define RTORRENT_CORE_LOG_H
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <sigc++/signal.h>
|
||||
|
||||
#include "utils/timer.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
class Log : private std::deque<std::pair<utils::Timer, std::string> > {
|
||||
public:
|
||||
typedef std::pair<utils::Timer, std::string> Type;
|
||||
typedef std::deque<Type> Base;
|
||||
typedef sigc::signal0<void> Signal;
|
||||
|
||||
using Base::iterator;
|
||||
using Base::const_iterator;
|
||||
using Base::reverse_iterator;
|
||||
using Base::const_reverse_iterator;
|
||||
|
||||
using Base::begin;
|
||||
using Base::end;
|
||||
using Base::rbegin;
|
||||
using Base::rend;
|
||||
|
||||
using Base::empty;
|
||||
using Base::size;
|
||||
|
||||
void push_front(const std::string& msg);
|
||||
|
||||
iterator find_older(utils::Timer t);
|
||||
|
||||
Signal& signal_update() { return m_signalUpdate; }
|
||||
|
||||
private:
|
||||
Signal m_signalUpdate;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+8
-1
@@ -99,9 +99,15 @@ Manager::receive_http_done(CurlGet* http) {
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
// What to do? Keep in list for now.
|
||||
m_log.push_front(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_http_failed(std::string msg) {
|
||||
m_log.push_front("Http download error: \"" + msg + "\"");
|
||||
}
|
||||
|
||||
void
|
||||
Manager::create_file(const std::string& uri) {
|
||||
try {
|
||||
@@ -111,6 +117,7 @@ Manager::create_file(const std::string& uri) {
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
// What to do? Keep in list for now.
|
||||
m_log.push_front(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +126,7 @@ Manager::create_http(const std::string& uri) {
|
||||
core::HttpQueue::iterator itr = m_httpQueue.insert(uri);
|
||||
|
||||
(*itr)->signal_done().slots().push_front(sigc::bind(sigc::mem_fun(*this, &core::Manager::receive_http_done), *itr));
|
||||
// Add the failed signal here.
|
||||
(*itr)->signal_failed().slots().push_front(sigc::mem_fun(*this, &core::Manager::receive_http_failed));
|
||||
}
|
||||
|
||||
Manager::iterator
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "hash_queue.h"
|
||||
#include "http_queue.h"
|
||||
#include "poll.h"
|
||||
#include "log.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
@@ -23,6 +24,7 @@ public:
|
||||
HttpQueue& get_http_queue() { return m_httpQueue; }
|
||||
|
||||
Poll& get_poll() { return m_poll; }
|
||||
Log& get_log() { return m_log; }
|
||||
|
||||
void initialize();
|
||||
void cleanup();
|
||||
@@ -40,6 +42,7 @@ public:
|
||||
|
||||
private:
|
||||
void receive_http_done(CurlGet* http);
|
||||
void receive_http_failed(std::string msg);
|
||||
|
||||
void create_file(const std::string& uri);
|
||||
void create_http(const std::string& uri);
|
||||
@@ -50,7 +53,9 @@ private:
|
||||
DownloadStore m_downloadStore;
|
||||
HashQueue m_hashQueue;
|
||||
HttpQueue m_httpQueue;
|
||||
|
||||
Poll m_poll;
|
||||
Log m_log;
|
||||
|
||||
std::string m_dns;
|
||||
int m_portFirst;
|
||||
|
||||
Reference in New Issue
Block a user