make all the log functions/structs/enums use a single 'tr_log' namespace, such as tr_logGetQueue, tr_logAddInfo, tr_logIsLevelActive
This commit is contained in:
parent
5af4abfc82
commit
f75027d5e9
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/tr-getopt.h>
|
||||
#include <libtransmission/log.h>
|
||||
#include <libtransmission/utils.h>
|
||||
#include <libtransmission/variant.h>
|
||||
#include <libtransmission/version.h>
|
||||
|
@ -145,7 +146,7 @@ gotsig (int sig)
|
|||
{
|
||||
if (!mySession)
|
||||
{
|
||||
tr_inf ("Deferring reload until session is fully started.");
|
||||
tr_logAddInfo ("Deferring reload until session is fully started.");
|
||||
seenHUP = true;
|
||||
}
|
||||
else
|
||||
|
@ -161,7 +162,7 @@ gotsig (int sig)
|
|||
}
|
||||
|
||||
configDir = tr_sessionGetConfigDir (mySession);
|
||||
tr_inf ("Reloading settings from \"%s\"", configDir);
|
||||
tr_logAddInfo ("Reloading settings from \"%s\"", configDir);
|
||||
tr_variantInitDict (&settings, 0);
|
||||
tr_variantDictAddBool (&settings, TR_KEY_rpc_enabled, true);
|
||||
tr_sessionLoadSettings (&settings, configDir, MY_NAME);
|
||||
|
@ -173,7 +174,7 @@ gotsig (int sig)
|
|||
}
|
||||
|
||||
default:
|
||||
tr_err ("Unexpected signal (%d) in daemon, closing.", sig);
|
||||
tr_logAddError ("Unexpected signal (%d) in daemon, closing.", sig);
|
||||
/* no break */
|
||||
|
||||
case SIGINT:
|
||||
|
@ -265,19 +266,19 @@ onFileAdded (tr_session * session, const char * dir, const char * file)
|
|||
tr_torrentNew (ctor, &err);
|
||||
|
||||
if (err == TR_PARSE_ERR)
|
||||
tr_err ("Error parsing .torrent file \"%s\"", file);
|
||||
tr_logAddError ("Error parsing .torrent file \"%s\"", file);
|
||||
else
|
||||
{
|
||||
bool trash = false;
|
||||
int test = tr_ctorGetDeleteSource (ctor, &trash);
|
||||
|
||||
tr_inf ("Parsing .torrent file successful \"%s\"", file);
|
||||
tr_logAddInfo ("Parsing .torrent file successful \"%s\"", file);
|
||||
|
||||
if (!test && trash)
|
||||
{
|
||||
tr_inf ("Deleting input .torrent file \"%s\"", file);
|
||||
tr_logAddInfo ("Deleting input .torrent file \"%s\"", file);
|
||||
if (remove (filename))
|
||||
tr_err ("Error deleting .torrent file: %s", tr_strerror (errno));
|
||||
tr_logAddError ("Error deleting .torrent file: %s", tr_strerror (errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -298,7 +299,7 @@ printMessage (FILE * logfile, int level, const char * name, const char * message
|
|||
if (logfile != NULL)
|
||||
{
|
||||
char timestr[64];
|
||||
tr_getLogTimeStr (timestr, sizeof (timestr));
|
||||
tr_logGetTimeStr (timestr, sizeof (timestr));
|
||||
if (name)
|
||||
fprintf (logfile, "[%s] %s %s (%s:%d)\n", timestr, name, message, file, line);
|
||||
else
|
||||
|
@ -311,9 +312,9 @@ printMessage (FILE * logfile, int level, const char * name, const char * message
|
|||
|
||||
/* figure out the syslog priority */
|
||||
switch (level) {
|
||||
case TR_MSG_ERR: priority = LOG_ERR; break;
|
||||
case TR_MSG_DBG: priority = LOG_DEBUG; break;
|
||||
default: priority = LOG_INFO; break;
|
||||
case TR_LOG_ERROR: priority = LOG_ERR; break;
|
||||
case TR_LOG_DEBUG: priority = LOG_DEBUG; break;
|
||||
default: priority = LOG_INFO; break;
|
||||
}
|
||||
|
||||
if (name)
|
||||
|
@ -327,8 +328,8 @@ printMessage (FILE * logfile, int level, const char * name, const char * message
|
|||
static void
|
||||
pumpLogMessages (FILE * logfile)
|
||||
{
|
||||
const tr_msg_list * l;
|
||||
tr_msg_list * list = tr_getQueuedMessages ();
|
||||
const tr_log_message * l;
|
||||
tr_log_message * list = tr_logGetQueue ();
|
||||
|
||||
for (l=list; l!=NULL; l=l->next)
|
||||
printMessage (logfile, l->level, l->name, l->message, l->file, l->line);
|
||||
|
@ -336,7 +337,7 @@ pumpLogMessages (FILE * logfile)
|
|||
if (logfile != NULL)
|
||||
fflush (logfile);
|
||||
|
||||
tr_freeMessageList (list);
|
||||
tr_logFreeQueue (list);
|
||||
}
|
||||
|
||||
static tr_rpc_callback_status
|
||||
|
@ -467,11 +468,11 @@ main (int argc, char ** argv)
|
|||
break;
|
||||
case 'Y': tr_variantDictAddBool (&settings, TR_KEY_lpd_enabled, false);
|
||||
break;
|
||||
case 810: tr_variantDictAddInt (&settings, TR_KEY_message_level, TR_MSG_ERR);
|
||||
case 810: tr_variantDictAddInt (&settings, TR_KEY_message_level, TR_LOG_ERROR);
|
||||
break;
|
||||
case 811: tr_variantDictAddInt (&settings, TR_KEY_message_level, TR_MSG_INF);
|
||||
case 811: tr_variantDictAddInt (&settings, TR_KEY_message_level, TR_LOG_INFO);
|
||||
break;
|
||||
case 812: tr_variantDictAddInt (&settings, TR_KEY_message_level, TR_MSG_DBG);
|
||||
case 812: tr_variantDictAddInt (&settings, TR_KEY_message_level, TR_LOG_DEBUG);
|
||||
break;
|
||||
case 830: tr_variantDictAddBool (&settings, TR_KEY_utp_enabled, true);
|
||||
break;
|
||||
|
@ -487,7 +488,7 @@ main (int argc, char ** argv)
|
|||
|
||||
if (!loaded)
|
||||
{
|
||||
printMessage (logfile, TR_MSG_ERR, MY_NAME, "Error loading config file -- exiting.", __FILE__, __LINE__);
|
||||
printMessage (logfile, TR_LOG_ERROR, MY_NAME, "Error loading config file -- exiting.", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -503,7 +504,7 @@ main (int argc, char ** argv)
|
|||
{
|
||||
char buf[256];
|
||||
tr_snprintf (buf, sizeof (buf), "Failed to daemonize: %s", tr_strerror (errno));
|
||||
printMessage (logfile, TR_MSG_ERR, MY_NAME, buf, __FILE__, __LINE__);
|
||||
printMessage (logfile, TR_LOG_ERROR, MY_NAME, buf, __FILE__, __LINE__);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
@ -513,7 +514,7 @@ main (int argc, char ** argv)
|
|||
tr_formatter_speed_init (SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR);
|
||||
session = tr_sessionInit ("daemon", configDir, true, &settings);
|
||||
tr_sessionSetRPCCallback (session, on_rpc_callback, NULL);
|
||||
tr_ninf (NULL, "Using settings from \"%s\"", configDir);
|
||||
tr_logAddNamedInfo (NULL, "Using settings from \"%s\"", configDir);
|
||||
tr_sessionSaveSettings (session, configDir, &settings);
|
||||
|
||||
pid_filename = NULL;
|
||||
|
@ -525,15 +526,15 @@ main (int argc, char ** argv)
|
|||
{
|
||||
fprintf (fp, "%d", (int)getpid ());
|
||||
fclose (fp);
|
||||
tr_inf ("Saved pidfile \"%s\"", pid_filename);
|
||||
tr_logAddInfo ("Saved pidfile \"%s\"", pid_filename);
|
||||
pidfile_created = true;
|
||||
}
|
||||
else
|
||||
tr_err ("Unable to save pidfile \"%s\": %s", pid_filename, tr_strerror (errno));
|
||||
tr_logAddError ("Unable to save pidfile \"%s\": %s", pid_filename, tr_strerror (errno));
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool (&settings, TR_KEY_rpc_authentication_required, &boolVal) && boolVal)
|
||||
tr_ninf (MY_NAME, "requiring authentication");
|
||||
tr_logAddNamedInfo (MY_NAME, "requiring authentication");
|
||||
|
||||
mySession = session;
|
||||
|
||||
|
@ -551,7 +552,7 @@ main (int argc, char ** argv)
|
|||
&& dir
|
||||
&& *dir)
|
||||
{
|
||||
tr_inf ("Watching \"%s\" for new .torrent files", dir);
|
||||
tr_logAddInfo ("Watching \"%s\" for new .torrent files", dir);
|
||||
watchdir = dtr_watchdir_new (mySession, dir, onFileAdded);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/log.h>
|
||||
#include <libtransmission/rpcimpl.h>
|
||||
#include <libtransmission/tr-getopt.h>
|
||||
#include <libtransmission/utils.h>
|
||||
|
@ -1677,7 +1678,7 @@ processResponse (const char * rpcurl, const void * response, size_t len)
|
|||
|
||||
if (tr_variantFromJson (&top, response, len))
|
||||
{
|
||||
tr_nerr (MY_NAME, "Unable to parse response \"%*.*s\"", (int)len,
|
||||
tr_logAddNamedError (MY_NAME, "Unable to parse response \"%*.*s\"", (int)len,
|
||||
(int)len, (char*)response);
|
||||
status |= EXIT_FAILURE;
|
||||
}
|
||||
|
@ -1803,7 +1804,7 @@ flush (const char * rpcurl, tr_variant ** benc)
|
|||
|
||||
if ((res = curl_easy_perform (curl)))
|
||||
{
|
||||
tr_nerr (MY_NAME, " (%s) %s", rpcurl_http, curl_easy_strerror (res));
|
||||
tr_logAddNamedError (MY_NAME, " (%s) %s", rpcurl_http, curl_easy_strerror (res));
|
||||
status |= EXIT_FAILURE;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#include <dirent.h> /* readdir */
|
||||
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/utils.h> /* tr_buildPath (), tr_inf () */
|
||||
#include <libtransmission/log.h>
|
||||
#include <libtransmission/utils.h> /* tr_buildPath (), tr_logAddInfo () */
|
||||
#include "watch.h"
|
||||
|
||||
struct dtr_watchdir
|
||||
|
@ -70,13 +71,13 @@ watchdir_new_impl (dtr_watchdir * w)
|
|||
}
|
||||
else
|
||||
{
|
||||
tr_inf ("Using inotify to watch directory \"%s\"", w->dir);
|
||||
tr_logAddInfo ("Using inotify to watch directory \"%s\"", w->dir);
|
||||
i = inotify_add_watch (w->inotify_fd, w->dir, DTR_INOTIFY_MASK);
|
||||
}
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
tr_err ("Unable to watch \"%s\": %s", w->dir, tr_strerror (errno));
|
||||
tr_logAddError ("Unable to watch \"%s\": %s", w->dir, tr_strerror (errno));
|
||||
}
|
||||
else if ((odir = opendir (w->dir)))
|
||||
{
|
||||
|
@ -89,7 +90,7 @@ watchdir_new_impl (dtr_watchdir * w)
|
|||
if (!tr_str_has_suffix (name, ".torrent")) /* skip non-torrents */
|
||||
continue;
|
||||
|
||||
tr_inf ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
|
||||
tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
|
||||
w->callback (w->session, w->dir, name);
|
||||
}
|
||||
|
||||
|
@ -138,7 +139,7 @@ watchdir_update_impl (dtr_watchdir * w)
|
|||
const char * name = event->name;
|
||||
if (tr_str_has_suffix (name, ".torrent"))
|
||||
{
|
||||
tr_inf ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
|
||||
tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
|
||||
w->callback (w->session, w->dir, name);
|
||||
}
|
||||
i += EVENT_SIZE + event->len;
|
||||
|
@ -159,7 +160,7 @@ watchdir_update_impl (dtr_watchdir * w)
|
|||
static void
|
||||
watchdir_new_impl (dtr_watchdir * w UNUSED)
|
||||
{
|
||||
tr_inf ("Using readdir to watch directory \"%s\"", w->dir);
|
||||
tr_logAddInfo ("Using readdir to watch directory \"%s\"", w->dir);
|
||||
w->lastFiles = evbuffer_new ();
|
||||
}
|
||||
static void
|
||||
|
@ -225,7 +226,7 @@ watchdir_update_impl (dtr_watchdir * w)
|
|||
|
||||
/* if this file wasn't here last time, try adding it */
|
||||
if (!is_file_in_list (w->lastFiles, name, len)) {
|
||||
tr_inf ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
|
||||
tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
|
||||
w->callback (w->session, w->dir, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -606,7 +606,9 @@ main (int argc, char ** argv)
|
|||
textdomain (MY_READABLE_NAME);
|
||||
|
||||
/* init glib/gtk */
|
||||
#if !GLIB_CHECK_VERSION(2,35,4)
|
||||
g_type_init ();
|
||||
#endif
|
||||
gtk_init (&argc, &argv);
|
||||
g_set_application_name (_("Transmission"));
|
||||
gtk_window_set_default_icon_name (MY_CONFIG_NAME);
|
||||
|
@ -1088,7 +1090,7 @@ on_prefs_changed (TrCore * core UNUSED, const tr_quark key, gpointer data)
|
|||
break;
|
||||
|
||||
case TR_KEY_message_level:
|
||||
tr_setMessageLevel (gtr_pref_int_get (key));
|
||||
tr_logSetLevel (gtr_pref_int_get (key));
|
||||
break;
|
||||
|
||||
case TR_KEY_peer_port:
|
||||
|
|
49
gtk/msgwin.c
49
gtk/msgwin.c
|
@ -18,6 +18,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/log.h>
|
||||
|
||||
#include "conf.h"
|
||||
#include "hig.h"
|
||||
|
@ -42,13 +43,13 @@ struct MsgData
|
|||
GtkListStore * store;
|
||||
GtkTreeModel * filter;
|
||||
GtkTreeModel * sort;
|
||||
tr_msg_level maxLevel;
|
||||
tr_log_level maxLevel;
|
||||
gboolean isPaused;
|
||||
guint refresh_tag;
|
||||
};
|
||||
|
||||
static struct tr_msg_list * myTail = NULL;
|
||||
static struct tr_msg_list * myHead = NULL;
|
||||
static struct tr_log_message * myTail = NULL;
|
||||
static struct tr_log_message * myHead = NULL;
|
||||
|
||||
/****
|
||||
*****
|
||||
|
@ -111,7 +112,7 @@ level_combo_changed_cb (GtkComboBox * combo_box, gpointer gdata)
|
|||
const int level = gtr_combo_box_get_active_enum (combo_box);
|
||||
const gboolean pinned_to_new = is_pinned_to_new (data);
|
||||
|
||||
tr_setMessageLevel (level);
|
||||
tr_logSetLevel (level);
|
||||
gtr_core_set_pref_int (data->core, TR_KEY_message_level, level);
|
||||
data->maxLevel = level;
|
||||
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (data->filter));
|
||||
|
@ -154,17 +155,17 @@ doSave (GtkWindow * parent, struct MsgData * data, const char * filename)
|
|||
{
|
||||
char * date;
|
||||
const char * levelStr;
|
||||
const struct tr_msg_list * node;
|
||||
const struct tr_log_message * node;
|
||||
|
||||
gtk_tree_model_get (model, &iter, COL_TR_MSG, &node, -1);
|
||||
date = gtr_localtime (node->when);
|
||||
switch (node->level)
|
||||
{
|
||||
case TR_MSG_DBG:
|
||||
case TR_LOG_DEBUG:
|
||||
levelStr = "debug";
|
||||
break;
|
||||
|
||||
case TR_MSG_ERR:
|
||||
case TR_LOG_ERROR:
|
||||
levelStr = "error";
|
||||
break;
|
||||
|
||||
|
@ -225,7 +226,7 @@ onClearRequest (GtkWidget * w UNUSED, gpointer gdata)
|
|||
struct MsgData * data = gdata;
|
||||
|
||||
gtk_list_store_clear (data->store);
|
||||
tr_freeMessageList (myHead);
|
||||
tr_logFreeQueue (myHead);
|
||||
myHead = myTail = NULL;
|
||||
}
|
||||
|
||||
|
@ -242,9 +243,9 @@ getForegroundColor (int msgLevel)
|
|||
{
|
||||
switch (msgLevel)
|
||||
{
|
||||
case TR_MSG_DBG: return "forestgreen";
|
||||
case TR_MSG_INF: return "black";
|
||||
case TR_MSG_ERR: return "red";
|
||||
case TR_LOG_DEBUG: return "forestgreen";
|
||||
case TR_LOG_INFO: return "black";
|
||||
case TR_LOG_ERROR: return "red";
|
||||
default: g_assert_not_reached (); return "black";
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +259,7 @@ renderText (GtkTreeViewColumn * column UNUSED,
|
|||
{
|
||||
const int col = GPOINTER_TO_INT (gcol);
|
||||
char * str = NULL;
|
||||
const struct tr_msg_list * node;
|
||||
const struct tr_log_message * node;
|
||||
|
||||
gtk_tree_model_get (tree_model, iter, col, &str, COL_TR_MSG, &node, -1);
|
||||
g_object_set (renderer, "text", str,
|
||||
|
@ -276,7 +277,7 @@ renderTime (GtkTreeViewColumn * column UNUSED,
|
|||
{
|
||||
struct tm tm;
|
||||
char buf[16];
|
||||
const struct tr_msg_list * node;
|
||||
const struct tr_log_message * node;
|
||||
|
||||
gtk_tree_model_get (tree_model, iter, COL_TR_MSG, &node, -1);
|
||||
tm = *localtime (&node->when);
|
||||
|
@ -354,7 +355,7 @@ appendColumn (GtkTreeView * view, int col)
|
|||
static gboolean
|
||||
isRowVisible (GtkTreeModel * model, GtkTreeIter * iter, gpointer gdata)
|
||||
{
|
||||
const struct tr_msg_list * node;
|
||||
const struct tr_log_message * node;
|
||||
const struct MsgData * data = gdata;
|
||||
|
||||
gtk_tree_model_get (model, iter, COL_TR_MSG, &node, -1);
|
||||
|
@ -372,10 +373,10 @@ onWindowDestroyed (gpointer gdata, GObject * deadWindow UNUSED)
|
|||
g_free (data);
|
||||
}
|
||||
|
||||
static tr_msg_list *
|
||||
addMessages (GtkListStore * store, struct tr_msg_list * head)
|
||||
static tr_log_message *
|
||||
addMessages (GtkListStore * store, struct tr_log_message * head)
|
||||
{
|
||||
tr_msg_list * i;
|
||||
tr_log_message * i;
|
||||
static unsigned int sequence = 0;
|
||||
const char * default_name = g_get_application_name ();
|
||||
|
||||
|
@ -391,7 +392,7 @@ addMessages (GtkListStore * store, struct tr_msg_list * head)
|
|||
-1);
|
||||
|
||||
/* if it's an error message, dump it to the terminal too */
|
||||
if (i->level == TR_MSG_ERR)
|
||||
if (i->level == TR_LOG_ERROR)
|
||||
{
|
||||
GString * gstr = g_string_sized_new (512);
|
||||
g_string_append_printf (gstr, "%s:%d %s", i->file, i->line, i->message);
|
||||
|
@ -413,12 +414,12 @@ onRefresh (gpointer gdata)
|
|||
|
||||
if (!data->isPaused)
|
||||
{
|
||||
tr_msg_list * msgs = tr_getQueuedMessages ();
|
||||
tr_log_message * msgs = tr_logGetQueue ();
|
||||
if (msgs)
|
||||
{
|
||||
/* add the new messages and append them to the end of
|
||||
* our persistent list */
|
||||
tr_msg_list * tail = addMessages (data->store, msgs);
|
||||
tr_log_message * tail = addMessages (data->store, msgs);
|
||||
if (myTail)
|
||||
myTail->next = msgs;
|
||||
else
|
||||
|
@ -436,9 +437,9 @@ onRefresh (gpointer gdata)
|
|||
static GtkWidget*
|
||||
debug_level_combo_new (void)
|
||||
{
|
||||
GtkWidget * w = gtr_combo_box_new_enum (_("Error"), TR_MSG_ERR,
|
||||
_("Information"), TR_MSG_INF,
|
||||
_("Debug"), TR_MSG_DBG,
|
||||
GtkWidget * w = gtr_combo_box_new_enum (_("Error"), TR_LOG_ERROR,
|
||||
_("Information"), TR_LOG_INFO,
|
||||
_("Debug"), TR_LOG_DEBUG,
|
||||
NULL);
|
||||
gtr_combo_box_set_active_enum (GTK_COMBO_BOX (w), gtr_pref_int_get (TR_KEY_message_level));
|
||||
return w;
|
||||
|
@ -521,7 +522,7 @@ gtr_message_log_window_new (GtkWindow * parent, TrCore * core)
|
|||
G_TYPE_UINT, /* sequence */
|
||||
G_TYPE_POINTER, /* category */
|
||||
G_TYPE_POINTER, /* message */
|
||||
G_TYPE_POINTER); /* struct tr_msg_list */
|
||||
G_TYPE_POINTER); /* struct tr_log_message */
|
||||
|
||||
addMessages (data->store, myHead);
|
||||
onRefresh (data); /* much faster to populate *before* it has listeners */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <event2/buffer.h>
|
||||
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/log.h>
|
||||
#include <libtransmission/rpcimpl.h>
|
||||
#include <libtransmission/utils.h> /* tr_free */
|
||||
#include <libtransmission/variant.h>
|
||||
|
@ -1548,11 +1549,11 @@ gtr_inhibit_hibernation (guint * cookie)
|
|||
/* logging */
|
||||
if (success)
|
||||
{
|
||||
tr_inf ("%s", _("Inhibiting desktop hibernation"));
|
||||
tr_logAddInfo ("%s", _("Inhibiting desktop hibernation"));
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_err (_("Couldn't inhibit desktop hibernation: %s"), err->message);
|
||||
tr_logAddError (_("Couldn't inhibit desktop hibernation: %s"), err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
|
||||
|
@ -1586,7 +1587,7 @@ gtr_uninhibit_hibernation (guint inhibit_cookie)
|
|||
/* logging */
|
||||
if (err == NULL)
|
||||
{
|
||||
tr_inf ("%s", _("Allowing desktop hibernation"));
|
||||
tr_logAddInfo ("%s", _("Allowing desktop hibernation"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ libtransmission_a_SOURCES = \
|
|||
history.c \
|
||||
inout.c \
|
||||
list.c \
|
||||
log.c \
|
||||
magnet.c \
|
||||
makemeta.c \
|
||||
metainfo.c \
|
||||
|
@ -88,6 +89,7 @@ noinst_HEADERS = \
|
|||
jsonsl.h \
|
||||
libtransmission-test.h \
|
||||
list.h \
|
||||
log.h \
|
||||
magnet.h \
|
||||
makemeta.h \
|
||||
metainfo.h \
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "announcer-common.h"
|
||||
#include "log.h"
|
||||
#include "net.h" /* tr_globalIPv6 () */
|
||||
#include "peer-mgr.h" /* pex */
|
||||
#include "torrent.h"
|
||||
|
@ -31,9 +32,12 @@
|
|||
#include "web.h" /* tr_http_escape () */
|
||||
|
||||
#define dbgmsg(name, ...) \
|
||||
if (tr_deepLoggingIsActive ()) do { \
|
||||
tr_deepLog (__FILE__, __LINE__, name, __VA_ARGS__); \
|
||||
} while (0)
|
||||
do \
|
||||
{ \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, name, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/****
|
||||
*****
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "announcer.h"
|
||||
#include "announcer-common.h"
|
||||
#include "crypto.h" /* tr_cryptoRandBuf () */
|
||||
#include "log.h"
|
||||
#include "peer-io.h"
|
||||
#include "peer-mgr.h" /* tr_peerMgrCompactToPex () */
|
||||
#include "ptrarray.h"
|
||||
|
@ -29,9 +30,12 @@
|
|||
#include "utils.h"
|
||||
|
||||
#define dbgmsg(name, ...) \
|
||||
if (tr_deepLoggingIsActive ()) do { \
|
||||
tr_deepLog (__FILE__, __LINE__, name, __VA_ARGS__); \
|
||||
} while (0)
|
||||
do \
|
||||
{ \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, name, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/****
|
||||
*****
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "announcer.h"
|
||||
#include "announcer-common.h"
|
||||
#include "crypto.h" /* tr_cryptoRandInt (), tr_cryptoWeakRandInt () */
|
||||
#include "log.h"
|
||||
#include "peer-mgr.h" /* tr_peerMgrCompactToPex () */
|
||||
#include "ptrarray.h"
|
||||
#include "session.h"
|
||||
|
@ -37,11 +38,16 @@ static void tier_build_log_name (const struct tr_tier * tier,
|
|||
char * buf, size_t buflen);
|
||||
|
||||
#define dbgmsg(tier, ...) \
|
||||
if (tr_deepLoggingIsActive ()) do { \
|
||||
char name[128]; \
|
||||
tier_build_log_name (tier, name, sizeof (name)); \
|
||||
tr_deepLog (__FILE__, __LINE__, name, __VA_ARGS__); \
|
||||
} while (0)
|
||||
do \
|
||||
{ \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
{ \
|
||||
char name[128]; \
|
||||
tier_build_log_name (tier, name, sizeof (name)); \
|
||||
tr_logAddDeep (__FILE__, __LINE__, name, __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -749,7 +755,7 @@ tr_announcerNextManualAnnounce (const tr_torrent * tor)
|
|||
static void
|
||||
dbgmsg_tier_announce_queue (const tr_tier * tier)
|
||||
{
|
||||
if (tr_deepLoggingIsActive ())
|
||||
if (tr_logGetDeepEnabled ())
|
||||
{
|
||||
int i;
|
||||
char name[128];
|
||||
|
@ -765,7 +771,7 @@ dbgmsg_tier_announce_queue (const tr_tier * tier)
|
|||
}
|
||||
|
||||
message = evbuffer_free_to_str (buf);
|
||||
tr_deepLog (__FILE__, __LINE__, name, "announce queue is %s", message);
|
||||
tr_logAddDeep (__FILE__, __LINE__, name, "announce queue is %s", message);
|
||||
tr_free (message);
|
||||
}
|
||||
}
|
||||
|
@ -991,7 +997,7 @@ on_announce_error (tr_tier * tier, const char * err, tr_announce_event e)
|
|||
|
||||
/* set the error message */
|
||||
dbgmsg (tier, "%s", err);
|
||||
tr_torinf (tier->tor, "%s", err);
|
||||
tr_logAddTorInfo (tier->tor, "%s", err);
|
||||
tr_strlcpy (tier->lastAnnounceStr, err, sizeof (tier->lastAnnounceStr));
|
||||
|
||||
/* switch to the next tracker */
|
||||
|
@ -1000,7 +1006,7 @@ on_announce_error (tr_tier * tier, const char * err, tr_announce_event e)
|
|||
/* schedule a reannounce */
|
||||
interval = getRetryInterval (tier->currentTracker);
|
||||
dbgmsg (tier, "Retrying announce in %d seconds.", interval);
|
||||
tr_torinf (tier->tor, "Retrying announce in %d seconds.", interval);
|
||||
tr_logAddTorInfo (tier->tor, "Retrying announce in %d seconds.", interval);
|
||||
tier_announce_event_push (tier, e, tr_time () + interval);
|
||||
}
|
||||
|
||||
|
@ -1145,7 +1151,7 @@ on_announce_done (const tr_announce_response * response,
|
|||
then a separate scrape isn't needed */
|
||||
if ((scrape_fields >= 3) || (!tracker->scrape && (scrape_fields >= 1)))
|
||||
{
|
||||
tr_tordbg (tier->tor, "Announce response contained scrape info; "
|
||||
tr_logAddTorDbg (tier->tor, "Announce response contained scrape info; "
|
||||
"rescheduling next scrape to %d seconds from now.",
|
||||
tier->scrapeIntervalSec);
|
||||
tier->scrapeAt = get_next_scrape_time (announcer->session, tier, tier->scrapeIntervalSec);
|
||||
|
@ -1205,7 +1211,7 @@ announce_request_delegate (tr_announcer * announcer,
|
|||
else if (!memcmp (request->url, "udp://", 6))
|
||||
tr_tracker_udp_announce (session, request, callback, callback_data);
|
||||
else
|
||||
tr_err ("Unsupported url: %s", request->url);
|
||||
tr_logAddError ("Unsupported url: %s", request->url);
|
||||
|
||||
announce_request_free (request);
|
||||
}
|
||||
|
@ -1256,7 +1262,7 @@ on_scrape_error (tr_session * session, tr_tier * tier, const char * errmsg)
|
|||
|
||||
/* set the error message */
|
||||
dbgmsg (tier, "Scrape error: %s", errmsg);
|
||||
tr_torinf (tier->tor, "Scrape error: %s", errmsg);
|
||||
tr_logAddTorInfo (tier->tor, "Scrape error: %s", errmsg);
|
||||
tr_strlcpy (tier->lastScrapeStr, errmsg, sizeof (tier->lastScrapeStr));
|
||||
|
||||
/* switch to the next tracker */
|
||||
|
@ -1265,7 +1271,7 @@ on_scrape_error (tr_session * session, tr_tier * tier, const char * errmsg)
|
|||
/* schedule a rescrape */
|
||||
interval = getRetryInterval (tier->currentTracker);
|
||||
dbgmsg (tier, "Retrying scrape in %zu seconds.", (size_t)interval);
|
||||
tr_torinf (tier->tor, "Retrying scrape in %zu seconds.", (size_t)interval);
|
||||
tr_logAddTorInfo (tier->tor, "Retrying scrape in %zu seconds.", (size_t)interval);
|
||||
tier->lastScrapeSucceeded = false;
|
||||
tier->scrapeAt = get_next_scrape_time (session, tier, interval);
|
||||
}
|
||||
|
@ -1348,7 +1354,7 @@ on_scrape_done (const tr_scrape_response * response, void * vsession)
|
|||
tier->scrapeIntervalSec = MAX (DEFAULT_SCRAPE_INTERVAL_SEC,
|
||||
response->min_request_interval);
|
||||
tier->scrapeAt = get_next_scrape_time (session, tier, tier->scrapeIntervalSec);
|
||||
tr_tordbg (tier->tor, "Scrape successful. Rescraping in %d seconds.",
|
||||
tr_logAddTorDbg (tier->tor, "Scrape successful. Rescraping in %d seconds.",
|
||||
tier->scrapeIntervalSec);
|
||||
|
||||
if ((tracker = tier->currentTracker))
|
||||
|
@ -1384,7 +1390,7 @@ scrape_request_delegate (tr_announcer * announcer,
|
|||
else if (!memcmp (request->url, "udp://", 6))
|
||||
tr_tracker_udp_scrape (session, request, callback, callback_data);
|
||||
else
|
||||
tr_err ("Unsupported url: %s", request->url);
|
||||
tr_logAddError ("Unsupported url: %s", request->url);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1529,7 +1535,7 @@ announceMore (tr_announcer * announcer)
|
|||
n = MIN (tr_ptrArraySize (&announceMe), announcer->slotsAvailable);
|
||||
for (i=0; i<n; ++i) {
|
||||
tr_tier * tier = tr_ptrArrayNth (&announceMe, i);
|
||||
tr_tordbg (tier->tor, "%s", "Announcing to tracker");
|
||||
tr_logAddTorDbg (tier->tor, "%s", "Announcing to tracker");
|
||||
dbgmsg (tier, "announcing tier %d of %d", i, n);
|
||||
tierAnnounce (announcer, tier);
|
||||
}
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
#include "transmission.h"
|
||||
#include "bandwidth.h"
|
||||
#include "crypto.h" /* tr_cryptoWeakRandInt () */
|
||||
#include "log.h"
|
||||
#include "peer-io.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define dbgmsg(...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "blocklist.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
@ -94,7 +95,7 @@ blocklistLoad (tr_blocklistFile * b)
|
|||
fd = open (b->filename, O_RDONLY | O_BINARY);
|
||||
if (fd == -1)
|
||||
{
|
||||
tr_err (err_fmt, b->filename, tr_strerror (errno));
|
||||
tr_logAddError (err_fmt, b->filename, tr_strerror (errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,7 @@ blocklistLoad (tr_blocklistFile * b)
|
|||
b->rules = mmap (NULL, byteCount, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (!b->rules)
|
||||
{
|
||||
tr_err (err_fmt, b->filename, tr_strerror (errno));
|
||||
tr_logAddError (err_fmt, b->filename, tr_strerror (errno));
|
||||
close (fd);
|
||||
return;
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ blocklistLoad (tr_blocklistFile * b)
|
|||
b->ruleCount = byteCount / sizeof (struct tr_ipv4_range);
|
||||
|
||||
base = tr_basename (b->filename);
|
||||
tr_inf (_("Blocklist \"%s\" contains %zu entries"), base, b->ruleCount);
|
||||
tr_logAddInfo (_("Blocklist \"%s\" contains %zu entries"), base, b->ruleCount);
|
||||
tr_free (base);
|
||||
}
|
||||
|
||||
|
@ -334,7 +335,7 @@ tr_blocklistFileSetContent (tr_blocklistFile * b, const char * filename)
|
|||
in = fopen (filename, "rb");
|
||||
if (in == NULL)
|
||||
{
|
||||
tr_err (err_fmt, filename, tr_strerror (errno));
|
||||
tr_logAddError (err_fmt, filename, tr_strerror (errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -343,7 +344,7 @@ tr_blocklistFileSetContent (tr_blocklistFile * b, const char * filename)
|
|||
out = fopen (b->filename, "wb+");
|
||||
if (out == NULL)
|
||||
{
|
||||
tr_err (err_fmt, b->filename, tr_strerror (errno));
|
||||
tr_logAddError (err_fmt, b->filename, tr_strerror (errno));
|
||||
fclose (in);
|
||||
return 0;
|
||||
}
|
||||
|
@ -363,7 +364,7 @@ tr_blocklistFileSetContent (tr_blocklistFile * b, const char * filename)
|
|||
if (!parseLine (line, &range))
|
||||
{
|
||||
/* don't try to display the actual lines - it causes issues */
|
||||
tr_err (_("blocklist skipped invalid address at line %d"), inCount);
|
||||
tr_logAddError (_("blocklist skipped invalid address at line %d"), inCount);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -413,12 +414,12 @@ tr_blocklistFileSetContent (tr_blocklistFile * b, const char * filename)
|
|||
|
||||
if (fwrite (ranges, sizeof (struct tr_ipv4_range), ranges_count, out) != ranges_count)
|
||||
{
|
||||
tr_err (_("Couldn't save file \"%1$s\": %2$s"), b->filename, tr_strerror (errno));
|
||||
tr_logAddError (_("Couldn't save file \"%1$s\": %2$s"), b->filename, tr_strerror (errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
char * base = tr_basename (b->filename);
|
||||
tr_inf (_("Blocklist \"%s\" updated with %zu entries"), base, ranges_count);
|
||||
tr_logAddInfo (_("Blocklist \"%s\" updated with %zu entries"), base, ranges_count);
|
||||
tr_free (base);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "transmission.h"
|
||||
#include "cache.h"
|
||||
#include "inout.h"
|
||||
#include "log.h"
|
||||
#include "peer-common.h" /* MAX_BLOCK_SIZE */
|
||||
#include "ptrarray.h"
|
||||
#include "torrent.h"
|
||||
|
@ -27,8 +28,8 @@
|
|||
#define dbgmsg(...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
@ -259,7 +260,7 @@ tr_cacheSetLimit (tr_cache * cache, int64_t max_bytes)
|
|||
cache->max_blocks = getMaxBlocks (max_bytes);
|
||||
|
||||
tr_formatter_mem_B (buf, cache->max_bytes, sizeof (buf));
|
||||
tr_ndbg (MY_NAME, "Maximum cache size set to %s (%d blocks)", buf, cache->max_blocks);
|
||||
tr_logAddNamedDbg (MY_NAME, "Maximum cache size set to %s (%d blocks)", buf, cache->max_blocks);
|
||||
|
||||
return cacheTrim (cache);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "crypto.h"
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define MY_NAME "tr_crypto"
|
||||
|
@ -83,10 +84,10 @@ static const uint8_t dh_G[] = { 2 };
|
|||
|
||||
#define logErrorFromSSL(...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_ERR)) { \
|
||||
if (tr_logLevelIsActive (TR_LOG_ERROR)) { \
|
||||
char buf[512]; \
|
||||
ERR_error_string_n (ERR_get_error (), buf, sizeof (buf)); \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_ERR, MY_NAME, "%s", buf); \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_ERROR, MY_NAME, "%s", buf); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
|
|
@ -43,15 +43,17 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "fdlimit.h"
|
||||
#include "net.h"
|
||||
#include "log.h"
|
||||
#include "session.h"
|
||||
#include "torrent.h" /* tr_isTorrent () */
|
||||
|
||||
#define dbgmsg(...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
} while (0)
|
||||
do \
|
||||
{ \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/***
|
||||
****
|
||||
|
@ -342,7 +344,7 @@ cached_file_open (struct tr_cached_file * o,
|
|||
const int err = tr_mkdirp (dir, 0777) ? errno : 0;
|
||||
if (err)
|
||||
{
|
||||
tr_err (_("Couldn't create \"%1$s\": %2$s"), dir, tr_strerror (err));
|
||||
tr_logAddError (_("Couldn't create \"%1$s\": %2$s"), dir, tr_strerror (err));
|
||||
tr_free (dir);
|
||||
return err;
|
||||
}
|
||||
|
@ -353,7 +355,7 @@ cached_file_open (struct tr_cached_file * o,
|
|||
|
||||
if (writable && !alreadyExisted && (allocation == TR_PREALLOCATE_FULL))
|
||||
if (preallocate_file_full (filename, file_size))
|
||||
tr_dbg ("Preallocated file \"%s\"", filename);
|
||||
tr_logAddDebug ("Preallocated file \"%s\"", filename);
|
||||
|
||||
/* open the file */
|
||||
flags = writable ? (O_RDWR | O_CREAT) : O_RDONLY;
|
||||
|
@ -363,7 +365,7 @@ cached_file_open (struct tr_cached_file * o,
|
|||
if (o->fd == -1)
|
||||
{
|
||||
const int err = errno;
|
||||
tr_err (_("Couldn't open \"%1$s\": %2$s"), filename, tr_strerror (err));
|
||||
tr_logAddError (_("Couldn't open \"%1$s\": %2$s"), filename, tr_strerror (err));
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -378,7 +380,7 @@ cached_file_open (struct tr_cached_file * o,
|
|||
if (ftruncate (o->fd, file_size) == -1)
|
||||
{
|
||||
const int err = errno;
|
||||
tr_err (_("Couldn't truncate \"%1$s\": %2$s"), filename, tr_strerror (err));
|
||||
tr_logAddError (_("Couldn't truncate \"%1$s\": %2$s"), filename, tr_strerror (err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +525,7 @@ ensureSessionFdInfoExists (tr_session * session)
|
|||
limit.rlim_cur = new_limit;
|
||||
setrlimit (RLIMIT_NOFILE, &limit);
|
||||
getrlimit (RLIMIT_NOFILE, &limit);
|
||||
tr_inf ("Changed open file limit from %d to %d", old_limit, (int)limit.rlim_cur);
|
||||
tr_logAddInfo ("Changed open file limit from %d to %d", old_limit, (int)limit.rlim_cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -665,7 +667,7 @@ tr_fdSocketCreate (tr_session * session, int domain, int type)
|
|||
if (gFd->peerCount < session->peerLimit)
|
||||
if ((s = socket (domain, type, 0)) < 0)
|
||||
if (sockerrno != EAFNOSUPPORT)
|
||||
tr_err (_("Couldn't create socket: %s"), tr_strerror (sockerrno));
|
||||
tr_logAddError (_("Couldn't create socket: %s"), tr_strerror (sockerrno));
|
||||
|
||||
if (s > -1)
|
||||
++gFd->peerCount;
|
||||
|
@ -681,9 +683,9 @@ tr_fdSocketCreate (tr_session * session, int domain, int type)
|
|||
socklen_t size = sizeof (int);
|
||||
buf_logged = true;
|
||||
getsockopt (s, SOL_SOCKET, SO_SNDBUF, &i, &size);
|
||||
tr_dbg ("SO_SNDBUF size is %d", i);
|
||||
tr_logAddDebug ("SO_SNDBUF size is %d", i);
|
||||
getsockopt (s, SOL_SOCKET, SO_RCVBUF, &i, &size);
|
||||
tr_dbg ("SO_RCVBUF size is %d", i);
|
||||
tr_logAddDebug ("SO_RCVBUF size is %d", i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "clients.h"
|
||||
#include "crypto.h"
|
||||
#include "handshake.h"
|
||||
#include "log.h"
|
||||
#include "peer-io.h"
|
||||
#include "peer-mgr.h"
|
||||
#include "session.h"
|
||||
|
@ -148,8 +149,8 @@ enum
|
|||
|
||||
#define dbgmsg(handshake, ...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, tr_peerIoGetAddrStr (handshake->io), __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, tr_peerIoGetAddrStr (handshake->io), __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
static const char*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "cache.h" /* tr_cacheReadBlock () */
|
||||
#include "fdlimit.h"
|
||||
#include "inout.h"
|
||||
#include "log.h"
|
||||
#include "peer-common.h" /* MAX_BLOCK_SIZE */
|
||||
#include "stats.h" /* tr_statsFileCreated () */
|
||||
#include "torrent.h"
|
||||
|
@ -99,7 +100,7 @@ readOrWriteBytes (tr_session * session,
|
|||
prealloc, file->length))) < 0)
|
||||
{
|
||||
err = errno;
|
||||
tr_torerr (tor, "tr_fdFileCheckout failed for \"%s\": %s",
|
||||
tr_logAddTorErr (tor, "tr_fdFileCheckout failed for \"%s\": %s",
|
||||
filename, tr_strerror (err));
|
||||
}
|
||||
else if (doWrite)
|
||||
|
@ -126,7 +127,7 @@ readOrWriteBytes (tr_session * session,
|
|||
if (rc < 0)
|
||||
{
|
||||
err = errno;
|
||||
tr_torerr (tor, "read failed for \"%s\": %s", file->name, tr_strerror (err));
|
||||
tr_logAddTorErr (tor, "read failed for \"%s\": %s", file->name, tr_strerror (err));
|
||||
}
|
||||
}
|
||||
else if (ioMode == TR_IO_WRITE)
|
||||
|
@ -135,7 +136,7 @@ readOrWriteBytes (tr_session * session,
|
|||
if (rc < 0)
|
||||
{
|
||||
err = errno;
|
||||
tr_torerr (tor, "write failed for \"%s\": %s", file->name, tr_strerror (err));
|
||||
tr_logAddTorErr (tor, "write failed for \"%s\": %s", file->name, tr_strerror (err));
|
||||
}
|
||||
}
|
||||
else if (ioMode == TR_IO_PREFETCH)
|
||||
|
|
|
@ -228,7 +228,7 @@ libtransmission_test_session_init_session (void)
|
|||
tr_variantDictAddStr (&dict, TR_KEY_download_dir, downloadDir);
|
||||
tr_variantDictAddBool (&dict, TR_KEY_port_forwarding_enabled, false);
|
||||
tr_variantDictAddBool (&dict, TR_KEY_dht_enabled, false);
|
||||
tr_variantDictAddInt (&dict, TR_KEY_message_level, verbose ? TR_MSG_DBG : TR_MSG_ERR);
|
||||
tr_variantDictAddInt (&dict, TR_KEY_message_level, verbose ? TR_LOG_DEBUG : TR_LOG_ERROR);
|
||||
session = tr_sessionInit ("libtransmission-test", sandbox, !verbose, &dict);
|
||||
|
||||
/* cleanup locals*/
|
||||
|
@ -247,7 +247,7 @@ void
|
|||
libtransmission_test_session_close (void)
|
||||
{
|
||||
tr_sessionClose (session);
|
||||
tr_freeMessageList (tr_getQueuedMessages ());
|
||||
tr_logFreeQueue (tr_logGetQueue ());
|
||||
session = NULL;
|
||||
|
||||
rm_rf (sandbox);
|
||||
|
|
|
@ -0,0 +1,291 @@
|
|||
/*
|
||||
* This file Copyright (C) Mnemosyne LLC
|
||||
*
|
||||
* This file is licensed by the GPL version 2. Works owned by the
|
||||
* Transmission project are granted a special exemption to clause 2 (b)
|
||||
* so that the bulk of its code can remain under the MIT license.
|
||||
* This exemption does not extend to derived works not owned by
|
||||
* the Transmission project.
|
||||
*
|
||||
* $Id: utils.c 13863 2013-01-24 23:59:52Z jordan $
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* getenv() */
|
||||
|
||||
#include <event2/buffer.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "log.h"
|
||||
#include "platform.h" /* tr_lock */
|
||||
#include "utils.h"
|
||||
|
||||
tr_log_level __tr_message_level = TR_LOG_ERROR;
|
||||
|
||||
static bool myQueueEnabled = false;
|
||||
static tr_log_message * myQueue = NULL;
|
||||
static tr_log_message ** myQueueTail = &myQueue;
|
||||
static int myQueueLength = 0;
|
||||
|
||||
#ifndef WIN32
|
||||
/* make null versions of these win32 functions */
|
||||
static inline int IsDebuggerPresent (void) { return false; }
|
||||
static inline void OutputDebugString (const void * unused UNUSED) { }
|
||||
#endif
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
tr_log_level
|
||||
tr_logGetLevel (void)
|
||||
{
|
||||
return __tr_message_level;
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
static tr_lock*
|
||||
getMessageLock (void)
|
||||
{
|
||||
static tr_lock * l = NULL;
|
||||
|
||||
if (!l)
|
||||
l = tr_lockNew ();
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
void*
|
||||
tr_logGetFile (void)
|
||||
{
|
||||
static bool initialized = false;
|
||||
static FILE * file = NULL;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
int fd = 0;
|
||||
const char * str = getenv ("TR_DEBUG_FD");
|
||||
|
||||
if (str && *str)
|
||||
fd = atoi (str);
|
||||
|
||||
switch (fd)
|
||||
{
|
||||
case 1:
|
||||
file = stdout;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
file = stderr;
|
||||
break;
|
||||
|
||||
default:
|
||||
file = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
void
|
||||
tr_logSetLevel (tr_log_level level)
|
||||
{
|
||||
__tr_message_level = level;
|
||||
}
|
||||
|
||||
void
|
||||
tr_logSetQueueEnabled (bool isEnabled)
|
||||
{
|
||||
assert (tr_isBool (isEnabled));
|
||||
|
||||
myQueueEnabled = isEnabled;
|
||||
}
|
||||
|
||||
bool
|
||||
tr_logGetQueueEnabled (void)
|
||||
{
|
||||
return myQueueEnabled;
|
||||
}
|
||||
|
||||
tr_log_message *
|
||||
tr_logGetQueue (void)
|
||||
{
|
||||
tr_log_message * ret;
|
||||
tr_lockLock (getMessageLock ());
|
||||
|
||||
ret = myQueue;
|
||||
myQueue = NULL;
|
||||
myQueueTail = &myQueue;
|
||||
myQueueLength = 0;
|
||||
|
||||
tr_lockUnlock (getMessageLock ());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
tr_logFreeQueue (tr_log_message * list)
|
||||
{
|
||||
tr_log_message * next;
|
||||
|
||||
while (NULL != list)
|
||||
{
|
||||
next = list->next;
|
||||
free (list->message);
|
||||
free (list->name);
|
||||
free (list);
|
||||
list = next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
||||
char*
|
||||
tr_logGetTimeStr (char * buf, int buflen)
|
||||
{
|
||||
char tmp[64];
|
||||
struct tm now_tm;
|
||||
struct timeval tv;
|
||||
time_t seconds;
|
||||
int milliseconds;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
|
||||
seconds = tv.tv_sec;
|
||||
tr_localtime_r (&seconds, &now_tm);
|
||||
strftime (tmp, sizeof (tmp), "%H:%M:%S", &now_tm);
|
||||
milliseconds = tv.tv_usec / 1000;
|
||||
tr_snprintf (buf, buflen, "%s.%03d", tmp, milliseconds);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool
|
||||
tr_logGetDeepEnabled (void)
|
||||
{
|
||||
static int8_t deepLoggingIsActive = -1;
|
||||
|
||||
if (deepLoggingIsActive < 0)
|
||||
deepLoggingIsActive = IsDebuggerPresent () || (tr_logGetFile ()!=NULL);
|
||||
|
||||
return deepLoggingIsActive != 0;
|
||||
}
|
||||
|
||||
void
|
||||
tr_logAddDeep (const char * file,
|
||||
int line,
|
||||
const char * name,
|
||||
const char * fmt,
|
||||
...)
|
||||
{
|
||||
FILE * fp = tr_logGetFile ();
|
||||
if (fp || IsDebuggerPresent ())
|
||||
{
|
||||
va_list args;
|
||||
char timestr[64];
|
||||
char * message;
|
||||
struct evbuffer * buf = evbuffer_new ();
|
||||
char * base = tr_basename (file);
|
||||
|
||||
evbuffer_add_printf (buf, "[%s] ",
|
||||
tr_logGetTimeStr (timestr, sizeof (timestr)));
|
||||
if (name)
|
||||
evbuffer_add_printf (buf, "%s ", name);
|
||||
va_start (args, fmt);
|
||||
evbuffer_add_vprintf (buf, fmt, args);
|
||||
va_end (args);
|
||||
evbuffer_add_printf (buf, " (%s:%d)\n", base, line);
|
||||
/* FIXME (libevent2) ifdef this out for nonwindows platforms */
|
||||
message = evbuffer_free_to_str (buf);
|
||||
OutputDebugString (message);
|
||||
if (fp)
|
||||
fputs (message, fp);
|
||||
|
||||
tr_free (message);
|
||||
tr_free (base);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
void
|
||||
tr_logAddMessage (const char * file,
|
||||
int line,
|
||||
tr_log_level level,
|
||||
const char * name,
|
||||
const char * fmt,
|
||||
...)
|
||||
{
|
||||
const int err = errno; /* message logging shouldn't affect errno */
|
||||
char buf[1024];
|
||||
va_list ap;
|
||||
tr_lockLock (getMessageLock ());
|
||||
|
||||
/* build the text message */
|
||||
*buf = '\0';
|
||||
va_start (ap, fmt);
|
||||
evutil_vsnprintf (buf, sizeof (buf), fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
OutputDebugString (buf);
|
||||
|
||||
if (*buf)
|
||||
{
|
||||
if (tr_logGetQueueEnabled ())
|
||||
{
|
||||
tr_log_message * newmsg;
|
||||
newmsg = tr_new0 (tr_log_message, 1);
|
||||
newmsg->level = level;
|
||||
newmsg->when = tr_time ();
|
||||
newmsg->message = tr_strdup (buf);
|
||||
newmsg->file = file;
|
||||
newmsg->line = line;
|
||||
newmsg->name = tr_strdup (name);
|
||||
|
||||
*myQueueTail = newmsg;
|
||||
myQueueTail = &newmsg->next;
|
||||
++myQueueLength;
|
||||
|
||||
if (myQueueLength > TR_LOG_MAX_QUEUE_LENGTH)
|
||||
{
|
||||
tr_log_message * old = myQueue;
|
||||
myQueue = old->next;
|
||||
old->next = NULL;
|
||||
tr_logFreeQueue (old);
|
||||
--myQueueLength;
|
||||
assert (myQueueLength == TR_LOG_MAX_QUEUE_LENGTH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE * fp;
|
||||
char timestr[64];
|
||||
|
||||
fp = tr_logGetFile ();
|
||||
if (fp == NULL)
|
||||
fp = stderr;
|
||||
|
||||
tr_logGetTimeStr (timestr, sizeof (timestr));
|
||||
|
||||
if (name)
|
||||
fprintf (fp, "[%s] %s: %s\n", timestr, name, buf);
|
||||
else
|
||||
fprintf (fp, "[%s] %s\n", timestr, buf);
|
||||
fflush (fp);
|
||||
}
|
||||
}
|
||||
|
||||
tr_lockUnlock (getMessageLock ());
|
||||
errno = err;
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* This file Copyright (C) Mnemosyne LLC
|
||||
*
|
||||
* This file is licensed by the GPL version 2. Works owned by the
|
||||
* Transmission project are granted a special exemption to clause 2 (b)
|
||||
* so that the bulk of its code can remain under the MIT license.
|
||||
* This exemption does not extend to derived works not owned by
|
||||
* the Transmission project.
|
||||
*
|
||||
* $Id:$
|
||||
*/
|
||||
|
||||
#ifndef TR_LOG_H
|
||||
#define TR_LOG_H 1
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
#include "utils.h" /* TR_GNUC_PRINTF, TR_GNUC_NONNULL */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TR_LOG_MAX_QUEUE_LENGTH 10000
|
||||
|
||||
tr_log_level tr_logGetLevel (void);
|
||||
|
||||
static inline bool
|
||||
tr_logLevelIsActive (tr_log_level level)
|
||||
{
|
||||
return tr_logGetLevel () >= level;
|
||||
}
|
||||
|
||||
void tr_logAddMessage (const char * file,
|
||||
int line,
|
||||
tr_log_level level,
|
||||
const char * torrent,
|
||||
const char * fmt, ...) TR_GNUC_PRINTF (5, 6);
|
||||
|
||||
#define tr_logAddNamedError(n, ...) \
|
||||
do\
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_ERROR)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_ERROR, n, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddNamedInfo(n, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_INFO)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_INFO, n, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddNamedDbg(n, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_DEBUG)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_DEBUG, n, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddTorErr(tor, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_ERROR)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_ERROR, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddTorInfo(tor, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_INFO)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_INFO, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddTorDbg(tor, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_DEBUG)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_DEBUG, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddError(...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_ERROR)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_ERROR, NULL, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddInfo(...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_INFO)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_INFO, NULL, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define tr_logAddDebug(...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_logLevelIsActive (TR_LOG_DEBUG)) \
|
||||
tr_logAddMessage (__FILE__, __LINE__, TR_LOG_DEBUG, NULL, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
|
||||
void* tr_logGetFile (void);
|
||||
|
||||
/** @brief return true if deep logging has been enabled by the user; false otherwise */
|
||||
bool tr_logGetDeepEnabled (void);
|
||||
|
||||
void tr_logAddDeep (const char * file,
|
||||
int line,
|
||||
const char * name,
|
||||
const char * fmt,
|
||||
...) TR_GNUC_PRINTF (4, 5) TR_GNUC_NONNULL (1,4);
|
||||
|
||||
/** @brief set the buffer with the current time formatted for deep logging. */
|
||||
char* tr_logGetTimeStr (char * buf, int buflen) TR_GNUC_NONNULL (1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
|
@ -26,6 +26,7 @@
|
|||
#include "transmission.h"
|
||||
#include "crypto.h" /* tr_sha1 */
|
||||
#include "fdlimit.h" /* tr_open_file_for_scanning () */
|
||||
#include "log.h"
|
||||
#include "session.h"
|
||||
#include "makemeta.h"
|
||||
#include "platform.h" /* threads, locks */
|
||||
|
@ -60,7 +61,7 @@ getFiles (const char * dir,
|
|||
i = stat (buf, &sb);
|
||||
if (i)
|
||||
{
|
||||
tr_err (_("Torrent Creator is skipping file \"%s\": %s"),
|
||||
tr_logAddError (_("Torrent Creator is skipping file \"%s\": %s"),
|
||||
buf, tr_strerror (errno));
|
||||
tr_free (buf);
|
||||
return list;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "transmission.h"
|
||||
#include "session.h"
|
||||
#include "crypto.h" /* tr_sha1 */
|
||||
#include "log.h"
|
||||
#include "metainfo.h"
|
||||
#include "platform.h" /* tr_getTorrentDir () */
|
||||
#include "utils.h"
|
||||
|
@ -542,7 +543,7 @@ tr_metainfoParse (const tr_session * session,
|
|||
|
||||
if (badTag)
|
||||
{
|
||||
tr_nerr (inf->name, _("Invalid metadata entry \"%s\""), badTag);
|
||||
tr_logAddNamedError (inf->name, _("Invalid metadata entry \"%s\""), badTag);
|
||||
tr_metainfoFree (inf);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "natpmp_local.h"
|
||||
#include "log.h"
|
||||
#include "net.h" /* tr_netCloseSocket */
|
||||
#include "port-forwarding.h"
|
||||
#include "utils.h"
|
||||
|
@ -69,9 +70,9 @@ logVal (const char * func,
|
|||
if (ret == NATPMP_TRYAGAIN)
|
||||
return;
|
||||
if (ret >= 0)
|
||||
tr_ninf (getKey (), _("%s succeeded (%d)"), func, ret);
|
||||
tr_logAddNamedInfo (getKey (), _("%s succeeded (%d)"), func, ret);
|
||||
else
|
||||
tr_ndbg (
|
||||
tr_logAddNamedDbg (
|
||||
getKey (),
|
||||
"%s failed. Natpmp returned %d (%s); errno is %d (%s)",
|
||||
func, ret, strnatpmperr (ret), errno, tr_strerror (errno));
|
||||
|
@ -138,7 +139,7 @@ tr_natpmpPulse (struct tr_natpmp * nat, tr_port private_port, bool is_enabled, t
|
|||
{
|
||||
char str[128];
|
||||
evutil_inet_ntop (AF_INET, &response.pnu.publicaddress.addr, str, sizeof (str));
|
||||
tr_ninf (getKey (), _("Found public address \"%s\""), str);
|
||||
tr_logAddNamedInfo (getKey (), _("Found public address \"%s\""), str);
|
||||
nat->state = TR_NATPMP_IDLE;
|
||||
}
|
||||
else if (val != NATPMP_TRYAGAIN)
|
||||
|
@ -173,7 +174,7 @@ tr_natpmpPulse (struct tr_natpmp * nat, tr_port private_port, bool is_enabled, t
|
|||
{
|
||||
const int private_port = resp.pnu.newportmapping.privateport;
|
||||
|
||||
tr_ninf (getKey (), _("no longer forwarding port %d"), private_port);
|
||||
tr_logAddNamedInfo (getKey (), _("no longer forwarding port %d"), private_port);
|
||||
|
||||
if (nat->private_port == private_port)
|
||||
{
|
||||
|
@ -218,7 +219,7 @@ tr_natpmpPulse (struct tr_natpmp * nat, tr_port private_port, bool is_enabled, t
|
|||
nat->renew_time = tr_time () + (resp.pnu.newportmapping.lifetime / 2);
|
||||
nat->private_port = resp.pnu.newportmapping.privateport;
|
||||
nat->public_port = resp.pnu.newportmapping.mappedpublicport;
|
||||
tr_ninf (getKey (), _("Port %d forwarded successfully"), nat->private_port);
|
||||
tr_logAddNamedInfo (getKey (), _("Port %d forwarded successfully"), nat->private_port);
|
||||
}
|
||||
else if (val != NATPMP_TRYAGAIN)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
#include "peer-io.h" /* tr_peerIoAddrStr () FIXME this should be moved to net.h */
|
||||
#include "session.h" /* tr_sessionGetPublicAddress () */
|
||||
#include "tr-utp.h" /* tr_utpSendTo () */
|
||||
#include "utils.h" /* tr_time (), tr_dbg () */
|
||||
#include "log.h"
|
||||
#include "utils.h" /* tr_time (), tr_logAddDebug () */
|
||||
|
||||
#ifndef IN_MULTICAST
|
||||
#define IN_MULTICAST(a) (((a) & 0xf0000000) == 0xe0000000)
|
||||
|
@ -249,7 +250,7 @@ tr_netOpenPeerSocket (tr_session * session,
|
|||
if (clientIsSeed) {
|
||||
int n = 8192;
|
||||
if (setsockopt (s, SOL_SOCKET, SO_RCVBUF, &n, sizeof (n)))
|
||||
tr_inf ("Unable to set SO_RCVBUF on socket %d: %s", s, tr_strerror (sockerrno));
|
||||
tr_logAddInfo ("Unable to set SO_RCVBUF on socket %d: %s", s, tr_strerror (sockerrno));
|
||||
}
|
||||
|
||||
if (evutil_make_socket_nonblocking (s) < 0) {
|
||||
|
@ -265,7 +266,7 @@ tr_netOpenPeerSocket (tr_session * session,
|
|||
sourcelen = setup_sockaddr (source_addr, 0, &source_sock);
|
||||
if (bind (s, (struct sockaddr *) &source_sock, sourcelen))
|
||||
{
|
||||
tr_err (_("Couldn't set source address %s on %d: %s"),
|
||||
tr_logAddError (_("Couldn't set source address %s on %d: %s"),
|
||||
tr_address_to_string (source_addr), s, tr_strerror (errno));
|
||||
return -errno;
|
||||
}
|
||||
|
@ -281,15 +282,15 @@ tr_netOpenPeerSocket (tr_session * session,
|
|||
tmperrno = sockerrno;
|
||||
if ((tmperrno != ENETUNREACH && tmperrno != EHOSTUNREACH)
|
||||
|| addr->type == TR_AF_INET)
|
||||
tr_err (_("Couldn't connect socket %d to %s, port %d (errno %d - %s)"),
|
||||
tr_logAddError (_("Couldn't connect socket %d to %s, port %d (errno %d - %s)"),
|
||||
s, tr_address_to_string (addr), (int)ntohs (port), tmperrno,
|
||||
tr_strerror (tmperrno));
|
||||
tr_netClose (session, s);
|
||||
s = -tmperrno;
|
||||
}
|
||||
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, "New OUTGOING connection %d (%s)",
|
||||
s, tr_peerIoAddrStr (addr, port));
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, "New OUTGOING connection %d (%s)",
|
||||
s, tr_peerIoAddrStr (addr, port));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -366,7 +367,7 @@ tr_netBindTCPImpl (const tr_address * addr, tr_port port, bool suppressMsgs, int
|
|||
else
|
||||
fmt = _("Couldn't bind port %d on %s: %s (%s)");
|
||||
|
||||
tr_err (fmt, port, tr_address_to_string (addr), tr_strerror (err), hint);
|
||||
tr_logAddError (fmt, port, tr_address_to_string (addr), tr_strerror (err), hint);
|
||||
}
|
||||
tr_netCloseSocket (fd);
|
||||
*errOut = err;
|
||||
|
@ -374,7 +375,7 @@ tr_netBindTCPImpl (const tr_address * addr, tr_port port, bool suppressMsgs, int
|
|||
}
|
||||
|
||||
if (!suppressMsgs)
|
||||
tr_dbg ("Bound socket %d to port %d on %s", fd, port, tr_address_to_string (addr));
|
||||
tr_logAddDebug ("Bound socket %d to port %d on %s", fd, port, tr_address_to_string (addr));
|
||||
|
||||
if (listen (fd, 128) == -1) {
|
||||
*errOut = sockerrno;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "session.h"
|
||||
#include "bandwidth.h"
|
||||
#include "crypto.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "peer-common.h" /* MAX_BLOCK_SIZE */
|
||||
#include "peer-io.h"
|
||||
|
@ -72,10 +73,12 @@ guessPacketOverhead (size_t d)
|
|||
**/
|
||||
|
||||
#define dbgmsg(io, ...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, tr_peerIoGetAddrStr (io), __VA_ARGS__); \
|
||||
} while (0)
|
||||
do \
|
||||
{ \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, tr_peerIoGetAddrStr (io), __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/**
|
||||
***
|
||||
|
@ -397,7 +400,7 @@ maybeSetCongestionAlgorithm (int socket, const char * algorithm)
|
|||
const int rc = tr_netSetCongestionControl (socket, algorithm);
|
||||
|
||||
if (rc < 0)
|
||||
tr_ninf ("Net", "Can't set congestion control algorithm '%s': %s",
|
||||
tr_logAddNamedInfo ("Net", "Can't set congestion control algorithm '%s': %s",
|
||||
algorithm, tr_strerror (errno));
|
||||
}
|
||||
}
|
||||
|
@ -416,7 +419,7 @@ utp_on_read (void *closure, const unsigned char *buf, size_t buflen)
|
|||
dbgmsg (io, "utp_on_read got %zu bytes", buflen);
|
||||
|
||||
if (rc < 0) {
|
||||
tr_nerr ("UTP", "On read evbuffer_add");
|
||||
tr_logAddNamedError ("UTP", "On read evbuffer_add");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -435,7 +438,7 @@ utp_on_write (void *closure, unsigned char *buf, size_t buflen)
|
|||
dbgmsg (io, "utp_on_write sending %zu bytes... evbuffer_remove returned %d", buflen, rc);
|
||||
assert (rc == (int)buflen); /* if this fails, we've corrupted our bookkeeping somewhere */
|
||||
if (rc < (long)buflen) {
|
||||
tr_nerr ("UTP", "Short write: %d < %ld", rc, (long)buflen);
|
||||
tr_logAddNamedError ("UTP", "Short write: %d < %ld", rc, (long)buflen);
|
||||
}
|
||||
|
||||
didWriteWrapper (io, buflen);
|
||||
|
@ -484,10 +487,10 @@ utp_on_state_change (void *closure, int state)
|
|||
if (io->gotError)
|
||||
io->gotError (io, BEV_EVENT_EOF, io->userData);
|
||||
} else if (state == UTP_STATE_DESTROYING) {
|
||||
tr_nerr ("UTP", "Impossible state UTP_STATE_DESTROYING");
|
||||
tr_logAddNamedError ("UTP", "Impossible state UTP_STATE_DESTROYING");
|
||||
return;
|
||||
} else {
|
||||
tr_nerr ("UTP", "Unknown state %d", state);
|
||||
tr_logAddNamedError ("UTP", "Unknown state %d", state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,7 +538,7 @@ static void
|
|||
dummy_read (void * closure UNUSED, const unsigned char *buf UNUSED, size_t buflen UNUSED)
|
||||
{
|
||||
/* This cannot happen, as far as I'm aware. */
|
||||
tr_nerr ("UTP", "On_read called on closed socket");
|
||||
tr_logAddNamedError ("UTP", "On_read called on closed socket");
|
||||
|
||||
}
|
||||
|
||||
|
@ -544,7 +547,7 @@ dummy_write (void * closure UNUSED, unsigned char *buf, size_t buflen)
|
|||
{
|
||||
/* This can very well happen if we've shut down a peer connection that
|
||||
had unflushed buffers. Complain and send zeroes. */
|
||||
tr_ndbg ("UTP", "On_write called on closed socket");
|
||||
tr_logAddNamedDbg ("UTP", "On_write called on closed socket");
|
||||
memset (buf, 0, buflen);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "completion.h"
|
||||
#include "crypto.h"
|
||||
#include "handshake.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "peer-io.h"
|
||||
#include "peer-mgr.h"
|
||||
|
@ -237,16 +238,16 @@ struct tr_peerMgr
|
|||
#define tordbg(t, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, tr_torrentName (t->tor), __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, tr_torrentName (t->tor), __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define dbgmsg(...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
@ -1805,7 +1806,7 @@ peerCallbackFunc (tr_peer * peer, const tr_peer_event * e, void * vt)
|
|||
|
||||
if (!ok)
|
||||
{
|
||||
tr_torerr (tor, _("Piece %lu, which was just downloaded, failed its checksum test"),
|
||||
tr_logAddTorErr (tor, _("Piece %lu, which was just downloaded, failed its checksum test"),
|
||||
(unsigned long)p);
|
||||
}
|
||||
|
||||
|
@ -2091,7 +2092,7 @@ tr_peerMgrAddIncoming (tr_peerMgr * manager,
|
|||
|
||||
if (tr_sessionIsAddressBlocked (session, addr))
|
||||
{
|
||||
tr_dbg ("Banned IP address \"%s\" tried to connect to us", tr_address_to_string (addr));
|
||||
tr_logAddDebug ("Banned IP address \"%s\" tried to connect to us", tr_address_to_string (addr));
|
||||
if (socket >= 0)
|
||||
tr_netClose (session, socket);
|
||||
else
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "cache.h"
|
||||
#include "completion.h"
|
||||
#include "crypto.h" /* tr_sha1 () */
|
||||
#include "log.h"
|
||||
#include "peer-io.h"
|
||||
#include "peer-mgr.h"
|
||||
#include "peer-msgs.h"
|
||||
|
@ -234,7 +235,7 @@ myDebug (const char * file, int line,
|
|||
const struct tr_peermsgs * msgs,
|
||||
const char * fmt, ...)
|
||||
{
|
||||
FILE * fp = tr_getLog ();
|
||||
FILE * fp = tr_logGetFile ();
|
||||
|
||||
if (fp)
|
||||
{
|
||||
|
@ -245,7 +246,7 @@ myDebug (const char * file, int line,
|
|||
char * message;
|
||||
|
||||
evbuffer_add_printf (buf, "[%s] %s - %s [%s]: ",
|
||||
tr_getLogTimeStr (timestr, sizeof (timestr)),
|
||||
tr_logGetTimeStr (timestr, sizeof (timestr)),
|
||||
tr_torrentName (msgs->torrent),
|
||||
tr_peerIoGetAddrStr (msgs->peer->io),
|
||||
tr_quark_get_string (msgs->peer->client, NULL));
|
||||
|
@ -265,7 +266,7 @@ myDebug (const char * file, int line,
|
|||
#define dbgmsg(msgs, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
myDebug (__FILE__, __LINE__, msgs, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include "transmission.h"
|
||||
#include "session.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "platform.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
@ -378,7 +379,7 @@ moveFiles (const char * oldDir, const char * newDir)
|
|||
}
|
||||
|
||||
if (count)
|
||||
tr_inf (_("Migrated %1$d files from \"%2$s\" to \"%3$s\""), count, oldDir, newDir);
|
||||
tr_logAddInfo (_("Migrated %1$d files from \"%2$s\" to \"%3$s\""), count, oldDir, newDir);
|
||||
|
||||
closedir (dirh);
|
||||
}
|
||||
|
@ -555,7 +556,7 @@ isWebClientDir (const char * path)
|
|||
struct stat sb;
|
||||
char * tmp = tr_buildPath (path, "index.html", NULL);
|
||||
const int ret = !stat (tmp, &sb);
|
||||
tr_inf (_("Searching for web interface file \"%s\""), tmp);
|
||||
tr_logAddInfo (_("Searching for web interface file \"%s\""), tmp);
|
||||
tr_free (tmp);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "natpmp_local.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "peer-mgr.h"
|
||||
#include "port-forwarding.h"
|
||||
|
@ -89,7 +90,7 @@ natPulse (tr_shared * s, bool do_check)
|
|||
newStatus = tr_sharedTraversalStatus (s);
|
||||
|
||||
if (newStatus != oldStatus)
|
||||
tr_ninf (getKey (), _("State changed from \"%1$s\" to \"%2$s\""),
|
||||
tr_logAddNamedInfo (getKey (), _("State changed from \"%1$s\" to \"%2$s\""),
|
||||
getNatStateStr (oldStatus),
|
||||
getNatStateStr (newStatus));
|
||||
}
|
||||
|
@ -179,7 +180,7 @@ stop_timer (tr_shared * s)
|
|||
static void
|
||||
stop_forwarding (tr_shared * s)
|
||||
{
|
||||
tr_ninf (getKey (), "%s", _("Stopped"));
|
||||
tr_logAddNamedInfo (getKey (), "%s", _("Stopped"));
|
||||
natPulse (s, false);
|
||||
|
||||
tr_natpmpClose (s->natpmp);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "completion.h"
|
||||
#include "log.h"
|
||||
#include "metainfo.h" /* tr_metainfoGetBasename () */
|
||||
#include "peer-mgr.h" /* pex */
|
||||
#include "platform.h" /* tr_getResumeDir () */
|
||||
|
@ -94,14 +95,14 @@ loadPeers (tr_variant * dict, tr_torrent * tor)
|
|||
if (tr_variantDictFindRaw (dict, TR_KEY_peers, &str, &len))
|
||||
{
|
||||
const int numAdded = addPeers (tor, str, len);
|
||||
tr_tordbg (tor, "Loaded %d IPv4 peers from resume file", numAdded);
|
||||
tr_logAddTorDbg (tor, "Loaded %d IPv4 peers from resume file", numAdded);
|
||||
ret = TR_FR_PEERS;
|
||||
}
|
||||
|
||||
if (tr_variantDictFindRaw (dict, TR_KEY_peers6, &str, &len))
|
||||
{
|
||||
const int numAdded = addPeers (tor, str, len);
|
||||
tr_tordbg (tor, "Loaded %d IPv6 peers from resume file", numAdded);
|
||||
tr_logAddTorDbg (tor, "Loaded %d IPv6 peers from resume file", numAdded);
|
||||
ret = TR_FR_PEERS;
|
||||
}
|
||||
|
||||
|
@ -151,13 +152,13 @@ loadDND (tr_variant * dict, tr_torrent * tor)
|
|||
if (dndCount)
|
||||
{
|
||||
tr_torrentInitFileDLs (tor, dnd, dndCount, false);
|
||||
tr_tordbg (tor, "Resume file found %d files listed as dnd",
|
||||
tr_logAddTorDbg (tor, "Resume file found %d files listed as dnd",
|
||||
dndCount);
|
||||
}
|
||||
if (dlCount)
|
||||
{
|
||||
tr_torrentInitFileDLs (tor, dl, dlCount, true);
|
||||
tr_tordbg (tor,
|
||||
tr_logAddTorDbg (tor,
|
||||
"Resume file found %d files marked for download",
|
||||
dlCount);
|
||||
}
|
||||
|
@ -168,7 +169,7 @@ loadDND (tr_variant * dict, tr_torrent * tor)
|
|||
}
|
||||
else
|
||||
{
|
||||
tr_tordbg (
|
||||
tr_logAddTorDbg (
|
||||
tor,
|
||||
"Couldn't load DND flags. DND list (%p) has %zu children; torrent has %d files",
|
||||
list, tr_variantListSize (list), (int)n);
|
||||
|
@ -629,7 +630,7 @@ loadProgress (tr_variant * dict, tr_torrent * tor)
|
|||
else err = "Couldn't find 'pieces' or 'have' or 'bitfield'";
|
||||
|
||||
if (err != NULL)
|
||||
tr_tordbg (tor, "Torrent needs to be verified - %s", err);
|
||||
tr_logAddTorDbg (tor, "Torrent needs to be verified - %s", err);
|
||||
else
|
||||
tr_cpBlockInit (&tor->completion, &blocks);
|
||||
|
||||
|
@ -708,13 +709,13 @@ loadFromFile (tr_torrent * tor, uint64_t fieldsToLoad)
|
|||
|
||||
if (tr_variantFromFile (&top, TR_VARIANT_FMT_BENC, filename))
|
||||
{
|
||||
tr_tordbg (tor, "Couldn't read \"%s\"", filename);
|
||||
tr_logAddTorDbg (tor, "Couldn't read \"%s\"", filename);
|
||||
|
||||
tr_free (filename);
|
||||
return fieldsLoaded;
|
||||
}
|
||||
|
||||
tr_tordbg (tor, "Read resume file \"%s\"", filename);
|
||||
tr_logAddTorDbg (tor, "Read resume file \"%s\"", filename);
|
||||
|
||||
if ((fieldsToLoad & TR_FR_CORRUPT)
|
||||
&& tr_variantDictFindInt (&top, TR_KEY_corrupt, &i))
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "crypto.h" /* tr_cryptoRandBuf (), tr_ssha1_matches () */
|
||||
#include "fdlimit.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "platform.h" /* tr_getWebClientDir () */
|
||||
#include "ptrarray.h"
|
||||
|
@ -78,8 +79,8 @@ struct tr_rpc_server
|
|||
|
||||
#define dbgmsg(...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
@ -798,9 +799,9 @@ tr_rpcSetWhitelist (tr_rpc_server * server, const char * whitelistStr)
|
|||
char * token = tr_strndup (walk, len);
|
||||
tr_list_append (&server->whitelist, token);
|
||||
if (strcspn (token, "+-") < len)
|
||||
tr_ninf (MY_NAME, "Adding address to whitelist: %s (And it has a '+' or '-'! Are you using an old ACL by mistake?)", token);
|
||||
tr_logAddNamedInfo (MY_NAME, "Adding address to whitelist: %s (And it has a '+' or '-'! Are you using an old ACL by mistake?)", token);
|
||||
else
|
||||
tr_ninf (MY_NAME, "Adding address to whitelist: %s", token);
|
||||
tr_logAddNamedInfo (MY_NAME, "Adding address to whitelist: %s", token);
|
||||
|
||||
if (walk[len]=='\0')
|
||||
break;
|
||||
|
@ -922,7 +923,7 @@ static void
|
|||
missing_settings_key (const tr_quark q)
|
||||
{
|
||||
const char * str = tr_quark_get_string (q, NULL);
|
||||
tr_nerr (MY_NAME, _("Couldn't find settings key \"%s\""), str);
|
||||
tr_logAddNamedError (MY_NAME, _("Couldn't find settings key \"%s\""), str);
|
||||
}
|
||||
|
||||
tr_rpc_server *
|
||||
|
@ -991,24 +992,24 @@ tr_rpcInit (tr_session * session, tr_variant * settings)
|
|||
missing_settings_key (key);
|
||||
address = tr_inaddr_any;
|
||||
} else if (!tr_address_from_string (&address, str)) {
|
||||
tr_nerr (MY_NAME, _("%s is not a valid address"), str);
|
||||
tr_logAddNamedError (MY_NAME, _("%s is not a valid address"), str);
|
||||
address = tr_inaddr_any;
|
||||
} else if (address.type != TR_AF_INET) {
|
||||
tr_nerr (MY_NAME, _("%s is not an IPv4 address. RPC listeners must be IPv4"), str);
|
||||
tr_logAddNamedError (MY_NAME, _("%s is not an IPv4 address. RPC listeners must be IPv4"), str);
|
||||
address = tr_inaddr_any;
|
||||
}
|
||||
s->bindAddress = address.addr.addr4;
|
||||
|
||||
if (s->isEnabled)
|
||||
{
|
||||
tr_ninf (MY_NAME, _("Serving RPC and Web requests on port 127.0.0.1:%d%s"), (int) s->port, s->url);
|
||||
tr_logAddNamedInfo (MY_NAME, _("Serving RPC and Web requests on port 127.0.0.1:%d%s"), (int) s->port, s->url);
|
||||
tr_runInEventThread (session, startServer, s);
|
||||
|
||||
if (s->isWhitelistEnabled)
|
||||
tr_ninf (MY_NAME, "%s", _("Whitelist enabled"));
|
||||
tr_logAddNamedInfo (MY_NAME, "%s", _("Whitelist enabled"));
|
||||
|
||||
if (s->isPasswordEnabled)
|
||||
tr_ninf (MY_NAME, "%s", _("Password required"));
|
||||
tr_logAddNamedInfo (MY_NAME, "%s", _("Password required"));
|
||||
}
|
||||
|
||||
return s;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "transmission.h"
|
||||
#include "completion.h"
|
||||
#include "fdlimit.h"
|
||||
#include "log.h"
|
||||
#include "rpcimpl.h"
|
||||
#include "session.h"
|
||||
#include "torrent.h"
|
||||
|
@ -49,10 +50,12 @@
|
|||
} while (0)
|
||||
#else
|
||||
#define dbgmsg(...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, "RPC", __VA_ARGS__); \
|
||||
} while (0)
|
||||
do \
|
||||
{ \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, "RPC", __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1479,7 +1482,7 @@ gotNewBlocklist (tr_session * session,
|
|||
tr_snprintf (result, sizeof (result), _("Couldn't save file \"%1$s\": %2$s"), filename, tr_strerror (errno));
|
||||
|
||||
if (*result)
|
||||
tr_err ("%s", result);
|
||||
tr_logAddError ("%s", result);
|
||||
else {
|
||||
/* feed it to the session and give the client a response */
|
||||
const int rule_count = tr_blocklistSetContent (session, filename);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "crypto.h"
|
||||
#include "fdlimit.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "peer-io.h"
|
||||
#include "peer-mgr.h"
|
||||
|
@ -71,8 +72,8 @@ enum
|
|||
#define dbgmsg(...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
@ -185,8 +186,8 @@ accept_incoming_peer (int fd, short what UNUSED, void * vsession)
|
|||
|
||||
clientSocket = tr_netAccept (session, fd, &clientAddr, &clientPort);
|
||||
if (clientSocket > 0) {
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, "new incoming connection %d (%s)",
|
||||
clientSocket, tr_peerIoAddrStr (&clientAddr, clientPort));
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, "new incoming connection %d (%s)",
|
||||
clientSocket, tr_peerIoAddrStr (&clientAddr, clientPort));
|
||||
tr_peerMgrAddIncoming (session->peerMgr, &clientAddr, clientPort,
|
||||
clientSocket, NULL);
|
||||
}
|
||||
|
@ -322,7 +323,7 @@ tr_sessionGetDefaultSettings (tr_variant * d)
|
|||
tr_variantDictAddBool (d, TR_KEY_idle_seeding_limit_enabled, false);
|
||||
tr_variantDictAddStr (d, TR_KEY_incomplete_dir, tr_getDefaultDownloadDir ());
|
||||
tr_variantDictAddBool (d, TR_KEY_incomplete_dir_enabled, false);
|
||||
tr_variantDictAddInt (d, TR_KEY_message_level, TR_MSG_INF);
|
||||
tr_variantDictAddInt (d, TR_KEY_message_level, TR_LOG_INFO);
|
||||
tr_variantDictAddInt (d, TR_KEY_download_queue_size, 5);
|
||||
tr_variantDictAddBool (d, TR_KEY_download_queue_enabled, true);
|
||||
tr_variantDictAddInt (d, TR_KEY_peer_limit_global, atoi (TR_DEFAULT_PEER_LIMIT_GLOBAL_STR));
|
||||
|
@ -394,7 +395,7 @@ tr_sessionGetSettings (tr_session * s, tr_variant * d)
|
|||
tr_variantDictAddBool (d, TR_KEY_idle_seeding_limit_enabled, tr_sessionIsIdleLimited (s));
|
||||
tr_variantDictAddStr (d, TR_KEY_incomplete_dir, tr_sessionGetIncompleteDir (s));
|
||||
tr_variantDictAddBool (d, TR_KEY_incomplete_dir_enabled, tr_sessionIsIncompleteDirEnabled (s));
|
||||
tr_variantDictAddInt (d, TR_KEY_message_level, tr_getMessageLevel ());
|
||||
tr_variantDictAddInt (d, TR_KEY_message_level, tr_logGetLevel ());
|
||||
tr_variantDictAddInt (d, TR_KEY_peer_limit_global, s->peerLimit);
|
||||
tr_variantDictAddInt (d, TR_KEY_peer_limit_per_torrent, s->peerLimitPerTorrent);
|
||||
tr_variantDictAddInt (d, TR_KEY_peer_port, tr_sessionGetPeerPort (s));
|
||||
|
@ -543,7 +544,7 @@ onSaveTimer (int foo UNUSED, short bar UNUSED, void * vsession)
|
|||
tr_session * session = vsession;
|
||||
|
||||
if (tr_cacheFlushDone (session->cache))
|
||||
tr_err ("Error while flushing completed pieces from cache");
|
||||
tr_logAddError ("Error while flushing completed pieces from cache");
|
||||
|
||||
while ((tor = tr_torrentNext (session, tor)))
|
||||
tr_torrentSave (tor);
|
||||
|
@ -596,7 +597,7 @@ tr_sessionInit (const char * tag,
|
|||
|
||||
/* nice to start logging at the very beginning */
|
||||
if (tr_variantDictFindInt (clientSettings, TR_KEY_message_level, &i))
|
||||
tr_setMessageLevel (i);
|
||||
tr_logSetLevel (i);
|
||||
|
||||
/* start the libtransmission thread */
|
||||
tr_netInit (); /* must go before tr_eventInit */
|
||||
|
@ -694,7 +695,7 @@ tr_sessionInitImpl (void * vdata)
|
|||
signal (SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
tr_setMessageQueuing (data->messageQueuingEnabled);
|
||||
tr_logSetQueueEnabled (data->messageQueuingEnabled);
|
||||
|
||||
tr_setConfigDir (session, data->configDir);
|
||||
|
||||
|
@ -722,7 +723,7 @@ tr_sessionInitImpl (void * vdata)
|
|||
|
||||
/* first %s is the application name
|
||||
second %s is the version number */
|
||||
tr_inf (_("%s %s started"), TR_NAME, LONG_VERSION_STRING);
|
||||
tr_logAddInfo (_("%s %s started"), TR_NAME, LONG_VERSION_STRING);
|
||||
|
||||
tr_statsInit (session);
|
||||
|
||||
|
@ -763,7 +764,7 @@ sessionSetImpl (void * vdata)
|
|||
assert (tr_amInEventThread (session));
|
||||
|
||||
if (tr_variantDictFindInt (settings, TR_KEY_message_level, &i))
|
||||
tr_setMessageLevel (i);
|
||||
tr_logSetLevel (i);
|
||||
|
||||
if (tr_variantDictFindInt (settings, TR_KEY_umask, &i)) {
|
||||
session->umask = (mode_t)i;
|
||||
|
@ -1371,7 +1372,7 @@ turtleCheckClock (tr_session * s, struct tr_turtle_info * t)
|
|||
|
||||
if (!alreadySwitched)
|
||||
{
|
||||
tr_inf ("Time to turn %s turtle mode!", (enabled?"on":"off"));
|
||||
tr_logAddInfo ("Time to turn %s turtle mode!", (enabled?"on":"off"));
|
||||
t->autoTurtleState = newAutoTurtleState;
|
||||
useAltSpeed (s, t, enabled, false);
|
||||
}
|
||||
|
@ -1493,7 +1494,7 @@ tr_sessionGetAltSpeed_KBps (const tr_session * s, tr_direction d)
|
|||
static void
|
||||
userPokedTheClock (tr_session * s, struct tr_turtle_info * t)
|
||||
{
|
||||
tr_dbg ("Refreshing the turtle mode clock due to user changes");
|
||||
tr_logAddDebug ("Refreshing the turtle mode clock due to user changes");
|
||||
|
||||
t->autoTurtleState = TR_AUTO_SWITCH_UNUSED;
|
||||
|
||||
|
@ -1947,7 +1948,7 @@ sessionLoadTorrents (void * vdata)
|
|||
tr_list_free (&list, NULL);
|
||||
|
||||
if (n)
|
||||
tr_inf (_("Loaded %d torrents"), n);
|
||||
tr_logAddInfo (_("Loaded %d torrents"), n);
|
||||
|
||||
if (data->setmeCount)
|
||||
*data->setmeCount = n;
|
||||
|
@ -2443,7 +2444,7 @@ metainfoLookupInit (tr_session * session)
|
|||
tr_ctorFree (ctor);
|
||||
|
||||
session->metainfoLookup = lookup;
|
||||
tr_dbg ("Found %d torrents in \"%s\"", n, dirname);
|
||||
tr_logAddDebug ("Found %d torrents in \"%s\"", n, dirname);
|
||||
}
|
||||
|
||||
const char*
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "session.h"
|
||||
#include "log.h"
|
||||
#include "platform.h" /* tr_sessionGetConfigDir () */
|
||||
#include "stats.h"
|
||||
#include "utils.h" /* tr_buildPath */
|
||||
|
@ -95,7 +96,7 @@ saveCumulativeStats (const tr_session * session, const tr_session_stats * s)
|
|||
tr_variantDictAddInt (&top, TR_KEY_uploaded_bytes, s->uploadedBytes);
|
||||
|
||||
filename = getFilename (session);
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, "Saving stats to \"%s\"", filename);
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, "Saving stats to \"%s\"", filename);
|
||||
tr_variantToFile (&top, TR_VARIANT_FMT_JSON, filename);
|
||||
|
||||
tr_free (filename);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "transmission.h"
|
||||
#include "crypto.h" /* tr_sha1 () */
|
||||
#include "log.h"
|
||||
#include "magnet.h"
|
||||
#include "metainfo.h"
|
||||
#include "resume.h"
|
||||
|
@ -30,8 +31,8 @@
|
|||
#define dbgmsg(tor, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
@ -314,7 +315,7 @@ tr_torrentSetMetadataPiece (tr_torrent * tor, int piece, const void * data, in
|
|||
m->piecesNeededCount = n;
|
||||
dbgmsg (tor, "metadata error; trying again. %d pieces left", n);
|
||||
|
||||
tr_err ("magnet status: checksum passed %d, metainfo parsed %d",
|
||||
tr_logAddError ("magnet status: checksum passed %d, metainfo parsed %d",
|
||||
(int)checksumPassed, (int)metainfoParsed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "resume.h"
|
||||
#include "fdlimit.h" /* tr_fdTorrentClose */
|
||||
#include "inout.h" /* tr_ioTestPiece () */
|
||||
#include "log.h"
|
||||
#include "magnet.h"
|
||||
#include "metainfo.h"
|
||||
#include "peer-common.h" /* MAX_BLOCK_SIZE */
|
||||
|
@ -62,8 +63,8 @@
|
|||
#define tr_deeplog_tor(tor, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
@ -455,7 +456,7 @@ tr_torrentCheckSeedLimit (tr_torrent * tor)
|
|||
/* if we're seeding and reach our seed ratio limit, stop the torrent */
|
||||
if (tr_torrentIsSeedRatioDone (tor))
|
||||
{
|
||||
tr_torinf (tor, "%s", "Seed ratio reached; pausing torrent");
|
||||
tr_logAddTorInfo (tor, "%s", "Seed ratio reached; pausing torrent");
|
||||
|
||||
tor->isStopping = true;
|
||||
|
||||
|
@ -466,7 +467,7 @@ tr_torrentCheckSeedLimit (tr_torrent * tor)
|
|||
/* if we're seeding and reach our inactiviy limit, stop the torrent */
|
||||
else if (tr_torrentIsSeedIdleLimitDone (tor))
|
||||
{
|
||||
tr_torinf (tor, "%s", "Seeding idle limit reached; pausing torrent");
|
||||
tr_logAddTorInfo (tor, "%s", "Seeding idle limit reached; pausing torrent");
|
||||
|
||||
tor->isStopping = true;
|
||||
tor->finishedSeedingByIdle = true;
|
||||
|
@ -494,7 +495,7 @@ tr_torrentSetLocalError (tr_torrent * tor, const char * fmt, ...)
|
|||
evutil_vsnprintf (tor->errorString, sizeof (tor->errorString), fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
tr_torerr (tor, "%s", tor->errorString);
|
||||
tr_logAddTorErr (tor, "%s", tor->errorString);
|
||||
|
||||
if (tor->isRunning)
|
||||
tor->isStopping = true;
|
||||
|
@ -520,9 +521,9 @@ onTrackerResponse (tr_torrent * tor, const tr_tracker_event * event, void * unus
|
|||
const bool allAreSeeds = seedProbability == 100;
|
||||
|
||||
if (allAreSeeds)
|
||||
tr_tordbg (tor, "Got %zu seeds from tracker", event->pexCount);
|
||||
tr_logAddTorDbg (tor, "Got %zu seeds from tracker", event->pexCount);
|
||||
else
|
||||
tr_tordbg (tor, "Got %zu peers from tracker", event->pexCount);
|
||||
tr_logAddTorDbg (tor, "Got %zu peers from tracker", event->pexCount);
|
||||
|
||||
for (i = 0; i < event->pexCount; ++i)
|
||||
tr_peerMgrAddPex (tor, TR_PEER_FROM_TRACKER, &event->pex[i], seedProbability);
|
||||
|
@ -531,14 +532,14 @@ onTrackerResponse (tr_torrent * tor, const tr_tracker_event * event, void * unus
|
|||
}
|
||||
|
||||
case TR_TRACKER_WARNING:
|
||||
tr_torerr (tor, _("Tracker warning: \"%s\""), event->text);
|
||||
tr_logAddTorErr (tor, _("Tracker warning: \"%s\""), event->text);
|
||||
tor->error = TR_STAT_TRACKER_WARNING;
|
||||
tr_strlcpy (tor->errorTracker, event->tracker, sizeof (tor->errorTracker));
|
||||
tr_strlcpy (tor->errorString, event->text, sizeof (tor->errorString));
|
||||
break;
|
||||
|
||||
case TR_TRACKER_ERROR:
|
||||
tr_torerr (tor, _("Tracker error: \"%s\""), event->text);
|
||||
tr_logAddTorErr (tor, _("Tracker error: \"%s\""), event->text);
|
||||
tor->error = TR_STAT_TRACKER_ERROR;
|
||||
tr_strlcpy (tor->errorTracker, event->tracker, sizeof (tor->errorTracker));
|
||||
tr_strlcpy (tor->errorString, event->text, sizeof (tor->errorString));
|
||||
|
@ -1650,7 +1651,7 @@ torrentStart (tr_torrent * tor, bool bypass_queue)
|
|||
|
||||
/* allow finished torrents to be resumed */
|
||||
if (tr_torrentIsSeedRatioDone (tor)) {
|
||||
tr_torinf (tor, "%s", _("Restarted manually -- disabling its seed ratio"));
|
||||
tr_logAddTorInfo (tor, "%s", _("Restarted manually -- disabling its seed ratio"));
|
||||
tr_torrentSetRatioMode (tor, TR_RATIOLIMIT_UNLIMITED);
|
||||
}
|
||||
|
||||
|
@ -1755,7 +1756,7 @@ static void
|
|||
stopTorrent (void * vtor)
|
||||
{
|
||||
tr_torrent * tor = vtor;
|
||||
tr_torinf (tor, "%s", "Pausing");
|
||||
tr_logAddTorInfo (tor, "%s", "Pausing");
|
||||
|
||||
assert (tr_isTorrent (tor));
|
||||
|
||||
|
@ -1805,7 +1806,7 @@ closeTorrent (void * vtor)
|
|||
tr_variantDictAddInt (d, TR_KEY_id, tor->uniqueId);
|
||||
tr_variantDictAddInt (d, TR_KEY_date, tr_time ());
|
||||
|
||||
tr_torinf (tor, "%s", _("Removing torrent"));
|
||||
tr_logAddTorInfo (tor, "%s", _("Removing torrent"));
|
||||
|
||||
stopTorrent (tor);
|
||||
|
||||
|
@ -1992,11 +1993,11 @@ torrentCallScript (const tr_torrent * tor, const char * script)
|
|||
tr_strdup_printf ("TR_TORRENT_NAME=%s", tr_torrentName (tor)),
|
||||
NULL };
|
||||
|
||||
tr_torinf (tor, "Calling script \"%s\"", script);
|
||||
tr_logAddTorInfo (tor, "Calling script \"%s\"", script);
|
||||
|
||||
#ifdef WIN32
|
||||
if (_spawnvpe (_P_NOWAIT, script, (const char*)cmd, env) == -1)
|
||||
tr_torerr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
|
||||
tr_logAddTorErr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
|
||||
#else
|
||||
signal (SIGCHLD, onSigCHLD);
|
||||
|
||||
|
@ -2006,7 +2007,7 @@ torrentCallScript (const tr_torrent * tor, const char * script)
|
|||
putenv (env[i]);
|
||||
|
||||
if (execvp (script, cmd) == -1)
|
||||
tr_torerr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
|
||||
tr_logAddTorErr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
|
||||
|
||||
_exit (0);
|
||||
}
|
||||
|
@ -2032,7 +2033,7 @@ tr_torrentRecheckCompleteness (tr_torrent * tor)
|
|||
const bool wasRunning = tor->isRunning;
|
||||
|
||||
if (recentChange)
|
||||
tr_torinf (tor, _("State changed from \"%1$s\" to \"%2$s\""),
|
||||
tr_logAddTorInfo (tor, _("State changed from \"%1$s\" to \"%2$s\""),
|
||||
getCompletionString (tor->completeness),
|
||||
getCompletionString (completeness));
|
||||
|
||||
|
@ -2356,7 +2357,7 @@ tr_torrentReqIsValid (const tr_torrent * tor,
|
|||
else if (tr_pieceOffset (tor, index, offset, length) > tor->info.totalSize)
|
||||
err = 5;
|
||||
|
||||
if (err) tr_tordbg (tor, "index %lu offset %lu length %lu err %d\n",
|
||||
if (err) tr_logAddTorDbg (tor, "index %lu offset %lu length %lu err %d\n",
|
||||
(unsigned long)index,
|
||||
(unsigned long)offset,
|
||||
(unsigned long)length,
|
||||
|
@ -2891,7 +2892,7 @@ setLocation (void * vdata)
|
|||
|
||||
assert (tr_isTorrent (tor));
|
||||
|
||||
tr_dbg ("Moving \"%s\" location from currentDir \"%s\" to \"%s\"",
|
||||
tr_logAddDebug ("Moving \"%s\" location from currentDir \"%s\" to \"%s\"",
|
||||
tr_torrentName (tor), tor->currentDir, location);
|
||||
|
||||
tr_mkdirp (location, 0777);
|
||||
|
@ -2916,17 +2917,17 @@ setLocation (void * vdata)
|
|||
char * oldpath = tr_buildPath (oldbase, sub, NULL);
|
||||
char * newpath = tr_buildPath (location, sub, NULL);
|
||||
|
||||
tr_dbg ("Found file #%d: %s", (int)i, oldpath);
|
||||
tr_logAddDebug ("Found file #%d: %s", (int)i, oldpath);
|
||||
|
||||
if (do_move && !tr_is_same_file (oldpath, newpath))
|
||||
{
|
||||
bool renamed = false;
|
||||
errno = 0;
|
||||
tr_torinf (tor, "moving \"%s\" to \"%s\"", oldpath, newpath);
|
||||
tr_logAddTorInfo (tor, "moving \"%s\" to \"%s\"", oldpath, newpath);
|
||||
if (tr_moveFile (oldpath, newpath, &renamed))
|
||||
{
|
||||
err = true;
|
||||
tr_torerr (tor, "error moving \"%s\" to \"%s\": %s",
|
||||
tr_logAddTorErr (tor, "error moving \"%s\" to \"%s\": %s",
|
||||
oldpath, newpath, tr_strerror (errno));
|
||||
}
|
||||
}
|
||||
|
@ -3029,7 +3030,7 @@ tr_torrentFileCompleted (tr_torrent * tor, tr_file_index_t fileNum)
|
|||
char * newpath = tr_buildPath (base, f->name, NULL);
|
||||
|
||||
if (rename (oldpath, newpath))
|
||||
tr_torerr (tor, "Error moving \"%s\" to \"%s\": %s", oldpath, newpath, tr_strerror (errno));
|
||||
tr_logAddTorErr (tor, "Error moving \"%s\" to \"%s\": %s", oldpath, newpath, tr_strerror (errno));
|
||||
|
||||
tr_free (newpath);
|
||||
tr_free (oldpath);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
/* libT */
|
||||
#include "transmission.h"
|
||||
#include "crypto.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "peer-mgr.h" /* tr_peerMgrCompactToPex () */
|
||||
#include "platform.h" /* tr_threadNew () */
|
||||
|
@ -122,7 +123,7 @@ bootstrap_from_name (const char *name, tr_port port, int af)
|
|||
|
||||
rc = getaddrinfo (name, pp, &hints, &info);
|
||||
if (rc != 0) {
|
||||
tr_nerr ("DHT", "%s:%s: %s", name, pp, gai_strerror (rc));
|
||||
tr_logAddNamedError ("DHT", "%s:%s: %s", name, pp, gai_strerror (rc));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -150,10 +151,10 @@ dht_bootstrap (void *closure)
|
|||
return;
|
||||
|
||||
if (cl->len > 0)
|
||||
tr_ninf ("DHT", "Bootstrapping from %d IPv4 nodes", num);
|
||||
tr_logAddNamedInfo ("DHT", "Bootstrapping from %d IPv4 nodes", num);
|
||||
|
||||
if (cl->len6 > 0)
|
||||
tr_ninf ("DHT", "Bootstrapping from %d IPv6 nodes", num6);
|
||||
tr_logAddNamedInfo ("DHT", "Bootstrapping from %d IPv6 nodes", num6);
|
||||
|
||||
|
||||
for (i = 0; i < MAX (num, num6); i++) {
|
||||
|
@ -202,7 +203,7 @@ dht_bootstrap (void *closure)
|
|||
if (bootstrap_file)
|
||||
f = fopen (bootstrap_file, "rb");
|
||||
if (f != NULL) {
|
||||
tr_ninf ("DHT", "Attempting manual bootstrap");
|
||||
tr_logAddNamedInfo ("DHT", "Attempting manual bootstrap");
|
||||
for (;;) {
|
||||
char buf[201];
|
||||
char *p;
|
||||
|
@ -216,7 +217,7 @@ dht_bootstrap (void *closure)
|
|||
if (p != NULL)
|
||||
port = atoi (p + 1);
|
||||
if (p == NULL || port <= 0 || port >= 0x10000) {
|
||||
tr_nerr ("DHT", "Couldn't parse %s", buf);
|
||||
tr_logAddNamedError ("DHT", "Couldn't parse %s", buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -243,7 +244,7 @@ dht_bootstrap (void *closure)
|
|||
if (bootstrap_done (cl->session, 0))
|
||||
break;
|
||||
if (i == 0)
|
||||
tr_ninf ("DHT",
|
||||
tr_logAddNamedInfo ("DHT",
|
||||
"Attempting bootstrap from dht.transmissionbt.com");
|
||||
bootstrap_from_name ("dht.transmissionbt.com", 6881,
|
||||
bootstrap_af (session));
|
||||
|
@ -255,7 +256,7 @@ dht_bootstrap (void *closure)
|
|||
if (cl->nodes6)
|
||||
tr_free (cl->nodes6);
|
||||
tr_free (closure);
|
||||
tr_ndbg ("DHT", "Finished bootstrapping");
|
||||
tr_logAddNamedDbg ("DHT", "Finished bootstrapping");
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -273,7 +274,7 @@ tr_dhtInit (tr_session *ss)
|
|||
if (session) /* already initialized */
|
||||
return -1;
|
||||
|
||||
tr_ndbg ("DHT", "Initializing DHT");
|
||||
tr_logAddNamedDbg ("DHT", "Initializing DHT");
|
||||
|
||||
if (getenv ("TR_DHT_VERBOSE") != NULL)
|
||||
dht_debug = stderr;
|
||||
|
@ -302,11 +303,11 @@ tr_dhtInit (tr_session *ss)
|
|||
len6 = 0;
|
||||
|
||||
if (have_id)
|
||||
tr_ninf ("DHT", "Reusing old id");
|
||||
tr_logAddNamedInfo ("DHT", "Reusing old id");
|
||||
else {
|
||||
/* Note that DHT ids need to be distributed uniformly,
|
||||
* so it should be something truly random. */
|
||||
tr_ninf ("DHT", "Generating new id");
|
||||
tr_logAddNamedInfo ("DHT", "Generating new id");
|
||||
tr_cryptoRandBuf (myid, 20);
|
||||
}
|
||||
|
||||
|
@ -327,12 +328,12 @@ tr_dhtInit (tr_session *ss)
|
|||
dht_timer = evtimer_new (session->event_base, timer_callback, session);
|
||||
tr_timerAdd (dht_timer, 0, tr_cryptoWeakRandInt (1000000));
|
||||
|
||||
tr_ndbg ("DHT", "DHT initialized");
|
||||
tr_logAddNamedDbg ("DHT", "DHT initialized");
|
||||
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
tr_ndbg ("DHT", "DHT initialization failed (errno = %d)", errno);
|
||||
tr_logAddNamedDbg ("DHT", "DHT initialization failed (errno = %d)", errno);
|
||||
session = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
@ -343,7 +344,7 @@ tr_dhtUninit (tr_session *ss)
|
|||
if (session != ss)
|
||||
return;
|
||||
|
||||
tr_ndbg ("DHT", "Uninitializing DHT");
|
||||
tr_logAddNamedDbg ("DHT", "Uninitializing DHT");
|
||||
|
||||
if (dht_timer != NULL) {
|
||||
event_free (dht_timer);
|
||||
|
@ -354,7 +355,7 @@ tr_dhtUninit (tr_session *ss)
|
|||
don't know enough nodes. */
|
||||
if ((tr_dhtStatus (ss, AF_INET, NULL) < TR_DHT_FIREWALLED) &&
|
||||
(tr_dhtStatus (ss, AF_INET6, NULL) < TR_DHT_FIREWALLED)) {
|
||||
tr_ninf ("DHT", "Not saving nodes, DHT not ready");
|
||||
tr_logAddNamedInfo ("DHT", "Not saving nodes, DHT not ready");
|
||||
} else {
|
||||
tr_variant benc;
|
||||
struct sockaddr_in sins[300];
|
||||
|
@ -364,7 +365,7 @@ tr_dhtUninit (tr_session *ss)
|
|||
int i, j, num = 300, num6 = 300;
|
||||
int n = dht_get_nodes (sins, &num, sins6, &num6);
|
||||
|
||||
tr_ninf ("DHT", "Saving %d (%d + %d) nodes", n, num, num6);
|
||||
tr_logAddNamedInfo ("DHT", "Saving %d (%d + %d) nodes", n, num, num6);
|
||||
|
||||
j = 0;
|
||||
for (i=0; i<num; ++i) {
|
||||
|
@ -391,7 +392,7 @@ tr_dhtUninit (tr_session *ss)
|
|||
}
|
||||
|
||||
dht_uninit ();
|
||||
tr_ndbg ("DHT", "Done uninitializing DHT");
|
||||
tr_logAddNamedDbg ("DHT", "Done uninitializing DHT");
|
||||
|
||||
session = NULL;
|
||||
}
|
||||
|
@ -530,7 +531,7 @@ callback (void *ignore UNUSED, int event,
|
|||
for (i=0; i<n; ++i)
|
||||
tr_peerMgrAddPex (tor, TR_PEER_FROM_DHT, pex+i, -1);
|
||||
tr_free (pex);
|
||||
tr_tordbg (tor, "Learned %d %s peers from DHT",
|
||||
tr_logAddTorDbg (tor, "Learned %d %s peers from DHT",
|
||||
(int)n,
|
||||
event == DHT_EVENT_VALUES6 ? "IPv6" : "IPv4");
|
||||
}
|
||||
|
@ -540,10 +541,10 @@ callback (void *ignore UNUSED, int event,
|
|||
tr_torrent * tor = tr_torrentFindFromHash (session, info_hash);
|
||||
if (tor) {
|
||||
if (event == DHT_EVENT_SEARCH_DONE) {
|
||||
tr_torinf (tor, "%s", "IPv4 DHT announce done");
|
||||
tr_logAddTorInfo (tor, "%s", "IPv4 DHT announce done");
|
||||
tor->dhtAnnounceInProgress = 0;
|
||||
} else {
|
||||
tr_torinf (tor, "%s", "IPv6 DHT announce done");
|
||||
tr_logAddTorInfo (tor, "%s", "IPv6 DHT announce done");
|
||||
tor->dhtAnnounce6InProgress = 0;
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +571,7 @@ tr_dhtAnnounce (tr_torrent *tor, int af, bool announce)
|
|||
announce ? tr_sessionGetPeerPort (session) : 0,
|
||||
af, callback, NULL);
|
||||
if (rc >= 1) {
|
||||
tr_torinf (tor, "Starting %s DHT announce (%s, %d nodes)",
|
||||
tr_logAddTorInfo (tor, "Starting %s DHT announce (%s, %d nodes)",
|
||||
af == AF_INET6 ? "IPv6" : "IPv4",
|
||||
tr_dhtPrintableStatus (status), numnodes);
|
||||
if (af == AF_INET)
|
||||
|
@ -579,13 +580,13 @@ tr_dhtAnnounce (tr_torrent *tor, int af, bool announce)
|
|||
tor->dhtAnnounce6InProgress = true;
|
||||
ret = 1;
|
||||
} else {
|
||||
tr_torerr (tor, "%s DHT announce failed (%s, %d nodes): %s",
|
||||
tr_logAddTorErr (tor, "%s DHT announce failed (%s, %d nodes): %s",
|
||||
af == AF_INET6 ? "IPv6" : "IPv4",
|
||||
tr_dhtPrintableStatus (status), numnodes,
|
||||
tr_strerror (errno));
|
||||
}
|
||||
} else {
|
||||
tr_tordbg (tor, "%s DHT not ready (%s, %d nodes)",
|
||||
tr_logAddTorDbg (tor, "%s DHT not ready (%s, %d nodes)",
|
||||
af == AF_INET6 ? "IPv6" : "IPv4",
|
||||
tr_dhtPrintableStatus (status), numnodes);
|
||||
}
|
||||
|
@ -643,7 +644,7 @@ tr_dhtCallback (unsigned char *buf, int buflen,
|
|||
if (errno == EINTR) {
|
||||
tosleep = 0;
|
||||
} else {
|
||||
tr_nerr ("DHT", "dht_periodic failed: %s", tr_strerror (errno));
|
||||
tr_logAddNamedError ("DHT", "dht_periodic failed: %s", tr_strerror (errno));
|
||||
if (errno == EINVAL || errno == EFAULT)
|
||||
abort ();
|
||||
tosleep = 1;
|
||||
|
|
|
@ -48,6 +48,7 @@ THE SOFTWARE.
|
|||
|
||||
/* libT */
|
||||
#include "transmission.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "peer-mgr.h" /* tr_peerMgrAddPex () */
|
||||
#include "session.h"
|
||||
|
@ -280,7 +281,7 @@ int tr_lpdInit (tr_session* ss, tr_address* tr_addr UNUSED)
|
|||
if (lpd_port <= 0)
|
||||
return -1;
|
||||
|
||||
tr_ndbg ("LPD", "Initialising Local Peer Discovery");
|
||||
tr_logAddNamedDbg ("LPD", "Initialising Local Peer Discovery");
|
||||
|
||||
/* setup datagram socket (receive) */
|
||||
{
|
||||
|
@ -351,7 +352,7 @@ int tr_lpdInit (tr_session* ss, tr_address* tr_addr UNUSED)
|
|||
upkeep_timer = evtimer_new (ss->event_base, on_upkeep_timer, ss);
|
||||
tr_timerAdd (upkeep_timer, UPKEEP_INTERVAL_SECS, 0);
|
||||
|
||||
tr_ndbg ("LPD", "Local Peer Discovery initialised");
|
||||
tr_logAddNamedDbg ("LPD", "Local Peer Discovery initialised");
|
||||
|
||||
return 1;
|
||||
|
||||
|
@ -362,7 +363,7 @@ int tr_lpdInit (tr_session* ss, tr_address* tr_addr UNUSED)
|
|||
close (lpd_socket2);
|
||||
lpd_socket = lpd_socket2 = -1;
|
||||
session = NULL;
|
||||
tr_ndbg ("LPD", "LPD initialisation failed (errno = %d)", save);
|
||||
tr_logAddNamedDbg ("LPD", "LPD initialisation failed (errno = %d)", save);
|
||||
errno = save;
|
||||
}
|
||||
|
||||
|
@ -375,7 +376,7 @@ void tr_lpdUninit (tr_session* ss)
|
|||
if (session != ss)
|
||||
return;
|
||||
|
||||
tr_ndbg ("LPD", "Uninitialising Local Peer Discovery");
|
||||
tr_logAddNamedDbg ("LPD", "Uninitialising Local Peer Discovery");
|
||||
|
||||
event_free (lpd_event);
|
||||
lpd_event = NULL;
|
||||
|
@ -386,7 +387,7 @@ void tr_lpdUninit (tr_session* ss)
|
|||
/* just shut down, we won't remember any former nodes */
|
||||
evutil_closesocket (lpd_socket);
|
||||
evutil_closesocket (lpd_socket2);
|
||||
tr_ndbg ("LPD", "Done uninitialising Local Peer Discovery");
|
||||
tr_logAddNamedDbg ("LPD", "Done uninitialising Local Peer Discovery");
|
||||
|
||||
session = NULL;
|
||||
}
|
||||
|
@ -470,7 +471,7 @@ tr_lpdSendAnnounce (const tr_torrent* t)
|
|||
return false;
|
||||
}
|
||||
|
||||
tr_tordbg (t, "LPD announce message away");
|
||||
tr_logAddTorDbg (t, "LPD announce message away");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -531,7 +532,7 @@ static int tr_lpdConsiderAnnounce (tr_pex* peer, const char* const msg)
|
|||
{
|
||||
/* we found a suitable peer, add it to the torrent */
|
||||
tr_peerMgrAddPex (tor, TR_PEER_FROM_LPD, peer, -1);
|
||||
tr_tordbg (tor, "Learned %d local peer from LPD (%s:%u)",
|
||||
tr_logAddTorDbg (tor, "Learned %d local peer from LPD (%s:%u)",
|
||||
1, tr_address_to_string (&peer->addr), peerPort);
|
||||
|
||||
/* periodic reconnectPulse () deals with the rest... */
|
||||
|
@ -539,7 +540,7 @@ static int tr_lpdConsiderAnnounce (tr_pex* peer, const char* const msg)
|
|||
return 1;
|
||||
}
|
||||
else
|
||||
tr_ndbg ("LPD", "Cannot serve torrent #%s", hashString);
|
||||
tr_logAddNamedDbg ("LPD", "Cannot serve torrent #%s", hashString);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -608,7 +609,7 @@ tr_lpdAnnounceMore (const time_t now, const int interval)
|
|||
const int maxAnnounceCap = interval * lpd_announceCapFactor;
|
||||
|
||||
if (lpd_unsolicitedMsgCounter < 0)
|
||||
tr_ninf ("LPD", "Dropped %d announces in the last interval (max. %d "
|
||||
tr_logAddNamedInfo ("LPD", "Dropped %d announces in the last interval (max. %d "
|
||||
"allowed)", -lpd_unsolicitedMsgCounter, maxAnnounceCap);
|
||||
|
||||
lpd_unsolicitedMsgCounter = maxAnnounceCap;
|
||||
|
@ -666,7 +667,7 @@ static void event_callback (int s UNUSED, short type, void* ignore UNUSED)
|
|||
return; /* OK so far, no log message */
|
||||
}
|
||||
|
||||
tr_ndbg ("LPD", "Discarded invalid multicast message");
|
||||
tr_logAddNamedDbg ("LPD", "Discarded invalid multicast message");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ THE SOFTWARE.
|
|||
#include <libutp/utp.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "session.h"
|
||||
#include "tr-dht.h"
|
||||
|
@ -54,13 +55,13 @@ set_socket_buffers (int fd, int large)
|
|||
size = large ? RECV_BUFFER_SIZE : SMALL_BUFFER_SIZE;
|
||||
rc = setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof (size));
|
||||
if (rc < 0)
|
||||
tr_nerr ("UDP", "Failed to set receive buffer: %s",
|
||||
tr_logAddNamedError ("UDP", "Failed to set receive buffer: %s",
|
||||
tr_strerror (errno));
|
||||
|
||||
size = large ? SEND_BUFFER_SIZE : SMALL_BUFFER_SIZE;
|
||||
rc = setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size));
|
||||
if (rc < 0)
|
||||
tr_nerr ("UDP", "Failed to set send buffer: %s",
|
||||
tr_logAddNamedError ("UDP", "Failed to set send buffer: %s",
|
||||
tr_strerror (errno));
|
||||
|
||||
if (large) {
|
||||
|
@ -73,10 +74,10 @@ set_socket_buffers (int fd, int large)
|
|||
sbuf = 0;
|
||||
|
||||
if (rbuf < RECV_BUFFER_SIZE) {
|
||||
tr_nerr ("UDP", "Failed to set receive buffer: requested %d, got %d",
|
||||
tr_logAddNamedError ("UDP", "Failed to set receive buffer: requested %d, got %d",
|
||||
RECV_BUFFER_SIZE, rbuf);
|
||||
#ifdef __linux__
|
||||
tr_ninf ("UDP",
|
||||
tr_logAddNamedInfo ("UDP",
|
||||
"Please add the line "
|
||||
"\"net.core.rmem_max = %d\" to /etc/sysctl.conf",
|
||||
RECV_BUFFER_SIZE);
|
||||
|
@ -84,10 +85,10 @@ set_socket_buffers (int fd, int large)
|
|||
}
|
||||
|
||||
if (sbuf < SEND_BUFFER_SIZE) {
|
||||
tr_nerr ("UDP", "Failed to set send buffer: requested %d, got %d",
|
||||
tr_logAddNamedError ("UDP", "Failed to set send buffer: requested %d, got %d",
|
||||
SEND_BUFFER_SIZE, sbuf);
|
||||
#ifdef __linux__
|
||||
tr_ninf ("UDP",
|
||||
tr_logAddNamedInfo ("UDP",
|
||||
"Please add the line "
|
||||
"\"net.core.wmem_max = %d\" to /etc/sysctl.conf",
|
||||
SEND_BUFFER_SIZE);
|
||||
|
@ -177,7 +178,7 @@ rebind_ipv6 (tr_session *ss, bool force)
|
|||
fail:
|
||||
/* Something went wrong. It's difficult to recover, so let's simply
|
||||
set things up so that we try again next time. */
|
||||
tr_nerr ("UDP", "Couldn't rebind IPv6 socket");
|
||||
tr_logAddNamedError ("UDP", "Couldn't rebind IPv6 socket");
|
||||
if (s >= 0)
|
||||
close (s);
|
||||
if (ss->udp6_bound) {
|
||||
|
@ -219,12 +220,12 @@ event_callback (int s, short type UNUSED, void *sv)
|
|||
buf[0] == 0 && buf[1] == 0 && buf[2] == 0 && buf[3] <= 3) {
|
||||
rc = tau_handle_message (ss, buf, rc);
|
||||
if (!rc)
|
||||
tr_ndbg ("UDP", "Couldn't parse UDP tracker packet.");
|
||||
tr_logAddNamedDbg ("UDP", "Couldn't parse UDP tracker packet.");
|
||||
} else {
|
||||
if (tr_sessionIsUTPEnabled (ss)) {
|
||||
rc = tr_utpPacket (buf, rc, (struct sockaddr*)&from, fromlen, ss);
|
||||
if (!rc)
|
||||
tr_ndbg ("UDP", "Unexpected UDP packet");
|
||||
tr_logAddNamedDbg ("UDP", "Unexpected UDP packet");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +248,7 @@ tr_udpInit (tr_session *ss)
|
|||
|
||||
ss->udp_socket = socket (PF_INET, SOCK_DGRAM, 0);
|
||||
if (ss->udp_socket < 0) {
|
||||
tr_nerr ("UDP", "Couldn't create IPv4 socket");
|
||||
tr_logAddNamedError ("UDP", "Couldn't create IPv4 socket");
|
||||
goto ipv6;
|
||||
}
|
||||
|
||||
|
@ -259,7 +260,7 @@ tr_udpInit (tr_session *ss)
|
|||
sin.sin_port = htons (ss->udp_port);
|
||||
rc = bind (ss->udp_socket, (struct sockaddr*)&sin, sizeof (sin));
|
||||
if (rc < 0) {
|
||||
tr_nerr ("UDP", "Couldn't bind IPv4 socket");
|
||||
tr_logAddNamedError ("UDP", "Couldn't bind IPv4 socket");
|
||||
close (ss->udp_socket);
|
||||
ss->udp_socket = -1;
|
||||
goto ipv6;
|
||||
|
@ -268,7 +269,7 @@ tr_udpInit (tr_session *ss)
|
|||
event_new (ss->event_base, ss->udp_socket, EV_READ | EV_PERSIST,
|
||||
event_callback, ss);
|
||||
if (ss->udp_event == NULL)
|
||||
tr_nerr ("UDP", "Couldn't allocate IPv4 event");
|
||||
tr_logAddNamedError ("UDP", "Couldn't allocate IPv4 event");
|
||||
|
||||
ipv6:
|
||||
if (tr_globalIPv6 ())
|
||||
|
@ -278,7 +279,7 @@ tr_udpInit (tr_session *ss)
|
|||
event_new (ss->event_base, ss->udp6_socket, EV_READ | EV_PERSIST,
|
||||
event_callback, ss);
|
||||
if (ss->udp6_event == NULL)
|
||||
tr_nerr ("UDP", "Couldn't allocate IPv6 event");
|
||||
tr_logAddNamedError ("UDP", "Couldn't allocate IPv6 event");
|
||||
}
|
||||
|
||||
tr_udpSetSocketBuffers (ss);
|
||||
|
|
|
@ -28,6 +28,7 @@ THE SOFTWARE.
|
|||
#include <libutp/utp.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "session.h"
|
||||
#include "crypto.h" /* tr_cryptoWeakRandInt () */
|
||||
|
@ -39,8 +40,8 @@ THE SOFTWARE.
|
|||
|
||||
#define dbgmsg(...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#ifndef WITH_UTP
|
||||
|
@ -48,7 +49,7 @@ THE SOFTWARE.
|
|||
void
|
||||
UTP_Close (struct UTPSocket * socket)
|
||||
{
|
||||
tr_nerr (MY_NAME, "UTP_Close (%p) was called.", socket);
|
||||
tr_logAddNamedError (MY_NAME, "UTP_Close (%p) was called.", socket);
|
||||
dbgmsg ("UTP_Close (%p) was called.", socket);
|
||||
assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ UTP_Close (struct UTPSocket * socket)
|
|||
void
|
||||
UTP_RBDrained (struct UTPSocket *socket)
|
||||
{
|
||||
tr_nerr (MY_NAME, "UTP_RBDrained (%p) was called.", socket);
|
||||
tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p) was called.", socket);
|
||||
dbgmsg ("UTP_RBDrained (%p) was called.", socket);
|
||||
assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
|
||||
}
|
||||
|
@ -64,7 +65,7 @@ UTP_RBDrained (struct UTPSocket *socket)
|
|||
bool
|
||||
UTP_Write (struct UTPSocket *socket, size_t count)
|
||||
{
|
||||
tr_nerr (MY_NAME, "UTP_RBDrained (%p, %zu) was called.", socket, count);
|
||||
tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p, %zu) was called.", socket, count);
|
||||
dbgmsg ("UTP_RBDrained (%p, %zu) was called.", socket, count);
|
||||
assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
|
||||
return false;
|
||||
|
@ -115,7 +116,7 @@ incoming (void *closure, struct UTPSocket *s)
|
|||
UTP_GetPeerName (s, from, &fromlen);
|
||||
if (!tr_address_from_sockaddr_storage (&addr, &port, &from_storage))
|
||||
{
|
||||
tr_nerr ("UTP", "Unknown socket family");
|
||||
tr_logAddNamedError ("UTP", "Unknown socket family");
|
||||
UTP_Close (s);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -801,48 +801,46 @@ void tr_sessionSetTorrentDoneScript (tr_session *, const char * scriptFilename);
|
|||
|
||||
typedef enum
|
||||
{
|
||||
TR_MSG_ERR = 1,
|
||||
TR_MSG_INF = 2,
|
||||
TR_MSG_DBG = 3
|
||||
TR_LOG_ERROR = 1,
|
||||
TR_LOG_INFO = 2,
|
||||
TR_LOG_DEBUG = 3,
|
||||
TR_LOG_FIREHOSE = 4
|
||||
}
|
||||
tr_msg_level;
|
||||
tr_log_level;
|
||||
|
||||
void tr_setMessageLevel (tr_msg_level);
|
||||
void tr_logSetLevel (tr_log_level);
|
||||
|
||||
typedef struct tr_msg_list
|
||||
typedef struct tr_log_message
|
||||
{
|
||||
/* TR_MSG_ERR, TR_MSG_INF, or TR_MSG_DBG */
|
||||
tr_msg_level level;
|
||||
/* TR_LOG_ERROR, TR_LOG_INFO, or TR_LOG_DEBUG */
|
||||
tr_log_level level;
|
||||
|
||||
/* The line number in the source file where this message originated */
|
||||
int line;
|
||||
/* The line number in the source file where this message originated */
|
||||
int line;
|
||||
|
||||
/* Time the message was generated */
|
||||
time_t when;
|
||||
/* Time the message was generated */
|
||||
time_t when;
|
||||
|
||||
/* The torrent associated with this message,
|
||||
* or a module name such as "Port Forwarding" for non-torrent messages,
|
||||
* or NULL. */
|
||||
char * name;
|
||||
/* The torrent associated with this message,
|
||||
* or a module name such as "Port Forwarding" for non-torrent messages,
|
||||
* or NULL. */
|
||||
char * name;
|
||||
|
||||
/* The message */
|
||||
char * message;
|
||||
/* The message */
|
||||
char * message;
|
||||
|
||||
/* The source file where this message originated */
|
||||
const char * file;
|
||||
/* The source file where this message originated */
|
||||
const char * file;
|
||||
|
||||
/* linked list of messages */
|
||||
struct tr_msg_list * next;
|
||||
/* linked list of messages */
|
||||
struct tr_log_message * next;
|
||||
}
|
||||
tr_msg_list;
|
||||
tr_log_message;
|
||||
|
||||
void tr_setMessageQueuing (bool isEnabled);
|
||||
|
||||
bool tr_getMessageQueuing (void);
|
||||
|
||||
tr_msg_list * tr_getQueuedMessages (void);
|
||||
|
||||
void tr_freeMessageList (tr_msg_list * freeme);
|
||||
tr_log_message * tr_logGetQueue (void);
|
||||
bool tr_logGetQueueEnabled (void);
|
||||
void tr_logSetQueueEnabled (bool isEnabled);
|
||||
void tr_logFreeQueue (tr_log_message * freeme);
|
||||
|
||||
/** @addtogroup Blocklists
|
||||
@{ */
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <event2/event.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "session.h"
|
||||
|
||||
|
@ -39,7 +40,7 @@ pgpipe (int handles[2])
|
|||
|
||||
if ((s = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
|
||||
{
|
||||
tr_dbg ("pgpipe failed to create socket: %ui", WSAGetLastError ());
|
||||
tr_logAddDebug ("pgpipe failed to create socket: %ui", WSAGetLastError ());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -49,38 +50,38 @@ pgpipe (int handles[2])
|
|||
serv_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
||||
if (bind (s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
|
||||
{
|
||||
tr_dbg ("pgpipe failed to bind: %ui", WSAGetLastError ());
|
||||
tr_logAddDebug ("pgpipe failed to bind: %ui", WSAGetLastError ());
|
||||
closesocket (s);
|
||||
return -1;
|
||||
}
|
||||
if (listen (s, 1) == SOCKET_ERROR)
|
||||
{
|
||||
tr_ndbg ("event","pgpipe failed to listen: %ui", WSAGetLastError ());
|
||||
tr_logAddNamedDbg ("event","pgpipe failed to listen: %ui", WSAGetLastError ());
|
||||
closesocket (s);
|
||||
return -1;
|
||||
}
|
||||
if (getsockname (s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR)
|
||||
{
|
||||
tr_dbg ("pgpipe failed to getsockname: %ui", WSAGetLastError ());
|
||||
tr_logAddDebug ("pgpipe failed to getsockname: %ui", WSAGetLastError ());
|
||||
closesocket (s);
|
||||
return -1;
|
||||
}
|
||||
if ((handles[1] = socket (PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
|
||||
{
|
||||
tr_dbg ("pgpipe failed to create socket 2: %ui", WSAGetLastError ());
|
||||
tr_logAddDebug ("pgpipe failed to create socket 2: %ui", WSAGetLastError ());
|
||||
closesocket (s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (connect (handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
|
||||
{
|
||||
tr_dbg ("pgpipe failed to connect socket: %ui", WSAGetLastError ());
|
||||
tr_logAddDebug ("pgpipe failed to connect socket: %ui", WSAGetLastError ());
|
||||
closesocket (s);
|
||||
return -1;
|
||||
}
|
||||
if ((handles[0] = accept (s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
|
||||
{
|
||||
tr_dbg ("pgpipe failed to accept socket: %ui", WSAGetLastError ());
|
||||
tr_logAddDebug ("pgpipe failed to accept socket: %ui", WSAGetLastError ());
|
||||
closesocket (handles[1]);
|
||||
handles[1] = INVALID_SOCKET;
|
||||
closesocket (s);
|
||||
|
@ -154,8 +155,8 @@ struct tr_run_data
|
|||
|
||||
#define dbgmsg(...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, "event", __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, "event", __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
static void
|
||||
|
@ -213,9 +214,9 @@ static void
|
|||
logFunc (int severity, const char * message)
|
||||
{
|
||||
if (severity >= _EVENT_LOG_ERR)
|
||||
tr_err ("%s", message);
|
||||
tr_logAddError ("%s", message);
|
||||
else
|
||||
tr_dbg ("%s", message);
|
||||
tr_logAddDebug ("%s", message);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -252,7 +253,7 @@ libeventThreadFunc (void * veh)
|
|||
event_base_free (base);
|
||||
eh->session->events = NULL;
|
||||
tr_free (eh);
|
||||
tr_dbg ("Closing libevent thread");
|
||||
tr_logAddDebug ("Closing libevent thread");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -279,7 +280,7 @@ tr_eventClose (tr_session * session)
|
|||
assert (tr_isSession (session));
|
||||
|
||||
session->events->die = true;
|
||||
tr_deepLog (__FILE__, __LINE__, NULL, "closing trevent pipe");
|
||||
tr_logAddDeep (__FILE__, __LINE__, NULL, "closing trevent pipe");
|
||||
tr_netCloseSocket (session->events->fds[1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#endif
|
||||
|
||||
#include "transmission.h"
|
||||
#include "log.h"
|
||||
#include "port-forwarding.h"
|
||||
#include "session.h"
|
||||
#include "upnp.h"
|
||||
|
@ -101,7 +102,7 @@ tr_upnpDiscover (int msec)
|
|||
#endif
|
||||
|
||||
if (ret != UPNPCOMMAND_SUCCESS)
|
||||
tr_ndbg (getKey (), "upnpDiscover failed (errno %d - %s)", err, tr_strerror (err));
|
||||
tr_logAddNamedDbg (getKey (), "upnpDiscover failed (errno %d - %s)", err, tr_strerror (err));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -149,7 +150,7 @@ tr_upnpAddPortMapping (const tr_upnp * handle, const char * proto, tr_port port,
|
|||
#endif
|
||||
|
||||
if (err)
|
||||
tr_ndbg (getKey (), "%s Port forwarding failed with error %d (errno %d - %s)", proto, err, errno, tr_strerror (errno));
|
||||
tr_logAddNamedDbg (getKey (), "%s Port forwarding failed with error %d (errno %d - %s)", proto, err, errno, tr_strerror (errno));
|
||||
|
||||
errno = old_errno;
|
||||
return err;
|
||||
|
@ -197,10 +198,10 @@ tr_upnpPulse (tr_upnp * handle,
|
|||
if (UPNP_GetValidIGD (devlist, &handle->urls, &handle->data,
|
||||
handle->lanaddr, sizeof (handle->lanaddr)) == UPNP_IGD_VALID_CONNECTED)
|
||||
{
|
||||
tr_ninf (getKey (), _(
|
||||
tr_logAddNamedInfo (getKey (), _(
|
||||
"Found Internet Gateway Device \"%s\""),
|
||||
handle->urls.controlURL);
|
||||
tr_ninf (getKey (), _(
|
||||
tr_logAddNamedInfo (getKey (), _(
|
||||
"Local Address is \"%s\""), handle->lanaddr);
|
||||
handle->state = TR_UPNP_IDLE;
|
||||
handle->hasDiscovered = 1;
|
||||
|
@ -208,11 +209,11 @@ tr_upnpPulse (tr_upnp * handle,
|
|||
else
|
||||
{
|
||||
handle->state = TR_UPNP_ERR;
|
||||
tr_ndbg (
|
||||
tr_logAddNamedDbg (
|
||||
getKey (), "UPNP_GetValidIGD failed (errno %d - %s)",
|
||||
errno,
|
||||
tr_strerror (errno));
|
||||
tr_ndbg (
|
||||
tr_logAddNamedDbg (
|
||||
getKey (),
|
||||
"If your router supports UPnP, please make sure UPnP is enabled!");
|
||||
}
|
||||
|
@ -230,7 +231,7 @@ tr_upnpPulse (tr_upnp * handle,
|
|||
if ((tr_upnpGetSpecificPortMappingEntry (handle, "TCP") != UPNPCOMMAND_SUCCESS) ||
|
||||
(tr_upnpGetSpecificPortMappingEntry (handle, "UDP") != UPNPCOMMAND_SUCCESS))
|
||||
{
|
||||
tr_ninf (getKey (), _("Port %d isn't forwarded"), handle->port);
|
||||
tr_logAddNamedInfo (getKey (), _("Port %d isn't forwarded"), handle->port);
|
||||
handle->isMapped = false;
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +241,7 @@ tr_upnpPulse (tr_upnp * handle,
|
|||
tr_upnpDeletePortMapping (handle, "TCP", handle->port);
|
||||
tr_upnpDeletePortMapping (handle, "UDP", handle->port);
|
||||
|
||||
tr_ninf (getKey (),
|
||||
tr_logAddNamedInfo (getKey (),
|
||||
_("Stopping port forwarding through \"%s\", service \"%s\""),
|
||||
handle->urls.controlURL, handle->data.first.servicetype);
|
||||
|
||||
|
@ -273,19 +274,19 @@ tr_upnpPulse (tr_upnp * handle,
|
|||
|
||||
handle->isMapped = !err_tcp | !err_udp;
|
||||
}
|
||||
tr_ninf (getKey (),
|
||||
tr_logAddNamedInfo (getKey (),
|
||||
_("Port forwarding through \"%s\", service \"%s\". (local address: %s:%d)"),
|
||||
handle->urls.controlURL, handle->data.first.servicetype,
|
||||
handle->lanaddr, port);
|
||||
if (handle->isMapped)
|
||||
{
|
||||
tr_ninf (getKey (), "%s", _("Port forwarding successful!"));
|
||||
tr_logAddNamedInfo (getKey (), "%s", _("Port forwarding successful!"));
|
||||
handle->port = port;
|
||||
handle->state = TR_UPNP_IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_ndbg (getKey (), "If your router supports UPnP, please make sure UPnP is enabled!");
|
||||
tr_logAddNamedDbg (getKey (), "If your router supports UPnP, please make sure UPnP is enabled!");
|
||||
handle->port = -1;
|
||||
handle->state = TR_UPNP_ERR;
|
||||
}
|
||||
|
|
|
@ -56,129 +56,19 @@
|
|||
#include "fdlimit.h"
|
||||
#include "ConvertUTF.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
#include "platform.h" /* tr_lockLock (), TR_PATH_MAX */
|
||||
#include "variant.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
time_t __tr_current_time = 0;
|
||||
tr_msg_level __tr_message_level = TR_MSG_ERR;
|
||||
|
||||
static bool messageQueuing = false;
|
||||
static tr_msg_list * messageQueue = NULL;
|
||||
static tr_msg_list ** messageQueueTail = &messageQueue;
|
||||
static int messageQueueCount = 0;
|
||||
|
||||
#ifndef WIN32
|
||||
/* make null versions of these win32 functions */
|
||||
static inline int IsDebuggerPresent (void) { return false; }
|
||||
static inline void OutputDebugString (const void * unused UNUSED) { }
|
||||
#endif
|
||||
time_t __tr_current_time = 0;
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
static tr_lock*
|
||||
getMessageLock (void)
|
||||
{
|
||||
static tr_lock * l = NULL;
|
||||
|
||||
if (!l)
|
||||
l = tr_lockNew ();
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
void*
|
||||
tr_getLog (void)
|
||||
{
|
||||
static bool initialized = false;
|
||||
static FILE * file = NULL;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
int fd = 0;
|
||||
const char * str = getenv ("TR_DEBUG_FD");
|
||||
|
||||
if (str && *str)
|
||||
fd = atoi (str);
|
||||
|
||||
switch (fd)
|
||||
{
|
||||
case 1:
|
||||
file = stdout;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
file = stderr;
|
||||
break;
|
||||
|
||||
default:
|
||||
file = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
void
|
||||
tr_setMessageLevel (tr_msg_level level)
|
||||
{
|
||||
__tr_message_level = level;
|
||||
}
|
||||
|
||||
void
|
||||
tr_setMessageQueuing (bool enabled)
|
||||
{
|
||||
messageQueuing = enabled;
|
||||
}
|
||||
|
||||
bool
|
||||
tr_getMessageQueuing (void)
|
||||
{
|
||||
return messageQueuing != 0;
|
||||
}
|
||||
|
||||
tr_msg_list *
|
||||
tr_getQueuedMessages (void)
|
||||
{
|
||||
tr_msg_list * ret;
|
||||
tr_lockLock (getMessageLock ());
|
||||
|
||||
ret = messageQueue;
|
||||
messageQueue = NULL;
|
||||
messageQueueTail = &messageQueue;
|
||||
|
||||
messageQueueCount = 0;
|
||||
|
||||
tr_lockUnlock (getMessageLock ());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
tr_freeMessageList (tr_msg_list * list)
|
||||
{
|
||||
tr_msg_list * next;
|
||||
|
||||
while (NULL != list)
|
||||
{
|
||||
next = list->next;
|
||||
free (list->message);
|
||||
free (list->name);
|
||||
free (list);
|
||||
list = next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
||||
struct tm *
|
||||
tr_localtime_r (const time_t *_clock, struct tm *_result)
|
||||
{
|
||||
|
@ -192,145 +82,6 @@ tr_localtime_r (const time_t *_clock, struct tm *_result)
|
|||
#endif
|
||||
}
|
||||
|
||||
char*
|
||||
tr_getLogTimeStr (char * buf, int buflen)
|
||||
{
|
||||
char tmp[64];
|
||||
struct tm now_tm;
|
||||
struct timeval tv;
|
||||
time_t seconds;
|
||||
int milliseconds;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
|
||||
seconds = tv.tv_sec;
|
||||
tr_localtime_r (&seconds, &now_tm);
|
||||
strftime (tmp, sizeof (tmp), "%H:%M:%S", &now_tm);
|
||||
milliseconds = tv.tv_usec / 1000;
|
||||
tr_snprintf (buf, buflen, "%s.%03d", tmp, milliseconds);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool
|
||||
tr_deepLoggingIsActive (void)
|
||||
{
|
||||
static int8_t deepLoggingIsActive = -1;
|
||||
|
||||
if (deepLoggingIsActive < 0)
|
||||
deepLoggingIsActive = IsDebuggerPresent () || (tr_getLog ()!=NULL);
|
||||
|
||||
return deepLoggingIsActive != 0;
|
||||
}
|
||||
|
||||
void
|
||||
tr_deepLog (const char * file,
|
||||
int line,
|
||||
const char * name,
|
||||
const char * fmt,
|
||||
...)
|
||||
{
|
||||
FILE * fp = tr_getLog ();
|
||||
if (fp || IsDebuggerPresent ())
|
||||
{
|
||||
va_list args;
|
||||
char timestr[64];
|
||||
char * message;
|
||||
struct evbuffer * buf = evbuffer_new ();
|
||||
char * base = tr_basename (file);
|
||||
|
||||
evbuffer_add_printf (buf, "[%s] ",
|
||||
tr_getLogTimeStr (timestr, sizeof (timestr)));
|
||||
if (name)
|
||||
evbuffer_add_printf (buf, "%s ", name);
|
||||
va_start (args, fmt);
|
||||
evbuffer_add_vprintf (buf, fmt, args);
|
||||
va_end (args);
|
||||
evbuffer_add_printf (buf, " (%s:%d)\n", base, line);
|
||||
/* FIXME (libevent2) ifdef this out for nonwindows platforms */
|
||||
message = evbuffer_free_to_str (buf);
|
||||
OutputDebugString (message);
|
||||
if (fp)
|
||||
fputs (message, fp);
|
||||
|
||||
tr_free (message);
|
||||
tr_free (base);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
void
|
||||
tr_msg (const char * file, int line,
|
||||
tr_msg_level level,
|
||||
const char * name,
|
||||
const char * fmt, ...)
|
||||
{
|
||||
const int err = errno; /* message logging shouldn't affect errno */
|
||||
char buf[1024];
|
||||
va_list ap;
|
||||
tr_lockLock (getMessageLock ());
|
||||
|
||||
/* build the text message */
|
||||
*buf = '\0';
|
||||
va_start (ap, fmt);
|
||||
evutil_vsnprintf (buf, sizeof (buf), fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
OutputDebugString (buf);
|
||||
|
||||
if (*buf)
|
||||
{
|
||||
if (messageQueuing)
|
||||
{
|
||||
tr_msg_list * newmsg;
|
||||
newmsg = tr_new0 (tr_msg_list, 1);
|
||||
newmsg->level = level;
|
||||
newmsg->when = tr_time ();
|
||||
newmsg->message = tr_strdup (buf);
|
||||
newmsg->file = file;
|
||||
newmsg->line = line;
|
||||
newmsg->name = tr_strdup (name);
|
||||
|
||||
*messageQueueTail = newmsg;
|
||||
messageQueueTail = &newmsg->next;
|
||||
++messageQueueCount;
|
||||
|
||||
if (messageQueueCount > TR_MAX_MSG_LOG)
|
||||
{
|
||||
tr_msg_list * old = messageQueue;
|
||||
messageQueue = old->next;
|
||||
old->next = NULL;
|
||||
tr_freeMessageList (old);
|
||||
--messageQueueCount;
|
||||
assert (messageQueueCount == TR_MAX_MSG_LOG);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE * fp;
|
||||
char timestr[64];
|
||||
|
||||
fp = tr_getLog ();
|
||||
if (fp == NULL)
|
||||
fp = stderr;
|
||||
|
||||
tr_getLogTimeStr (timestr, sizeof (timestr));
|
||||
|
||||
if (name)
|
||||
fprintf (fp, "[%s] %s: %s\n", timestr, name, buf);
|
||||
else
|
||||
fprintf (fp, "[%s] %s\n", timestr, buf);
|
||||
fflush (fp);
|
||||
}
|
||||
}
|
||||
|
||||
tr_lockUnlock (getMessageLock ());
|
||||
errno = err;
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
@ -446,14 +197,14 @@ tr_loadFile (const char * path,
|
|||
if (stat (path, &sb))
|
||||
{
|
||||
const int err = errno;
|
||||
tr_dbg (err_fmt, path, tr_strerror (errno));
|
||||
tr_logAddDebug (err_fmt, path, tr_strerror (errno));
|
||||
errno = err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((sb.st_mode & S_IFMT) != S_IFREG)
|
||||
{
|
||||
tr_err (err_fmt, path, _("Not a regular file"));
|
||||
tr_logAddError (err_fmt, path, _("Not a regular file"));
|
||||
errno = EISDIR;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -463,7 +214,7 @@ tr_loadFile (const char * path,
|
|||
if (fd < 0)
|
||||
{
|
||||
const int err = errno;
|
||||
tr_err (err_fmt, path, tr_strerror (errno));
|
||||
tr_logAddError (err_fmt, path, tr_strerror (errno));
|
||||
errno = err;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -471,7 +222,7 @@ tr_loadFile (const char * path,
|
|||
if (!buf)
|
||||
{
|
||||
const int err = errno;
|
||||
tr_err (err_fmt, path, _("Memory allocation failed"));
|
||||
tr_logAddError (err_fmt, path, _("Memory allocation failed"));
|
||||
tr_close_file (fd);
|
||||
errno = err;
|
||||
return NULL;
|
||||
|
@ -480,7 +231,7 @@ tr_loadFile (const char * path,
|
|||
if (n == -1)
|
||||
{
|
||||
const int err = errno;
|
||||
tr_err (err_fmt, path, tr_strerror (errno));
|
||||
tr_logAddError (err_fmt, path, tr_strerror (errno));
|
||||
tr_close_file (fd);
|
||||
free (buf);
|
||||
errno = err;
|
||||
|
@ -579,7 +330,7 @@ tr_mkdirp (const char * path_in,
|
|||
if (tr_mkdir (path, permissions))
|
||||
{
|
||||
tmperr = errno;
|
||||
tr_err (_("Couldn't create \"%1$s\": %2$s"), path, tr_strerror (tmperr));
|
||||
tr_logAddError (_("Couldn't create \"%1$s\": %2$s"), path, tr_strerror (tmperr));
|
||||
tr_free (path);
|
||||
errno = tmperr;
|
||||
return -1;
|
||||
|
@ -589,7 +340,7 @@ tr_mkdirp (const char * path_in,
|
|||
{
|
||||
/* Node exists but isn't a folder */
|
||||
char * buf = tr_strdup_printf (_("File \"%s\" is in the way"), path);
|
||||
tr_err (_("Couldn't create \"%1$s\": %2$s"), path_in, buf);
|
||||
tr_logAddError (_("Couldn't create \"%1$s\": %2$s"), path_in, buf);
|
||||
tr_free (buf);
|
||||
tr_free (path);
|
||||
errno = ENOTDIR;
|
||||
|
|
|
@ -101,96 +101,6 @@ const char * tr_strip_positional_args (const char * fmt);
|
|||
*****
|
||||
****/
|
||||
|
||||
#define TR_MAX_MSG_LOG 10000
|
||||
|
||||
extern tr_msg_level __tr_message_level;
|
||||
|
||||
static inline tr_msg_level tr_getMessageLevel (void)
|
||||
{
|
||||
return __tr_message_level;
|
||||
}
|
||||
|
||||
static inline bool tr_msgLoggingIsActive (tr_msg_level level)
|
||||
{
|
||||
return tr_getMessageLevel () >= level;
|
||||
}
|
||||
|
||||
void tr_msg (const char * file, int line,
|
||||
tr_msg_level level,
|
||||
const char * torrent,
|
||||
const char * fmt, ...) TR_GNUC_PRINTF (5, 6);
|
||||
|
||||
#define tr_nerr(n, ...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_ERR)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_ERR, n, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_ninf(n, ...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_INF)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_INF, n, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_ndbg(n, ...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_DBG)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_DBG, n, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_torerr(tor, ...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_ERR)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_ERR, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_torinf(tor, ...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_INF)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_INF, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_tordbg(tor, ...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_DBG)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_DBG, tr_torrentName (tor), __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_err(...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_ERR)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_ERR, NULL, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_inf(...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_INF)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_INF, NULL, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define tr_dbg(...) \
|
||||
do { \
|
||||
if (tr_msgLoggingIsActive (TR_MSG_DBG)) \
|
||||
tr_msg (__FILE__, __LINE__, TR_MSG_DBG, NULL, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
void* tr_getLog (void);
|
||||
|
||||
/** @brief return true if deep logging has been enabled by the user; false otherwise */
|
||||
bool tr_deepLoggingIsActive (void);
|
||||
|
||||
void tr_deepLog (const char * file,
|
||||
int line,
|
||||
const char * name,
|
||||
const char * fmt,
|
||||
...) TR_GNUC_PRINTF (4, 5) TR_GNUC_NONNULL (1,4);
|
||||
|
||||
/** @brief set the buffer with the current time formatted for deep logging. */
|
||||
char* tr_getLogTimeStr (char * buf, int buflen) TR_GNUC_NONNULL (1);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Rich Salz's classic implementation of shell-style pattern matching for ?, \, [], and * characters.
|
||||
* @return 1 if the pattern matches, 0 if it doesn't, or -1 if an error occured
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "transmission.h"
|
||||
#include "ConvertUTF.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "ptrarray.h"
|
||||
#include "utils.h"
|
||||
#include "variant.h"
|
||||
|
@ -90,7 +91,7 @@ error_handler (jsonsl_t jsn,
|
|||
|
||||
if (data->source)
|
||||
{
|
||||
tr_err ("JSON parse failed in %s at pos %zu: %s -- remaining text \"%.16s\"",
|
||||
tr_logAddError ("JSON parse failed in %s at pos %zu: %s -- remaining text \"%.16s\"",
|
||||
data->source,
|
||||
jsn->pos,
|
||||
jsonsl_strerror (error),
|
||||
|
@ -98,7 +99,7 @@ error_handler (jsonsl_t jsn,
|
|||
}
|
||||
else
|
||||
{
|
||||
tr_err ("JSON parse failed at pos %zu: %s -- remaining text \"%.16s\"",
|
||||
tr_logAddError ("JSON parse failed at pos %zu: %s -- remaining text \"%.16s\"",
|
||||
jsn->pos,
|
||||
jsonsl_strerror (error),
|
||||
buf);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "transmission.h"
|
||||
#include "ConvertUTF.h"
|
||||
#include "fdlimit.h" /* tr_close_file() */
|
||||
#include "log.h"
|
||||
#include "platform.h" /* TR_PATH_MAX */
|
||||
#include "utils.h" /* tr_new(), tr_free() */
|
||||
#include "variant.h"
|
||||
|
@ -888,7 +889,7 @@ tr_variantWalk (const tr_variant * v,
|
|||
|
||||
default:
|
||||
/* did caller give us an uninitialized val? */
|
||||
tr_err ("%s", _("Invalid metadata"));
|
||||
tr_logAddError ("%s", _("Invalid metadata"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -978,7 +979,7 @@ tr_variantListCopy (tr_variant * target, const tr_variant * src)
|
|||
}
|
||||
else
|
||||
{
|
||||
tr_err ("tr_variantListCopy skipping item");
|
||||
tr_logAddError ("tr_variantListCopy skipping item");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1074,7 +1075,7 @@ tr_variantMergeDicts (tr_variant * target, const tr_variant * source)
|
|||
}
|
||||
else
|
||||
{
|
||||
tr_dbg ("tr_variantMergeDicts skipping \"%s\"", tr_quark_get_string(key,NULL));
|
||||
tr_logAddDebug ("tr_variantMergeDicts skipping \"%s\"", tr_quark_get_string(key,NULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1190,7 +1191,7 @@ tr_variantToFile (const tr_variant * v,
|
|||
|
||||
if (nleft > 0)
|
||||
{
|
||||
tr_err (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
|
||||
tr_logAddError (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
|
||||
tr_close_file (fd);
|
||||
unlink (tmp);
|
||||
}
|
||||
|
@ -1204,12 +1205,12 @@ tr_variantToFile (const tr_variant * v,
|
|||
if (!rename (tmp, filename))
|
||||
#endif
|
||||
{
|
||||
tr_inf (_("Saved \"%s\""), filename);
|
||||
tr_logAddInfo (_("Saved \"%s\""), filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = errno;
|
||||
tr_err (_("Couldn't save file \"%1$s\": %2$s"), filename, tr_strerror (err));
|
||||
tr_logAddError (_("Couldn't save file \"%1$s\": %2$s"), filename, tr_strerror (err));
|
||||
unlink (tmp);
|
||||
}
|
||||
}
|
||||
|
@ -1217,7 +1218,7 @@ tr_variantToFile (const tr_variant * v,
|
|||
else
|
||||
{
|
||||
err = errno;
|
||||
tr_err (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
|
||||
tr_logAddError (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
|
||||
}
|
||||
|
||||
tr_free (tmp);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "completion.h"
|
||||
#include "fdlimit.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "platform.h" /* tr_lock () */
|
||||
#include "torrent.h"
|
||||
#include "utils.h" /* tr_valloc (), tr_free () */
|
||||
|
@ -58,7 +59,7 @@ verifyTorrent (tr_torrent * tor, bool * stopFlag)
|
|||
|
||||
SHA1_Init (&sha);
|
||||
|
||||
tr_tordbg (tor, "%s", "verifying torrent...");
|
||||
tr_logAddTorDbg (tor, "%s", "verifying torrent...");
|
||||
tr_torrentSetChecked (tor, 0);
|
||||
while (!*stopFlag && (pieceIndex < tor->info.pieceCount))
|
||||
{
|
||||
|
@ -159,7 +160,7 @@ verifyTorrent (tr_torrent * tor, bool * stopFlag)
|
|||
|
||||
/* stopwatch */
|
||||
end = tr_time ();
|
||||
tr_tordbg (tor, "Verification is done. It took %d seconds to verify %"PRIu64" bytes (%"PRIu64" bytes per second)",
|
||||
tr_logAddTorDbg (tor, "Verification is done. It took %d seconds to verify %"PRIu64" bytes (%"PRIu64" bytes per second)",
|
||||
(int)(end-begin), tor->info.totalSize,
|
||||
(uint64_t)(tor->info.totalSize/ (1+ (end-begin))));
|
||||
|
||||
|
@ -226,7 +227,7 @@ verifyThreadFunc (void * unused UNUSED)
|
|||
tr_free (node);
|
||||
tr_lockUnlock (getVerifyLock ());
|
||||
|
||||
tr_torinf (tor, "%s", _("Verifying torrent"));
|
||||
tr_logAddTorInfo (tor, "%s", _("Verifying torrent"));
|
||||
tr_torrentSetVerifyState (tor, TR_VERIFY_NOW);
|
||||
changed = verifyTorrent (tor, &stopCurrent);
|
||||
tr_torrentSetVerifyState (tor, TR_VERIFY_NONE);
|
||||
|
@ -270,7 +271,7 @@ tr_verifyAdd (tr_torrent * tor, tr_verify_done_cb verify_done_cb)
|
|||
struct verify_node * node;
|
||||
|
||||
assert (tr_isTorrent (tor));
|
||||
tr_torinf (tor, "%s", _("Queued for verification"));
|
||||
tr_logAddTorInfo (tor, "%s", _("Queued for verification"));
|
||||
|
||||
node = tr_new (struct verify_node, 1);
|
||||
node->torrent = tor;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <event2/buffer.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "log.h"
|
||||
#include "net.h" /* tr_address */
|
||||
#include "platform.h" /* mutex */
|
||||
#include "session.h"
|
||||
|
@ -50,8 +51,8 @@ enum
|
|||
#else
|
||||
#define dbgmsg(...) \
|
||||
do { \
|
||||
if (tr_deepLoggingIsActive ()) \
|
||||
tr_deepLog (__FILE__, __LINE__, "web", __VA_ARGS__); \
|
||||
if (tr_logGetDeepEnabled ()) \
|
||||
tr_logAddDeep (__FILE__, __LINE__, "web", __VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
@ -336,10 +337,10 @@ tr_webThreadFunc (void * vsession)
|
|||
web->curl_ca_bundle = getenv ("CURL_CA_BUNDLE");
|
||||
if (web->curl_ssl_verify)
|
||||
{
|
||||
tr_ninf ("web", "will verify tracker certs using envvar CURL_CA_BUNDLE: %s",
|
||||
tr_logAddNamedInfo ("web", "will verify tracker certs using envvar CURL_CA_BUNDLE: %s",
|
||||
web->curl_ca_bundle == NULL ? "none" : web->curl_ca_bundle);
|
||||
tr_ninf ("web", "NB: this only works if you built against libcurl with openssl or gnutls, NOT nss");
|
||||
tr_ninf ("web", "NB: invalid certs will show up as 'Could not connect to tracker' like many other errors");
|
||||
tr_logAddNamedInfo ("web", "NB: this only works if you built against libcurl with openssl or gnutls, NOT nss");
|
||||
tr_logAddNamedInfo ("web", "NB: invalid certs will show up as 'Could not connect to tracker' like many other errors");
|
||||
}
|
||||
web->cookie_filename = tr_buildPath (session->configDir, "cookies.txt", NULL);
|
||||
|
||||
|
|
|
@ -184,8 +184,8 @@
|
|||
|
||||
- (void) updateLog: (NSTimer *) timer
|
||||
{
|
||||
tr_msg_list * messages;
|
||||
if ((messages = tr_getQueuedMessages()) == NULL)
|
||||
tr_log_message * messages;
|
||||
if ((messages = tr_logGetQueue()) == NULL)
|
||||
return;
|
||||
|
||||
[fLock lock];
|
||||
|
@ -201,7 +201,7 @@
|
|||
|
||||
BOOL changed = NO;
|
||||
|
||||
for (tr_msg_list * currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
|
||||
for (tr_log_message * currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
|
||||
{
|
||||
NSString * name = currentMessage->name != NULL ? [NSString stringWithUTF8String: currentMessage->name]
|
||||
: [[NSProcessInfo processInfo] processName];
|
||||
|
@ -226,11 +226,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ([fMessages count] > TR_MAX_MSG_LOG)
|
||||
if ([fMessages count] > TR_LOG_MAX_QUEUE_LENGTH)
|
||||
{
|
||||
const NSUInteger oldCount = [fDisplayedMessages count];
|
||||
|
||||
NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fMessages count]-TR_MAX_MSG_LOG)];
|
||||
NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fMessages count]-TR_LOG_MAX_QUEUE_LENGTH)];
|
||||
NSArray * itemsToRemove = [fMessages objectsAtIndexes: removeIndexes];
|
||||
|
||||
[fMessages removeObjectsAtIndexes: removeIndexes];
|
||||
|
@ -250,7 +250,7 @@
|
|||
|
||||
[fLock unlock];
|
||||
|
||||
tr_freeMessageList(messages);
|
||||
tr_logFreeQueue (messages);
|
||||
}
|
||||
|
||||
- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableView
|
||||
|
|
|
@ -843,9 +843,9 @@ Details :: refresh( )
|
|||
if( !single || myFilesDirty )
|
||||
myFileTreeView->clear( );
|
||||
if( single )
|
||||
myFileTreeView->update( torrents[0]->files( ) , myChangedTorrents );
|
||||
myFilesDirty = false;
|
||||
myFileTreeView->update( torrents[0]->files( ) , myFilesDirty || myChangedTorrents );
|
||||
|
||||
myFilesDirty = false;
|
||||
myChangedTorrents = false;
|
||||
myHavePendingRefresh = false;
|
||||
foreach( QWidget * w, myWidgets )
|
||||
|
|
|
@ -183,23 +183,26 @@ FileTreeItem :: update (int index,
|
|||
int priority,
|
||||
uint64_t totalSize,
|
||||
uint64_t haveSize,
|
||||
bool torrentChanged)
|
||||
bool updateFields)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " index " << index << " wanted " << wanted << " myIndex " << myIndex << " myWanted" << myIsWanted << std::endl;
|
||||
|
||||
if (myIndex != index)
|
||||
{
|
||||
myIndex = index;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (torrentChanged && myIsWanted != wanted)
|
||||
if (updateFields && myIsWanted != wanted)
|
||||
{
|
||||
myIsWanted = wanted;
|
||||
changed = true;
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " setting myIsWanted to " << myIsWanted << std::endl;
|
||||
}
|
||||
|
||||
if (torrentChanged && myPriority != priority)
|
||||
if (updateFields && myPriority != priority)
|
||||
{
|
||||
myPriority = priority;
|
||||
changed = true;
|
||||
|
@ -285,6 +288,7 @@ FileTreeItem :: twiddlePriority (QSet<int>& ids, int& p)
|
|||
p = TR_PRI_HIGH;
|
||||
else
|
||||
p = TR_PRI_LOW;
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " twiddlePriority, p " << p << std::endl;
|
||||
|
||||
setSubtreePriority (p, ids);
|
||||
}
|
||||
|
@ -316,7 +320,8 @@ FileTreeItem :: isSubtreeWanted () const
|
|||
void
|
||||
FileTreeItem :: setSubtreeWanted (bool b, QSet<int>& ids)
|
||||
{
|
||||
if(myIsWanted != b)
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " twiddleWanted, wanted " << b << std::endl;
|
||||
if (myIsWanted != b)
|
||||
{
|
||||
myIsWanted = b;
|
||||
|
||||
|
@ -331,6 +336,7 @@ FileTreeItem :: setSubtreeWanted (bool b, QSet<int>& ids)
|
|||
void
|
||||
FileTreeItem :: twiddleWanted (QSet<int>& ids, bool& wanted)
|
||||
{
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " twiddleWanted" << std::endl;
|
||||
wanted = isSubtreeWanted() != Qt::Checked;
|
||||
setSubtreeWanted (wanted, ids);
|
||||
}
|
||||
|
@ -348,6 +354,7 @@ FileTreeModel :: FileTreeModel (QObject *parent):
|
|||
|
||||
FileTreeModel :: ~FileTreeModel()
|
||||
{
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " dtor " << std::endl;
|
||||
clear();
|
||||
|
||||
delete rootItem;
|
||||
|
@ -516,16 +523,18 @@ void
|
|||
FileTreeModel :: clearSubtree (const QModelIndex& top)
|
||||
{
|
||||
size_t i = rowCount (top);
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " clearSubtree " << i << std::endl;
|
||||
|
||||
while (i > 0)
|
||||
clearSubtree(index(--i, 0, top));
|
||||
|
||||
delete static_cast<FileTreeItem*>(top.internalPointer());
|
||||
delete static_cast<FileTreeItem*>(top.internalPointer());
|
||||
}
|
||||
|
||||
void
|
||||
FileTreeModel :: clear ()
|
||||
{
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " clear" << std::endl;
|
||||
clearSubtree (QModelIndex());
|
||||
|
||||
reset ();
|
||||
|
@ -539,8 +548,9 @@ FileTreeModel :: addFile (int index,
|
|||
uint64_t size,
|
||||
uint64_t have,
|
||||
QList<QModelIndex> & rowsAdded,
|
||||
bool torrentChanged)
|
||||
bool updateFields)
|
||||
{
|
||||
bool added = false;
|
||||
FileTreeItem * i (rootItem);
|
||||
|
||||
foreach (QString token, filename.split (QChar::fromAscii('/')))
|
||||
|
@ -548,6 +558,7 @@ FileTreeModel :: addFile (int index,
|
|||
FileTreeItem * child(i->child(token));
|
||||
if (!child)
|
||||
{
|
||||
added = true;
|
||||
QModelIndex parentIndex (indexOf(i, 0));
|
||||
const int n (i->childCount());
|
||||
beginInsertRows (parentIndex, n, n);
|
||||
|
@ -559,8 +570,13 @@ FileTreeModel :: addFile (int index,
|
|||
}
|
||||
|
||||
if (i != rootItem)
|
||||
if (i->update (index, wanted, priority, size, have, torrentChanged))
|
||||
dataChanged (indexOf(i, 0), indexOf(i, NUM_COLUMNS-1));
|
||||
{
|
||||
if (i->update (index, wanted, priority, size, have, added || updateFields))
|
||||
{
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " emitting dataChanged for row " << i << std::endl;
|
||||
dataChanged (indexOf(i, 0), indexOf(i, NUM_COLUMNS-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -621,6 +637,7 @@ FileTreeModel :: clicked (const QModelIndex& index)
|
|||
QSet<int> file_ids;
|
||||
FileTreeItem * item;
|
||||
|
||||
std::cerr << "clicked in COL_PRIORITY" << std::endl;
|
||||
item = static_cast<FileTreeItem*>(index.internalPointer());
|
||||
item->twiddlePriority (file_ids, priority);
|
||||
emit priorityChanged (file_ids, priority);
|
||||
|
@ -799,8 +816,9 @@ FileTreeView :: ~FileTreeView ()
|
|||
void
|
||||
FileTreeView :: onClicked (const QModelIndex& proxyIndex)
|
||||
{
|
||||
const QModelIndex modelIndex = myProxy->mapToSource(proxyIndex);
|
||||
myModel.clicked(modelIndex);
|
||||
const QModelIndex modelIndex = myProxy->mapToSource (proxyIndex);
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " calling myModel.clicked()" << std::endl;
|
||||
myModel.clicked (modelIndex);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -835,24 +853,29 @@ FileTreeView :: eventFilter (QObject * o, QEvent * event)
|
|||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// handle using the keyboard to toggle the
|
||||
// wanted/unwanted state or the file priority
|
||||
else if(event->type() == QEvent::KeyPress)
|
||||
else if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " " << qPrintable(dynamic_cast<QKeyEvent*>(event)->text()) << std::endl;
|
||||
switch(dynamic_cast<QKeyEvent*>(event)->key())
|
||||
{
|
||||
case Qt::Key_Space:
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " calling COL_WANTED.clicked()" << std::endl;
|
||||
foreach (QModelIndex i, selectionModel()->selectedRows(COL_WANTED))
|
||||
clicked (i);
|
||||
return false;
|
||||
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " calling COL_PRIORITY.clicked()" << std::endl;
|
||||
foreach (QModelIndex i, selectionModel()->selectedRows(COL_PRIORITY))
|
||||
clicked (i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -864,12 +887,14 @@ FileTreeView :: update (const FileList& files)
|
|||
}
|
||||
|
||||
void
|
||||
FileTreeView :: update (const FileList& files, bool torrentChanged)
|
||||
FileTreeView :: update (const FileList& files, bool updateFields)
|
||||
{
|
||||
std::cerr << "update updateFields " << updateFields << std::endl;
|
||||
foreach (const TrFile file, files)
|
||||
{
|
||||
QList<QModelIndex> added;
|
||||
myModel.addFile (file.index, file.filename, file.wanted, file.priority, file.size, file.have, added, torrentChanged);
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " add file " << qPrintable(file.filename) << " wanted " << file.wanted << std::endl;
|
||||
myModel.addFile (file.index, file.filename, file.wanted, file.priority, file.size, file.have, added, updateFields);
|
||||
foreach (QModelIndex i, added)
|
||||
expand (myProxy->mapFromSource(i));
|
||||
}
|
||||
|
@ -878,5 +903,6 @@ FileTreeView :: update (const FileList& files, bool torrentChanged)
|
|||
void
|
||||
FileTreeView :: clear ()
|
||||
{
|
||||
std::cerr << __FILE__ << ':' << __LINE__ << " clear" << std::endl;
|
||||
myModel.clear();
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class FileTreeItem: public QObject
|
|||
int row () const;
|
||||
const QString& name () const { return myName; }
|
||||
QVariant data (int column, int role) const;
|
||||
bool update (int index, bool want, int priority, uint64_t total, uint64_t have, bool torrentChanged);
|
||||
bool update (int index, bool want, int priority, uint64_t total, uint64_t have, bool updateFields);
|
||||
void twiddleWanted (QSet<int>& fileIds, bool&);
|
||||
void twiddlePriority (QSet<int>& fileIds, int&);
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ main (int argc, char * argv[])
|
|||
char * out2 = NULL;
|
||||
tr_metainfo_builder * b = NULL;
|
||||
|
||||
tr_setMessageLevel (TR_MSG_ERR);
|
||||
tr_logSetLevel (TR_LOG_ERROR);
|
||||
|
||||
if (parseCommandLine (argc, (const char**)argv))
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -295,7 +295,7 @@ main (int argc, char * argv[])
|
|||
|
||||
files = tr_new0 (const char*, argc);
|
||||
|
||||
tr_setMessageLevel (TR_MSG_ERR);
|
||||
tr_logSetLevel (TR_LOG_ERROR);
|
||||
|
||||
if (parseCommandLine (argc, (const char**)argv))
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -310,7 +310,7 @@ main (int argc, char * argv[])
|
|||
tr_info inf;
|
||||
tr_ctor * ctor;
|
||||
|
||||
tr_setMessageLevel (TR_MSG_ERR);
|
||||
tr_logSetLevel (TR_LOG_ERROR);
|
||||
tr_formatter_mem_init (MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR);
|
||||
tr_formatter_size_init (DISK_K, DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR);
|
||||
tr_formatter_speed_init (SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR);
|
||||
|
|
Loading…
Reference in New Issue