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:
rakshasa
2005-02-25 22:05:15 +00:00
parent f66424f642
commit 9fe97ee490
17 changed files with 220 additions and 21 deletions
+2
View File
@@ -17,6 +17,8 @@ libsub_display_a_SOURCES = \
window_http_queue.h \
window_input.cc \
window_input.h \
window_log.cc \
window_log.h \
window_peer_info.cc \
window_peer_info.h \
window_peer_list.cc \
+2
View File
@@ -7,6 +7,8 @@
namespace display {
Window::Slot Window::m_slotAdjust;
Window::~Window() {
delete m_canvas;
}
+16 -8
View File
@@ -1,6 +1,8 @@
#ifndef RTORRENT_WINDOW_BASE_H
#define RTORRENT_WINDOW_BASE_H
#include <sigc++/slot.h>
#include "utils/timer.h"
namespace display {
@@ -9,38 +11,44 @@ class Canvas;
class Window {
public:
typedef sigc::slot0<void> Slot;
Window(Canvas* c = NULL, bool d = false, int h = 1) :
m_canvas(c), m_active(true), m_dynamic(d), m_minHeight(h) {}
virtual ~Window();
bool is_active() { return m_active; }
bool is_dynamic() { return m_dynamic; }
bool is_dirty() { return m_lastDraw == 0; }
bool is_active() { return m_active; }
bool is_dynamic() { return m_dynamic; }
bool is_dirty() { return m_lastDraw == 0; }
int get_min_height() { return m_minHeight; }
int get_min_height() { return m_minHeight; }
bool get_active() { return m_active; }
void set_active(bool a) { m_active = a; }
bool get_active() { return m_active; }
void set_active(bool a) { m_active = a; }
void refresh();
void resize(int x, int y, int w, int h);
void mark_dirty() { m_lastDraw = 0; }
void mark_dirty() { m_lastDraw = 0; }
virtual void redraw() = 0;
static void slot_adjust(Slot s) { m_slotAdjust = s; }
protected:
Window(const Window&);
void operator = (const Window&);
static Slot m_slotAdjust;
Canvas* m_canvas;
bool m_active;
bool m_dynamic;
int m_minHeight;
utils::Timer m_lastDraw;
utils::Timer m_lastDraw;
};
}
+3 -1
View File
@@ -72,7 +72,9 @@ WindowHttpQueue::cleanup_list() {
std::string
WindowHttpQueue::create_name(core::CurlGet* h) {
std::string n = h->get_url().substr(h->get_url().rfind('/', h->get_url().size() - std::min((size_t)10, h->get_url().size())));
size_t p = h->get_url().rfind('/', h->get_url().size() - std::min<int>(10, h->get_url().size()));
std::string n = p != std::string::npos ? h->get_url().substr(p) : h->get_url();
if (n.empty())
throw std::logic_error("WindowHttpQueue::create_name(...) made a bad string");
-6
View File
@@ -1,7 +1,6 @@
#ifndef RTORRENT_DISPLAY_WINDOW_HTTP_QUEUE_H
#define RTORRENT_DISPLAY_WINDOW_HTTP_QUEUE_H
#include <sigc++/slot.h>
#include <sigc++/connection.h>
#include "window.h"
@@ -15,13 +14,9 @@ namespace display {
class WindowHttpQueue : public Window {
public:
typedef sigc::slot0<void> Slot;
WindowHttpQueue(core::HttpQueue* q);
~WindowHttpQueue() { m_connInsert.disconnect(); m_connErase.disconnect(); }
void slot_adjust(Slot s) { m_slotAdjust = s; }
virtual void redraw();
private:
@@ -45,7 +40,6 @@ private:
static std::string create_name(core::CurlGet* h);
core::HttpQueue* m_queue;
Slot m_slotAdjust;
sigc::connection m_connInsert;
sigc::connection m_connErase;
+52
View File
@@ -0,0 +1,52 @@
#include "config.h"
#include "core/log.h"
#include "canvas.h"
#include "window_log.h"
namespace display {
WindowLog::WindowLog(core::Log* l) :
Window(new Canvas, false, 0),
m_log(l) {
set_active(false);
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
}
WindowLog::~WindowLog() {
m_connUpdate.disconnect();
}
void
WindowLog::redraw() {
if (!is_dirty())
return;
m_lastDraw = utils::Timer::cache();
m_canvas->erase();
int pos = 0;
for (core::Log::iterator itr = m_log->begin(), end = m_log->end(); itr != end; ++itr)
m_canvas->print(0, pos++, "Log: %s", itr->second.c_str());
}
void
WindowLog::receive_update() {
int newHeight = std::min<size_t>(m_log->size(), 5);
if (newHeight != m_minHeight) {
m_minHeight = newHeight;
set_active(m_minHeight != 0);
m_slotAdjust();
}
mark_dirty();
}
}
+30
View File
@@ -0,0 +1,30 @@
#ifndef RTORRENT_DISPLAY_WINDOW_LOG_H
#define RTORRENT_DISPLAY_WINDOW_LOG_H
#include <sigc++/connection.h>
#include "window.h"
namespace core {
class Log;
}
namespace display {
class WindowLog : public Window {
public:
WindowLog(core::Log* l);
~WindowLog();
virtual void redraw();
private:
void receive_update();
core::Log* m_log;
sigc::connection m_connUpdate;
};
}
#endif