* Changing push_log calls to the new logging facility.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1284 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2011-09-21 05:07:06 +00:00
parent 156d69c854
commit 4914d798f1
10 changed files with 44 additions and 31 deletions
+5 -3
View File
@@ -55,6 +55,7 @@
#include <torrent/download/resource_manager.h>
#include <torrent/peer/connection_list.h>
#include <torrent/peer/peer_list.h>
#include <torrent/utils/log.h>
#include <torrent/utils/option_strings.h>
#include "core/download.h"
@@ -318,10 +319,11 @@ struct call_add_d_peer_t {
call_add_d_peer_t(core::Download* d, int port) : m_download(d), m_port(port) { }
void operator() (const sockaddr* sa, int err) {
if (sa == NULL)
control->core()->push_log("Could not resolve host.");
else
if (sa == NULL) {
lt_log_print(torrent::LOG_CONNECTION_WARN, "Could not resolve hostname for added peer.");
} else {
m_download->download()->add_peer(sa, m_port);
}
}
core::Download* m_download;
+2 -1
View File
@@ -44,6 +44,7 @@
#include <sigc++/adaptors/bind.h>
#include <torrent/rate.h>
#include <torrent/hash_string.h>
#include <torrent/utils/log.h>
#include "core/download.h"
#include "core/download_list.h"
@@ -235,7 +236,7 @@ apply_close_low_diskspace(int64_t arg) {
}
if (closed)
control->core()->push_log("Closed torrents due to low diskspace.");
lt_log_print(torrent::LOG_TORRENT_ERROR, "Closed torrents due to low diskspace.");
return torrent::Object();
}
+8 -9
View File
@@ -42,6 +42,7 @@
#include <torrent/dht_manager.h>
#include <torrent/object_stream.h>
#include <torrent/rate.h>
#include <torrent/utils/log.h>
#include "rpc/parse_commands.h"
@@ -76,7 +77,7 @@ DhtManager::load_dht_cache() {
// If the cache file is corrupted we will just discard it with an
// error message.
if (cache_file.fail()) {
control->core()->push_log("DHT warning: Cache file corrupted, discarding.");
lt_log_print(torrent::LOG_DHT_WARN, "DHT cache file corrupted, discarding.");
cache = torrent::Object::create_map();
}
}
@@ -88,7 +89,7 @@ DhtManager::load_dht_cache() {
start_dht();
} catch (torrent::local_error& e) {
control->core()->push_log((std::string("DHT error: ") + e.what()).c_str());
lt_log_print(torrent::LOG_DHT_WARN, "DHT failed: %s", e.what());
}
}
@@ -107,9 +108,7 @@ DhtManager::start_dht() {
if (port <= 0)
return;
char msg[128];
snprintf(msg, sizeof(msg), "Starting DHT server on port %d.", port);
control->core()->push_log(msg);
lt_log_print(torrent::LOG_DHT_INFO, "Starting DHT server on port %d.", port);
try {
torrent::dht_manager()->start(port);
@@ -126,7 +125,7 @@ DhtManager::start_dht() {
m_dhtPrevBytesDown = 0;
} catch (torrent::local_error& e) {
control->core()->push_log((std::string("DHT error: ") + e.what()).c_str());
lt_log_print(torrent::LOG_DHT_ERROR, "DHT start failed: %s", e.what());
m_start = dht_off;
}
}
@@ -138,7 +137,7 @@ DhtManager::stop_dht() {
if (torrent::dht_manager()->is_active()) {
log_statistics(true);
control->core()->push_log("Stopping DHT server.");
lt_log_print(torrent::LOG_DHT_INFO, "Stopping DHT server.");
torrent::dht_manager()->stop();
}
}
@@ -220,7 +219,7 @@ DhtManager::log_statistics(bool force) {
// We should have had clients ping us at least but have received
// nothing, that means the UDP port is probably unreachable.
if (torrent::dht_manager()->can_receive_queries())
control->core()->push_log("Warning: DHT port appears to be unreachable, no queries received.");
lt_log_print(torrent::LOG_DHT_WARN, "DHT port appears to be unreachable, no queries received.");
torrent::dht_manager()->set_can_receive(false);
}
@@ -228,7 +227,7 @@ DhtManager::log_statistics(bool force) {
if (stats.queries_sent - m_dhtPrevQueriesSent > stats.num_nodes * 2 + 20 && stats.replies_received == m_dhtPrevRepliesReceived) {
// No replies to over 20 queries plus two per node we have. Probably firewalled.
if (!m_warned)
control->core()->push_log("Warning: DHT port appears to be firewalled, no replies received.");
lt_log_print(torrent::LOG_DHT_WARN, "DHT port appears to be firewalled, no replies received.");
m_warned = true;
return false;
+13 -12
View File
@@ -50,6 +50,7 @@
#include <torrent/object.h>
#include <torrent/object_stream.h>
#include <torrent/torrent.h>
#include <torrent/utils/log.h>
#include "rpc/parse_commands.h"
@@ -90,7 +91,7 @@ DownloadList::session_save() {
unsigned int c = std::count_if(begin(), end(), std::bind1st(std::mem_fun(&DownloadStore::save_resume), control->core()->download_store()));
if (c != size())
control->core()->push_log("Failed to save session torrents.");
lt_log_print(torrent::LOG_ERROR, "Failed to save session torrents.");
control->dht_manager()->save_dht_cache();
}
@@ -128,7 +129,7 @@ DownloadList::create(torrent::Object* obj, bool printLog) {
delete obj;
if (printLog)
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download: %s", e.what());
return NULL;
}
@@ -152,7 +153,7 @@ DownloadList::create(std::istream* str, bool printLog) {
delete object;
if (printLog)
control->core()->push_log("Could not create download, the input is not a valid torrent.");
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download, the input is not a valid torrent.");
return NULL;
}
@@ -163,7 +164,7 @@ DownloadList::create(std::istream* str, bool printLog) {
delete object;
if (printLog)
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download: %s", e.what());
return NULL;
}
@@ -232,7 +233,7 @@ DownloadList::open(Download* download) {
return true;
} catch (torrent::local_error& e) {
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not open download: %s", e.what());
return false;
}
}
@@ -260,7 +261,7 @@ DownloadList::close(Download* download) {
close_throw(download);
} catch (torrent::local_error& e) {
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not close download: %s", e.what());
}
}
@@ -408,7 +409,7 @@ DownloadList::resume(Download* download, int flags) {
DL_TRIGGER_EVENT(download, "event.download.resumed");
} catch (torrent::local_error& e) {
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not resume download: %s", e.what());
}
}
@@ -455,7 +456,7 @@ DownloadList::pause(Download* download, int flags) {
//control->core()->download_store()->save(download);
} catch (torrent::local_error& e) {
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not pause download: %s", e.what());
}
}
@@ -471,7 +472,7 @@ DownloadList::check_hash(Download* download) {
hash_queue(download, Download::variable_hashing_rehash);
} catch (torrent::local_error& e) {
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not check hash: %s", e.what());
}
}
@@ -532,7 +533,7 @@ DownloadList::hash_done(Download* download) {
confirm_finished(download);
} else {
download->set_message("Hash check on download completion found bad chunks, consider using \"safe_sync\".");
control->core()->push_log("Hash check on download completion found bad chunks, consider using \"safe_sync\".");
lt_log_print(torrent::LOG_TORRENT_ERROR, "Hash check on download completion found bad chunks, consider using \"safe_sync\".");
DL_TRIGGER_EVENT(download, "event.download.hash_final_failed");
}
@@ -670,7 +671,7 @@ DownloadList::process_meta_download(Download* download) {
std::string metafile = (*download->file_list()->begin())->frozen_path();
std::fstream file(metafile.c_str(), std::ios::in | std::ios::binary);
if (!file.is_open()) {
control->core()->push_log("Could not read download metadata.");
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not read download metadata.");
return;
}
@@ -678,7 +679,7 @@ DownloadList::process_meta_download(Download* download) {
file >> bencode->insert_key("info", torrent::Object());
if (file.fail()) {
delete bencode;
control->core()->push_log("Could not create download, the input is not a valid torrent.");
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download, the input is not a valid torrent.");
return;
}
file.close();
+2 -1
View File
@@ -57,6 +57,7 @@
#include <torrent/object_stream.h>
#include <torrent/tracker_list.h>
#include <torrent/throttle.h>
#include <torrent/utils/log.h>
#include "rpc/parse_commands.h"
#include "utils/directory.h"
@@ -579,7 +580,7 @@ Manager::receive_hashing_changed() {
} else {
(*itr)->set_hash_failed(true);
push_log(e.what());
lt_log_print(torrent::LOG_TORRENT_ERROR, "Hashing failed: %s", e.what());
}
}
}
+5
View File
@@ -43,6 +43,7 @@
#include <sys/socket.h>
#include <torrent/exceptions.h>
#include <torrent/poll.h>
#include <torrent/utils/log.h>
#include "utils/socket_fd.h"
@@ -182,6 +183,8 @@ SCgiTask::event_read() {
write(m_parent->log_fd(), "\n---\n", sizeof("\n---\n"));
}
lt_log_print(torrent::LOG_RPC_DEBUG, "---\n%*s\n---", m_bufferSize - std::distance(m_buffer, m_body), m_body);
// Close if the call failed, else stay open to write back data.
if (!m_parent->receive_call(this, m_body, m_bufferSize - std::distance(m_buffer, m_body)))
close();
@@ -240,6 +243,8 @@ SCgiTask::receive_write(const char* buffer, uint32_t length) {
write(m_parent->log_fd(), "\n---\n", sizeof("\n---\n"));
}
lt_log_print(torrent::LOG_RPC_DEBUG, "---\n%*s\n---", m_bufferSize, m_buffer);
event_write();
return true;
}
+2 -2
View File
@@ -46,6 +46,7 @@
#include <unistd.h>
#include <rak/error_number.h>
#include <torrent/exceptions.h>
#include <torrent/utils/log.h>
#include "globals.h"
#include "control.h"
@@ -170,9 +171,8 @@ ThreadBase::event_loop(ThreadBase* threadBase) {
} catch (torrent::shutdown_exception& e) {
acquire_global_lock();
control->core()->push_log("Shutting down thread.");
lt_log_print(torrent::LOG_THREAD_NOTICE, "Shutting down thread.");
release_global_lock();
// sleep(20);
}
threadBase->m_state = STATE_INACTIVE;
+2
View File
@@ -97,6 +97,8 @@ protected:
void call_queued_items();
// TODO: Add thread name.
pthread_t m_thread;
state_type m_state;
+2 -1
View File
@@ -42,6 +42,7 @@
#include <sigc++/adaptors/hide.h>
#include <torrent/exceptions.h>
#include <torrent/torrent.h>
#include <torrent/utils/log.h>
#include "core/download.h"
#include "core/download_list.h"
@@ -328,7 +329,7 @@ DownloadList::receive_exit_input(Input type) {
}
} catch (torrent::input_error& e) {
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_WARN, "Input failed: %s", e.what());
}
activate_display(DISPLAY_DOWNLOAD_LIST);
+3 -2
View File
@@ -39,6 +39,7 @@
#include <sigc++/adaptors/bind.h>
#include <torrent/exceptions.h>
#include <torrent/object.h>
#include <torrent/utils/log.h>
#include "core/download.h"
#include "core/manager.h"
@@ -152,7 +153,7 @@ ElementDownloadList::receive_command(const char* cmd) {
m_view->set_last_changed();
} catch (torrent::input_error& e) {
control->core()->push_log(e.what());
lt_log_print(torrent::LOG_WARN, "Command failed: %s", e.what());
return;
}
}
@@ -194,7 +195,7 @@ ElementDownloadList::receive_cycle_throttle() {
core::Download* download = *m_view->focus();
if (download->is_active()) {
control->core()->push_log("Cannot change throttle on active download.");
lt_log_print(torrent::LOG_TORRENT_WARN, "Cannot change throttle on active download.");
return;
}