Changeset 13868


Ignore:
Timestamp:
Jan 25, 2013, 11:34:20 PM (8 years ago)
Author:
jordan
Message:

make all the log functions/structs/enums use a single 'tr_log' namespace, such as tr_logGetQueue, tr_logAddInfo, tr_logIsLevelActive

Location:
trunk
Files:
2 added
54 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/daemon.c

    r13683 r13868  
    2626#include <libtransmission/transmission.h>
    2727#include <libtransmission/tr-getopt.h>
     28#include <libtransmission/log.h>
    2829#include <libtransmission/utils.h>
    2930#include <libtransmission/variant.h>
     
    146147            if (!mySession)
    147148            {
    148                 tr_inf ("Deferring reload until session is fully started.");
     149                tr_logAddInfo ("Deferring reload until session is fully started.");
    149150                seenHUP = true;
    150151            }
     
    162163
    163164                configDir = tr_sessionGetConfigDir (mySession);
    164                 tr_inf ("Reloading settings from \"%s\"", configDir);
     165                tr_logAddInfo ("Reloading settings from \"%s\"", configDir);
    165166                tr_variantInitDict (&settings, 0);
    166167                tr_variantDictAddBool (&settings, TR_KEY_rpc_enabled, true);
     
    174175
    175176        default:
    176             tr_err ("Unexpected signal (%d) in daemon, closing.", sig);
     177            tr_logAddError ("Unexpected signal (%d) in daemon, closing.", sig);
    177178            /* no break */
    178179
     
    266267
    267268        if (err == TR_PARSE_ERR)
    268             tr_err ("Error parsing .torrent file \"%s\"", file);
     269            tr_logAddError ("Error parsing .torrent file \"%s\"", file);
    269270        else
    270271        {
     
    272273            int test = tr_ctorGetDeleteSource (ctor, &trash);
    273274
    274             tr_inf ("Parsing .torrent file successful \"%s\"", file);
     275            tr_logAddInfo ("Parsing .torrent file successful \"%s\"", file);
    275276
    276277            if (!test && trash)
    277278            {
    278                 tr_inf ("Deleting input .torrent file \"%s\"", file);
     279                tr_logAddInfo ("Deleting input .torrent file \"%s\"", file);
    279280                if (remove (filename))
    280                     tr_err ("Error deleting .torrent file: %s", tr_strerror (errno));
     281                    tr_logAddError ("Error deleting .torrent file: %s", tr_strerror (errno));
    281282            }
    282283            else
     
    299300    {
    300301        char timestr[64];
    301         tr_getLogTimeStr (timestr, sizeof (timestr));
     302        tr_logGetTimeStr (timestr, sizeof (timestr));
    302303        if (name)
    303304            fprintf (logfile, "[%s] %s %s (%s:%d)\n", timestr, name, message, file, line);
     
    312313        /* figure out the syslog priority */
    313314        switch (level) {
    314             case TR_MSG_ERR: priority = LOG_ERR; break;
    315             case TR_MSG_DBG: priority = LOG_DEBUG; break;
    316             default: priority = LOG_INFO; break;
     315            case TR_LOG_ERROR: priority = LOG_ERR; break;
     316            case TR_LOG_DEBUG: priority = LOG_DEBUG; break;
     317            default:           priority = LOG_INFO; break;
    317318        }
    318319
     
    328329pumpLogMessages (FILE * logfile)
    329330{
    330     const tr_msg_list * l;
    331     tr_msg_list * list = tr_getQueuedMessages ();
     331    const tr_log_message * l;
     332    tr_log_message * list = tr_logGetQueue ();
    332333
    333334    for (l=list; l!=NULL; l=l->next)
     
    337338        fflush (logfile);
    338339
    339     tr_freeMessageList (list);
     340    tr_logFreeQueue (list);
    340341}
    341342
     
    468469            case 'Y': tr_variantDictAddBool (&settings, TR_KEY_lpd_enabled, false);
    469470                      break;
    470             case 810: tr_variantDictAddInt (&settings,  TR_KEY_message_level, TR_MSG_ERR);
    471                       break;
    472             case 811: tr_variantDictAddInt (&settings,  TR_KEY_message_level, TR_MSG_INF);
    473                       break;
    474             case 812: tr_variantDictAddInt (&settings,  TR_KEY_message_level, TR_MSG_DBG);
     471            case 810: tr_variantDictAddInt (&settings,  TR_KEY_message_level, TR_LOG_ERROR);
     472                      break;
     473            case 811: tr_variantDictAddInt (&settings,  TR_KEY_message_level, TR_LOG_INFO);
     474                      break;
     475            case 812: tr_variantDictAddInt (&settings,  TR_KEY_message_level, TR_LOG_DEBUG);
    475476                      break;
    476477            case 830: tr_variantDictAddBool (&settings, TR_KEY_utp_enabled, true);
     
    488489    if (!loaded)
    489490    {
    490         printMessage (logfile, TR_MSG_ERR, MY_NAME, "Error loading config file -- exiting.", __FILE__, __LINE__);
     491        printMessage (logfile, TR_LOG_ERROR, MY_NAME, "Error loading config file -- exiting.", __FILE__, __LINE__);
    491492        return -1;
    492493    }
     
    504505        char buf[256];
    505506        tr_snprintf (buf, sizeof (buf), "Failed to daemonize: %s", tr_strerror (errno));
    506         printMessage (logfile, TR_MSG_ERR, MY_NAME, buf, __FILE__, __LINE__);
     507        printMessage (logfile, TR_LOG_ERROR, MY_NAME, buf, __FILE__, __LINE__);
    507508        exit (1);
    508509    }
     
    514515    session = tr_sessionInit ("daemon", configDir, true, &settings);
    515516    tr_sessionSetRPCCallback (session, on_rpc_callback, NULL);
    516     tr_ninf (NULL, "Using settings from \"%s\"", configDir);
     517    tr_logAddNamedInfo (NULL, "Using settings from \"%s\"", configDir);
    517518    tr_sessionSaveSettings (session, configDir, &settings);
    518519
     
    526527            fprintf (fp, "%d", (int)getpid ());
    527528            fclose (fp);
    528             tr_inf ("Saved pidfile \"%s\"", pid_filename);
     529            tr_logAddInfo ("Saved pidfile \"%s\"", pid_filename);
    529530            pidfile_created = true;
    530531        }
    531532        else
    532             tr_err ("Unable to save pidfile \"%s\": %s", pid_filename, tr_strerror (errno));
     533            tr_logAddError ("Unable to save pidfile \"%s\": %s", pid_filename, tr_strerror (errno));
    533534    }
    534535
    535536    if (tr_variantDictFindBool (&settings, TR_KEY_rpc_authentication_required, &boolVal) && boolVal)
    536         tr_ninf (MY_NAME, "requiring authentication");
     537        tr_logAddNamedInfo (MY_NAME, "requiring authentication");
    537538
    538539    mySession = session;
     
    552553            && *dir)
    553554        {
    554             tr_inf ("Watching \"%s\" for new .torrent files", dir);
     555            tr_logAddInfo ("Watching \"%s\" for new .torrent files", dir);
    555556            watchdir = dtr_watchdir_new (mySession, dir, onFileAdded);
    556557        }
  • trunk/daemon/remote.c

    r13839 r13868  
    3131
    3232#include <libtransmission/transmission.h>
     33#include <libtransmission/log.h>
    3334#include <libtransmission/rpcimpl.h>
    3435#include <libtransmission/tr-getopt.h>
     
    16781679    if (tr_variantFromJson (&top, response, len))
    16791680    {
    1680         tr_nerr (MY_NAME, "Unable to parse response \"%*.*s\"", (int)len,
     1681        tr_logAddNamedError (MY_NAME, "Unable to parse response \"%*.*s\"", (int)len,
    16811682               (int)len, (char*)response);
    16821683        status |= EXIT_FAILURE;
     
    18041805    if ((res = curl_easy_perform (curl)))
    18051806    {
    1806         tr_nerr (MY_NAME, " (%s) %s", rpcurl_http, curl_easy_strerror (res));
     1807        tr_logAddNamedError (MY_NAME, " (%s) %s", rpcurl_http, curl_easy_strerror (res));
    18071808        status |= EXIT_FAILURE;
    18081809    }
  • trunk/daemon/watch.c

    r13726 r13868  
    2727
    2828#include <libtransmission/transmission.h>
    29 #include <libtransmission/utils.h> /* tr_buildPath (), tr_inf () */
     29#include <libtransmission/log.h>
     30#include <libtransmission/utils.h> /* tr_buildPath (), tr_logAddInfo () */
    3031#include "watch.h"
    3132
     
    7172    else
    7273    {
    73         tr_inf ("Using inotify to watch directory \"%s\"", w->dir);
     74        tr_logAddInfo ("Using inotify to watch directory \"%s\"", w->dir);
    7475        i = inotify_add_watch (w->inotify_fd, w->dir, DTR_INOTIFY_MASK);
    7576    }
     
    7778    if (i < 0)
    7879    {
    79         tr_err ("Unable to watch \"%s\": %s", w->dir, tr_strerror (errno));
     80        tr_logAddError ("Unable to watch \"%s\": %s", w->dir, tr_strerror (errno));
    8081    }
    8182    else if ((odir = opendir (w->dir)))
     
    9091                continue;
    9192
    92             tr_inf ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
     93            tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
    9394            w->callback (w->session, w->dir, name);
    9495        }
     
    139140            if (tr_str_has_suffix (name, ".torrent"))
    140141            {
    141                 tr_inf ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
     142                tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
    142143                w->callback (w->session, w->dir, name);
    143144            }
     
    160161watchdir_new_impl (dtr_watchdir * w UNUSED)
    161162{
    162     tr_inf ("Using readdir to watch directory \"%s\"", w->dir);
     163    tr_logAddInfo ("Using readdir to watch directory \"%s\"", w->dir);
    163164    w->lastFiles = evbuffer_new ();
    164165}
     
    226227            /* if this file wasn't here last time, try adding it */
    227228            if (!is_file_in_list (w->lastFiles, name, len)) {
    228                 tr_inf ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
     229                tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
    229230                w->callback (w->session, w->dir, name);
    230231            }
  • trunk/gtk/main.c

    r13795 r13868  
    607607
    608608  /* init glib/gtk */
     609#if !GLIB_CHECK_VERSION(2,35,4)
    609610  g_type_init ();
     611#endif
    610612  gtk_init (&argc, &argv);
    611613  g_set_application_name (_("Transmission"));
     
    10891091
    10901092      case TR_KEY_message_level:
    1091         tr_setMessageLevel (gtr_pref_int_get (key));
     1093        tr_logSetLevel (gtr_pref_int_get (key));
    10921094        break;
    10931095
  • trunk/gtk/msgwin.c

    r13761 r13868  
    1919
    2020#include <libtransmission/transmission.h>
     21#include <libtransmission/log.h>
    2122
    2223#include "conf.h"
     
    4344  GtkTreeModel  * filter;
    4445  GtkTreeModel  * sort;
    45   tr_msg_level    maxLevel;
     46  tr_log_level    maxLevel;
    4647  gboolean        isPaused;
    4748  guint           refresh_tag;
    4849};
    4950
    50 static struct tr_msg_list * myTail = NULL;
    51 static struct tr_msg_list * myHead = NULL;
     51static struct tr_log_message * myTail = NULL;
     52static struct tr_log_message * myHead = NULL;
    5253
    5354/****
     
    112113  const gboolean pinned_to_new = is_pinned_to_new (data);
    113114
    114   tr_setMessageLevel (level);
     115  tr_logSetLevel (level);
    115116  gtr_core_set_pref_int (data->core, TR_KEY_message_level, level);
    116117  data->maxLevel = level;
     
    155156          char * date;
    156157          const char * levelStr;
    157           const struct tr_msg_list * node;
     158          const struct tr_log_message * node;
    158159
    159160          gtk_tree_model_get (model, &iter, COL_TR_MSG, &node, -1);
     
    161162          switch (node->level)
    162163           {
    163              case TR_MSG_DBG:
     164             case TR_LOG_DEBUG:
    164165               levelStr = "debug";
    165166               break;
    166167
    167              case TR_MSG_ERR:
     168             case TR_LOG_ERROR:
    168169               levelStr = "error";
    169170               break;
     
    226227
    227228  gtk_list_store_clear (data->store);
    228   tr_freeMessageList (myHead);
     229  tr_logFreeQueue (myHead);
    229230  myHead = myTail = NULL;
    230231}
     
    243244  switch (msgLevel)
    244245    {
    245       case TR_MSG_DBG: return "forestgreen";
    246       case TR_MSG_INF: return "black";
    247       case TR_MSG_ERR: return "red";
     246      case TR_LOG_DEBUG: return "forestgreen";
     247      case TR_LOG_INFO: return "black";
     248      case TR_LOG_ERROR: return "red";
    248249      default: g_assert_not_reached (); return "black";
    249250    }
     
    259260  const int col = GPOINTER_TO_INT (gcol);
    260261  char * str = NULL;
    261   const struct tr_msg_list * node;
     262  const struct tr_log_message * node;
    262263
    263264  gtk_tree_model_get (tree_model, iter, col, &str, COL_TR_MSG, &node, -1);
     
    277278  struct tm tm;
    278279  char buf[16];
    279   const struct tr_msg_list * node;
     280  const struct tr_log_message * node;
    280281
    281282  gtk_tree_model_get (tree_model, iter, COL_TR_MSG, &node, -1);
     
    355356isRowVisible (GtkTreeModel * model, GtkTreeIter * iter, gpointer gdata)
    356357{
    357   const struct tr_msg_list * node;
     358  const struct tr_log_message * node;
    358359  const struct MsgData * data = gdata;
    359360
     
    373374}
    374375
    375 static tr_msg_list *
    376 addMessages (GtkListStore * store, struct tr_msg_list * head)
    377 {
    378   tr_msg_list * i;
     376static tr_log_message *
     377addMessages (GtkListStore * store, struct tr_log_message * head)
     378{
     379  tr_log_message * i;
    379380  static unsigned int sequence = 0;
    380381  const char * default_name = g_get_application_name ();
     
    392393
    393394      /* if it's an error message, dump it to the terminal too */
    394       if (i->level == TR_MSG_ERR)
     395      if (i->level == TR_LOG_ERROR)
    395396        {
    396397          GString * gstr = g_string_sized_new (512);
     
    414415  if (!data->isPaused)
    415416    {
    416       tr_msg_list * msgs = tr_getQueuedMessages ();
     417      tr_log_message * msgs = tr_logGetQueue ();
    417418      if (msgs)
    418419        {
    419420          /* add the new messages and append them to the end of
    420421           * our persistent list */
    421           tr_msg_list * tail = addMessages (data->store, msgs);
     422          tr_log_message * tail = addMessages (data->store, msgs);
    422423          if (myTail)
    423424              myTail->next = msgs;
     
    437438debug_level_combo_new (void)
    438439{
    439   GtkWidget * w = gtr_combo_box_new_enum (_("Error"),       TR_MSG_ERR,
    440                                           _("Information"), TR_MSG_INF,
    441                                           _("Debug"),       TR_MSG_DBG,
     440  GtkWidget * w = gtr_combo_box_new_enum (_("Error"),       TR_LOG_ERROR,
     441                                          _("Information"), TR_LOG_INFO,
     442                                          _("Debug"),       TR_LOG_DEBUG,
    442443                                          NULL);
    443444  gtr_combo_box_set_active_enum (GTK_COMBO_BOX (w), gtr_pref_int_get (TR_KEY_message_level));
     
    522523                                    G_TYPE_POINTER,    /* category */
    523524                                    G_TYPE_POINTER,    /* message */
    524                                     G_TYPE_POINTER);   /* struct tr_msg_list */
     525                                    G_TYPE_POINTER);   /* struct tr_log_message */
    525526
    526527  addMessages (data->store, myHead);
  • trunk/gtk/tr-core.c

    r13821 r13868  
    3333
    3434#include <libtransmission/transmission.h>
     35#include <libtransmission/log.h>
    3536#include <libtransmission/rpcimpl.h>
    3637#include <libtransmission/utils.h> /* tr_free */
     
    15491550  if (success)
    15501551    {
    1551       tr_inf ("%s", _("Inhibiting desktop hibernation"));
     1552      tr_logAddInfo ("%s", _("Inhibiting desktop hibernation"));
    15521553    }
    15531554  else
    15541555    {
    1555       tr_err (_("Couldn't inhibit desktop hibernation: %s"), err->message);
     1556      tr_logAddError (_("Couldn't inhibit desktop hibernation: %s"), err->message);
    15561557      g_error_free (err);
    15571558    }
     
    15871588  if (err == NULL)
    15881589    {
    1589       tr_inf ("%s", _("Allowing desktop hibernation"));
     1590      tr_logAddInfo ("%s", _("Allowing desktop hibernation"));
    15901591    }
    15911592  else
  • trunk/libtransmission/Makefile.am

    r13807 r13868  
    3434  inout.c \
    3535  list.c \
     36  log.c \
    3637  magnet.c \
    3738  makemeta.c \
     
    8990  libtransmission-test.h \
    9091  list.h \
     92  log.h \
    9193  magnet.h \
    9294  makemeta.h \
  • trunk/libtransmission/announcer-http.c

    r13683 r13868  
    2323#include "transmission.h"
    2424#include "announcer-common.h"
     25#include "log.h"
    2526#include "net.h" /* tr_globalIPv6 () */
    2627#include "peer-mgr.h" /* pex */
     
    3233
    3334#define dbgmsg(name, ...) \
    34 if (tr_deepLoggingIsActive ()) do { \
    35   tr_deepLog (__FILE__, __LINE__, name, __VA_ARGS__); \
    36 } while (0)
     35  do \
     36    { \
     37      if (tr_logGetDeepEnabled ()) \
     38        tr_logAddDeep (__FILE__, __LINE__, name, __VA_ARGS__); \
     39    } \
     40  while (0)
    3741
    3842/****
  • trunk/libtransmission/announcer-udp.c

    r13631 r13868  
    2323#include "announcer-common.h"
    2424#include "crypto.h" /* tr_cryptoRandBuf () */
     25#include "log.h"
    2526#include "peer-io.h"
    2627#include "peer-mgr.h" /* tr_peerMgrCompactToPex () */
     
    3031
    3132#define dbgmsg(name, ...) \
    32 if (tr_deepLoggingIsActive ()) do { \
    33   tr_deepLog (__FILE__, __LINE__, name, __VA_ARGS__); \
    34 } while (0)
     33  do \
     34    { \
     35      if (tr_logGetDeepEnabled ()) \
     36        tr_logAddDeep (__FILE__, __LINE__, name, __VA_ARGS__); \
     37    } \
     38  while (0)
    3539
    3640/****
  • trunk/libtransmission/announcer.c

    r13652 r13868  
    2626#include "announcer-common.h"
    2727#include "crypto.h" /* tr_cryptoRandInt (), tr_cryptoWeakRandInt () */
     28#include "log.h"
    2829#include "peer-mgr.h" /* tr_peerMgrCompactToPex () */
    2930#include "ptrarray.h"
     
    3839
    3940#define dbgmsg(tier, ...) \
    40 if (tr_deepLoggingIsActive ()) do { \
    41   char name[128]; \
    42   tier_build_log_name (tier, name, sizeof (name)); \
    43   tr_deepLog (__FILE__, __LINE__, name, __VA_ARGS__); \
    44 } while (0)
     41  do \
     42    { \
     43      if (tr_logGetDeepEnabled ()) \
     44        { \
     45          char name[128]; \
     46          tier_build_log_name (tier, name, sizeof (name)); \
     47          tr_logAddDeep (__FILE__, __LINE__, name, __VA_ARGS__); \
     48        } \
     49    } \
     50  while (0)
    4551
    4652enum
     
    750756dbgmsg_tier_announce_queue (const tr_tier * tier)
    751757{
    752     if (tr_deepLoggingIsActive ())
     758    if (tr_logGetDeepEnabled ())
    753759    {
    754760        int i;
     
    766772
    767773        message = evbuffer_free_to_str (buf);
    768         tr_deepLog (__FILE__, __LINE__, name, "announce queue is %s", message);
     774        tr_logAddDeep (__FILE__, __LINE__, name, "announce queue is %s", message);
    769775        tr_free (message);
    770776    }
     
    992998    /* set the error message */
    993999    dbgmsg (tier, "%s", err);
    994     tr_torinf (tier->tor, "%s", err);
     1000    tr_logAddTorInfo (tier->tor, "%s", err);
    9951001    tr_strlcpy (tier->lastAnnounceStr, err, sizeof (tier->lastAnnounceStr));
    9961002
     
    10011007    interval = getRetryInterval (tier->currentTracker);
    10021008    dbgmsg (tier, "Retrying announce in %d seconds.", interval);
    1003     tr_torinf (tier->tor, "Retrying announce in %d seconds.", interval);
     1009    tr_logAddTorInfo (tier->tor, "Retrying announce in %d seconds.", interval);
    10041010    tier_announce_event_push (tier, e, tr_time () + interval);
    10051011}
     
    11461152            if ((scrape_fields >= 3) || (!tracker->scrape && (scrape_fields >= 1)))
    11471153            {
    1148                 tr_tordbg (tier->tor, "Announce response contained scrape info; "
     1154                tr_logAddTorDbg (tier->tor, "Announce response contained scrape info; "
    11491155                                      "rescheduling next scrape to %d seconds from now.",
    11501156                                      tier->scrapeIntervalSec);
     
    12061212        tr_tracker_udp_announce (session, request, callback, callback_data);
    12071213    else
    1208         tr_err ("Unsupported url: %s", request->url);
     1214        tr_logAddError ("Unsupported url: %s", request->url);
    12091215
    12101216    announce_request_free (request);
     
    12571263    /* set the error message */
    12581264    dbgmsg (tier, "Scrape error: %s", errmsg);
    1259     tr_torinf (tier->tor, "Scrape error: %s", errmsg);
     1265    tr_logAddTorInfo (tier->tor, "Scrape error: %s", errmsg);
    12601266    tr_strlcpy (tier->lastScrapeStr, errmsg, sizeof (tier->lastScrapeStr));
    12611267
     
    12661272    interval = getRetryInterval (tier->currentTracker);
    12671273    dbgmsg (tier, "Retrying scrape in %zu seconds.", (size_t)interval);
    1268     tr_torinf (tier->tor, "Retrying scrape in %zu seconds.", (size_t)interval);
     1274    tr_logAddTorInfo (tier->tor, "Retrying scrape in %zu seconds.", (size_t)interval);
    12691275    tier->lastScrapeSucceeded = false;
    12701276    tier->scrapeAt = get_next_scrape_time (session, tier, interval);
     
    13491355                                                   response->min_request_interval);
    13501356                    tier->scrapeAt = get_next_scrape_time (session, tier, tier->scrapeIntervalSec);
    1351                     tr_tordbg (tier->tor, "Scrape successful. Rescraping in %d seconds.",
     1357                    tr_logAddTorDbg (tier->tor, "Scrape successful. Rescraping in %d seconds.",
    13521358                               tier->scrapeIntervalSec);
    13531359
     
    13851391        tr_tracker_udp_scrape (session, request, callback, callback_data);
    13861392    else
    1387         tr_err ("Unsupported url: %s", request->url);
     1393        tr_logAddError ("Unsupported url: %s", request->url);
    13881394}
    13891395
     
    15301536    for (i=0; i<n; ++i) {
    15311537        tr_tier * tier = tr_ptrArrayNth (&announceMe, i);
    1532         tr_tordbg (tier->tor, "%s", "Announcing to tracker");
     1538        tr_logAddTorDbg (tier->tor, "%s", "Announcing to tracker");
    15331539        dbgmsg (tier, "announcing tier %d of %d", i, n);
    15341540        tierAnnounce (announcer, tier);
  • trunk/libtransmission/bandwidth.c

    r13863 r13868  
    1818#include "bandwidth.h"
    1919#include "crypto.h" /* tr_cryptoWeakRandInt () */
     20#include "log.h"
    2021#include "peer-io.h"
    2122#include "utils.h"
     
    2425  do \
    2526    { \
    26       if (tr_deepLoggingIsActive ()) \
    27         tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
     27      if (tr_logGetDeepEnabled ()) \
     28        tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
    2829    } \
    2930  while (0)
  • trunk/libtransmission/blocklist.c

    r13824 r13868  
    3636#include "transmission.h"
    3737#include "blocklist.h"
     38#include "log.h"
    3839#include "net.h"
    3940#include "utils.h"
     
    9596  if (fd == -1)
    9697    {
    97       tr_err (err_fmt, b->filename, tr_strerror (errno));
     98      tr_logAddError (err_fmt, b->filename, tr_strerror (errno));
    9899      return;
    99100    }
     
    103104  if (!b->rules)
    104105    {
    105       tr_err (err_fmt, b->filename, tr_strerror (errno));
     106      tr_logAddError (err_fmt, b->filename, tr_strerror (errno));
    106107      close (fd);
    107108      return;
     
    113114
    114115  base = tr_basename (b->filename);
    115   tr_inf (_("Blocklist \"%s\" contains %zu entries"), base, b->ruleCount);
     116  tr_logAddInfo (_("Blocklist \"%s\" contains %zu entries"), base, b->ruleCount);
    116117  tr_free (base);
    117118}
     
    335336  if (in == NULL)
    336337    {
    337       tr_err (err_fmt, filename, tr_strerror (errno));
     338      tr_logAddError (err_fmt, filename, tr_strerror (errno));
    338339      return 0;
    339340    }
     
    344345  if (out == NULL)
    345346    {
    346       tr_err (err_fmt, b->filename, tr_strerror (errno));
     347      tr_logAddError (err_fmt, b->filename, tr_strerror (errno));
    347348      fclose (in);
    348349      return 0;
     
    364365        {
    365366          /* don't try to display the actual lines - it causes issues */
    366           tr_err (_("blocklist skipped invalid address at line %d"), inCount);
     367          tr_logAddError (_("blocklist skipped invalid address at line %d"), inCount);
    367368          continue;
    368369        }
     
    414415  if (fwrite (ranges, sizeof (struct tr_ipv4_range), ranges_count, out) != ranges_count)
    415416    {
    416       tr_err (_("Couldn't save file \"%1$s\": %2$s"), b->filename, tr_strerror (errno));
     417      tr_logAddError (_("Couldn't save file \"%1$s\": %2$s"), b->filename, tr_strerror (errno));
    417418    }
    418419  else
    419420    {
    420421      char * base = tr_basename (b->filename);
    421       tr_inf (_("Blocklist \"%s\" updated with %zu entries"), base, ranges_count);
     422      tr_logAddInfo (_("Blocklist \"%s\" updated with %zu entries"), base, ranges_count);
    422423      tr_free (base);
    423424    }
  • trunk/libtransmission/cache.c

    r13625 r13868  
    1818#include "cache.h"
    1919#include "inout.h"
     20#include "log.h"
    2021#include "peer-common.h" /* MAX_BLOCK_SIZE */
    2122#include "ptrarray.h"
     
    2829  do \
    2930    { \
    30       if (tr_deepLoggingIsActive ()) \
    31         tr_deepLog (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
     31      if (tr_logGetDeepEnabled ()) \
     32        tr_logAddDeep (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
    3233    } \
    3334  while (0)
     
    260261
    261262  tr_formatter_mem_B (buf, cache->max_bytes, sizeof (buf));
    262   tr_ndbg (MY_NAME, "Maximum cache size set to %s (%d blocks)", buf, cache->max_blocks);
     263  tr_logAddNamedDbg (MY_NAME, "Maximum cache size set to %s (%d blocks)", buf, cache->max_blocks);
    263264
    264265  return cacheTrim (cache);
  • trunk/libtransmission/crypto.c

    r13863 r13868  
    2727#include "transmission.h"
    2828#include "crypto.h"
     29#include "log.h"
    2930#include "utils.h"
    3031
     
    8485#define logErrorFromSSL(...) \
    8586  do { \
    86     if (tr_msgLoggingIsActive (TR_MSG_ERR)) { \
     87    if (tr_logLevelIsActive (TR_LOG_ERROR)) { \
    8788      char buf[512]; \
    8889      ERR_error_string_n (ERR_get_error (), buf, sizeof (buf)); \
    89       tr_msg (__FILE__, __LINE__, TR_MSG_ERR, MY_NAME, "%s", buf); \
     90      tr_logAddMessage (__FILE__, __LINE__, TR_LOG_ERROR, MY_NAME, "%s", buf); \
    9091    } \
    9192  } while (0)
  • trunk/libtransmission/fdlimit.c

    r13803 r13868  
    4444#include "transmission.h"
    4545#include "fdlimit.h"
    46 #include "net.h"
     46#include "log.h"
    4747#include "session.h"
    4848#include "torrent.h" /* tr_isTorrent () */
    4949
    5050#define dbgmsg(...) \
    51     do { \
    52         if (tr_deepLoggingIsActive ()) \
    53             tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
    54     } while (0)
     51  do \
     52    { \
     53      if (tr_logGetDeepEnabled ()) \
     54        tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
     55    } \
     56  while (0)
    5557
    5658/***
     
    343345      if (err)
    344346        {
    345           tr_err (_("Couldn't create \"%1$s\": %2$s"), dir, tr_strerror (err));
     347          tr_logAddError (_("Couldn't create \"%1$s\": %2$s"), dir, tr_strerror (err));
    346348          tr_free (dir);
    347349          return err;
     
    354356  if (writable && !alreadyExisted && (allocation == TR_PREALLOCATE_FULL))
    355357    if (preallocate_file_full (filename, file_size))
    356       tr_dbg ("Preallocated file \"%s\"", filename);
     358      tr_logAddDebug ("Preallocated file \"%s\"", filename);
    357359
    358360  /* open the file */
     
    364366    {
    365367      const int err = errno;
    366       tr_err (_("Couldn't open \"%1$s\": %2$s"), filename, tr_strerror (err));
     368      tr_logAddError (_("Couldn't open \"%1$s\": %2$s"), filename, tr_strerror (err));
    367369      return err;
    368370    }
     
    379381        {
    380382          const int err = errno;
    381           tr_err (_("Couldn't truncate \"%1$s\": %2$s"), filename, tr_strerror (err));
     383          tr_logAddError (_("Couldn't truncate \"%1$s\": %2$s"), filename, tr_strerror (err));
    382384          return err;
    383385        }
     
    524526              setrlimit (RLIMIT_NOFILE, &limit);
    525527              getrlimit (RLIMIT_NOFILE, &limit);
    526               tr_inf ("Changed open file limit from %d to %d", old_limit, (int)limit.rlim_cur);
     528              tr_logAddInfo ("Changed open file limit from %d to %d", old_limit, (int)limit.rlim_cur);
    527529            }
    528530        }
     
    666668    if ((s = socket (domain, type, 0)) < 0)
    667669      if (sockerrno != EAFNOSUPPORT)
    668         tr_err (_("Couldn't create socket: %s"), tr_strerror (sockerrno));
     670        tr_logAddError (_("Couldn't create socket: %s"), tr_strerror (sockerrno));
    669671
    670672  if (s > -1)
     
    682684          buf_logged = true;
    683685          getsockopt (s, SOL_SOCKET, SO_SNDBUF, &i, &size);
    684           tr_dbg ("SO_SNDBUF size is %d", i);
     686          tr_logAddDebug ("SO_SNDBUF size is %d", i);
    685687          getsockopt (s, SOL_SOCKET, SO_RCVBUF, &i, &size);
    686           tr_dbg ("SO_RCVBUF size is %d", i);
     688          tr_logAddDebug ("SO_RCVBUF size is %d", i);
    687689        }
    688690    }
  • trunk/libtransmission/handshake.c

    r13702 r13868  
    2222#include "crypto.h"
    2323#include "handshake.h"
     24#include "log.h"
    2425#include "peer-io.h"
    2526#include "peer-mgr.h"
     
    149150#define dbgmsg(handshake, ...) \
    150151  do { \
    151     if (tr_deepLoggingIsActive ()) \
    152       tr_deepLog (__FILE__, __LINE__, tr_peerIoGetAddrStr (handshake->io), __VA_ARGS__); \
     152    if (tr_logGetDeepEnabled ()) \
     153      tr_logAddDeep (__FILE__, __LINE__, tr_peerIoGetAddrStr (handshake->io), __VA_ARGS__); \
    153154  } while (0)
    154155
  • trunk/libtransmission/inout.c

    r13625 r13868  
    2222#include "fdlimit.h"
    2323#include "inout.h"
     24#include "log.h"
    2425#include "peer-common.h" /* MAX_BLOCK_SIZE */
    2526#include "stats.h" /* tr_statsFileCreated () */
     
    100101            {
    101102              err = errno;
    102               tr_torerr (tor, "tr_fdFileCheckout failed for \"%s\": %s",
     103              tr_logAddTorErr (tor, "tr_fdFileCheckout failed for \"%s\": %s",
    103104                         filename, tr_strerror (err));
    104105            }
     
    127128            {
    128129              err = errno;
    129               tr_torerr (tor, "read failed for \"%s\": %s", file->name, tr_strerror (err));
     130              tr_logAddTorErr (tor, "read failed for \"%s\": %s", file->name, tr_strerror (err));
    130131            }
    131132        }
     
    136137            {
    137138              err = errno;
    138               tr_torerr (tor, "write failed for \"%s\": %s", file->name, tr_strerror (err));
     139              tr_logAddTorErr (tor, "write failed for \"%s\": %s", file->name, tr_strerror (err));
    139140            }
    140141        }
  • trunk/libtransmission/libtransmission-test.c

    r13825 r13868  
    229229  tr_variantDictAddBool (&dict, TR_KEY_port_forwarding_enabled, false);
    230230  tr_variantDictAddBool (&dict, TR_KEY_dht_enabled, false);
    231   tr_variantDictAddInt  (&dict, TR_KEY_message_level, verbose ? TR_MSG_DBG : TR_MSG_ERR);
     231  tr_variantDictAddInt  (&dict, TR_KEY_message_level, verbose ? TR_LOG_DEBUG : TR_LOG_ERROR);
    232232  session = tr_sessionInit ("libtransmission-test", sandbox, !verbose, &dict);
    233233
     
    248248{
    249249  tr_sessionClose (session);
    250   tr_freeMessageList (tr_getQueuedMessages ());
     250  tr_logFreeQueue (tr_logGetQueue ());
    251251  session = NULL;
    252252
  • trunk/libtransmission/makemeta.c

    r13865 r13868  
    2727#include "crypto.h" /* tr_sha1 */
    2828#include "fdlimit.h" /* tr_open_file_for_scanning () */
     29#include "log.h"
    2930#include "session.h"
    3031#include "makemeta.h"
     
    6162  if (i)
    6263    {
    63       tr_err (_("Torrent Creator is skipping file \"%s\": %s"),
     64      tr_logAddError (_("Torrent Creator is skipping file \"%s\": %s"),
    6465                buf, tr_strerror (errno));
    6566      tr_free (buf);
  • trunk/libtransmission/metainfo.c

    r13829 r13868  
    2424#include "session.h"
    2525#include "crypto.h" /* tr_sha1 */
     26#include "log.h"
    2627#include "metainfo.h"
    2728#include "platform.h" /* tr_getTorrentDir () */
     
    543544  if (badTag)
    544545    {
    545       tr_nerr (inf->name, _("Invalid metadata entry \"%s\""), badTag);
     546      tr_logAddNamedError (inf->name, _("Invalid metadata entry \"%s\""), badTag);
    546547      tr_metainfoFree (inf);
    547548    }
  • trunk/libtransmission/natpmp.c

    r13631 r13868  
    2222#include "transmission.h"
    2323#include "natpmp_local.h"
     24#include "log.h"
    2425#include "net.h" /* tr_netCloseSocket */
    2526#include "port-forwarding.h"
     
    7071        return;
    7172    if (ret >= 0)
    72         tr_ninf (getKey (), _("%s succeeded (%d)"), func, ret);
     73        tr_logAddNamedInfo (getKey (), _("%s succeeded (%d)"), func, ret);
    7374    else
    74         tr_ndbg (
     75        tr_logAddNamedDbg (
    7576             getKey (),
    7677            "%s failed. Natpmp returned %d (%s); errno is %d (%s)",
     
    139140            char str[128];
    140141            evutil_inet_ntop (AF_INET, &response.pnu.publicaddress.addr, str, sizeof (str));
    141             tr_ninf (getKey (), _("Found public address \"%s\""), str);
     142            tr_logAddNamedInfo (getKey (), _("Found public address \"%s\""), str);
    142143            nat->state = TR_NATPMP_IDLE;
    143144        }
     
    174175            const int private_port = resp.pnu.newportmapping.privateport;
    175176
    176             tr_ninf (getKey (), _("no longer forwarding port %d"), private_port);
     177            tr_logAddNamedInfo (getKey (), _("no longer forwarding port %d"), private_port);
    177178
    178179            if (nat->private_port == private_port)
     
    219220            nat->private_port = resp.pnu.newportmapping.privateport;
    220221            nat->public_port = resp.pnu.newportmapping.mappedpublicport;
    221             tr_ninf (getKey (), _("Port %d forwarded successfully"), nat->private_port);
     222            tr_logAddNamedInfo (getKey (), _("Port %d forwarded successfully"), nat->private_port);
    222223        }
    223224        else if (val != NATPMP_TRYAGAIN)
  • trunk/libtransmission/net.c

    r13631 r13868  
    4747#include "session.h" /* tr_sessionGetPublicAddress () */
    4848#include "tr-utp.h" /* tr_utpSendTo () */
    49 #include "utils.h" /* tr_time (), tr_dbg () */
     49#include "log.h"
     50#include "utils.h" /* tr_time (), tr_logAddDebug () */
    5051
    5152#ifndef IN_MULTICAST
     
    250251        int n = 8192;
    251252        if (setsockopt (s, SOL_SOCKET, SO_RCVBUF, &n, sizeof (n)))
    252             tr_inf ("Unable to set SO_RCVBUF on socket %d: %s", s, tr_strerror (sockerrno));
     253            tr_logAddInfo ("Unable to set SO_RCVBUF on socket %d: %s", s, tr_strerror (sockerrno));
    253254    }
    254255
     
    266267    if (bind (s, (struct sockaddr *) &source_sock, sourcelen))
    267268    {
    268         tr_err (_("Couldn't set source address %s on %d: %s"),
     269        tr_logAddError (_("Couldn't set source address %s on %d: %s"),
    269270                tr_address_to_string (source_addr), s, tr_strerror (errno));
    270271        return -errno;
     
    282283        if ((tmperrno != ENETUNREACH && tmperrno != EHOSTUNREACH)
    283284                || addr->type == TR_AF_INET)
    284             tr_err (_("Couldn't connect socket %d to %s, port %d (errno %d - %s)"),
     285            tr_logAddError (_("Couldn't connect socket %d to %s, port %d (errno %d - %s)"),
    285286                    s, tr_address_to_string (addr), (int)ntohs (port), tmperrno,
    286287                    tr_strerror (tmperrno));
     
    289290    }
    290291
    291     tr_deepLog (__FILE__, __LINE__, NULL, "New OUTGOING connection %d (%s)",
    292                s, tr_peerIoAddrStr (addr, port));
     292    tr_logAddDeep (__FILE__, __LINE__, NULL, "New OUTGOING connection %d (%s)",
     293                   s, tr_peerIoAddrStr (addr, port));
    293294
    294295    return s;
     
    367368                fmt = _("Couldn't bind port %d on %s: %s (%s)");
    368369
    369             tr_err (fmt, port, tr_address_to_string (addr), tr_strerror (err), hint);
     370            tr_logAddError (fmt, port, tr_address_to_string (addr), tr_strerror (err), hint);
    370371        }
    371372        tr_netCloseSocket (fd);
     
    375376
    376377    if (!suppressMsgs)
    377         tr_dbg ("Bound socket %d to port %d on %s", fd, port, tr_address_to_string (addr));
     378        tr_logAddDebug ("Bound socket %d to port %d on %s", fd, port, tr_address_to_string (addr));
    378379
    379380    if (listen (fd, 128) == -1) {
  • trunk/libtransmission/peer-io.c

    r13667 r13868  
    2525#include "bandwidth.h"
    2626#include "crypto.h"
     27#include "log.h"
    2728#include "net.h"
    2829#include "peer-common.h" /* MAX_BLOCK_SIZE */
     
    7374
    7475#define dbgmsg(io, ...) \
    75     do { \
    76         if (tr_deepLoggingIsActive ()) \
    77             tr_deepLog (__FILE__, __LINE__, tr_peerIoGetAddrStr (io), __VA_ARGS__); \
    78     } while (0)
     76  do \
     77    { \
     78      if (tr_logGetDeepEnabled ()) \
     79        tr_logAddDeep (__FILE__, __LINE__, tr_peerIoGetAddrStr (io), __VA_ARGS__); \
     80    } \
     81  while (0)
    7982
    8083/**
     
    398401
    399402        if (rc < 0)
    400             tr_ninf ("Net", "Can't set congestion control algorithm '%s': %s",
     403            tr_logAddNamedInfo ("Net", "Can't set congestion control algorithm '%s': %s",
    401404                     algorithm, tr_strerror (errno));
    402405    }
     
    417420
    418421    if (rc < 0) {
    419         tr_nerr ("UTP", "On read evbuffer_add");
     422        tr_logAddNamedError ("UTP", "On read evbuffer_add");
    420423        return;
    421424    }
     
    436439    assert (rc == (int)buflen); /* if this fails, we've corrupted our bookkeeping somewhere */
    437440    if (rc < (long)buflen) {
    438         tr_nerr ("UTP", "Short write: %d < %ld", rc, (long)buflen);
     441        tr_logAddNamedError ("UTP", "Short write: %d < %ld", rc, (long)buflen);
    439442    }
    440443
     
    485488            io->gotError (io, BEV_EVENT_EOF, io->userData);
    486489    } else if (state == UTP_STATE_DESTROYING) {
    487         tr_nerr ("UTP", "Impossible state UTP_STATE_DESTROYING");
     490        tr_logAddNamedError ("UTP", "Impossible state UTP_STATE_DESTROYING");
    488491        return;
    489492    } else {
    490         tr_nerr ("UTP", "Unknown state %d", state);
     493        tr_logAddNamedError ("UTP", "Unknown state %d", state);
    491494    }
    492495}
     
    536539{
    537540    /* This cannot happen, as far as I'm aware. */
    538     tr_nerr ("UTP", "On_read called on closed socket");
     541    tr_logAddNamedError ("UTP", "On_read called on closed socket");
    539542
    540543}
     
    545548    /* This can very well happen if we've shut down a peer connection that
    546549       had unflushed buffers.  Complain and send zeroes. */
    547     tr_ndbg ("UTP", "On_write called on closed socket");
     550    tr_logAddNamedDbg ("UTP", "On_write called on closed socket");
    548551    memset (buf, 0, buflen);
    549552}
  • trunk/libtransmission/peer-mgr.c

    r13863 r13868  
    3030#include "crypto.h"
    3131#include "handshake.h"
     32#include "log.h"
    3233#include "net.h"
    3334#include "peer-io.h"
     
    238239  do \
    239240    { \
    240       if (tr_deepLoggingIsActive ()) \
    241         tr_deepLog (__FILE__, __LINE__, tr_torrentName (t->tor), __VA_ARGS__); \
     241      if (tr_logGetDeepEnabled ()) \
     242        tr_logAddDeep (__FILE__, __LINE__, tr_torrentName (t->tor), __VA_ARGS__); \
    242243    } \
    243244  while (0)
     
    246247  do \
    247248    { \
    248       if (tr_deepLoggingIsActive ()) \
    249         tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
     249      if (tr_logGetDeepEnabled ()) \
     250        tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
    250251    } \
    251252  while (0)
     
    18061807                    if (!ok)
    18071808                    {
    1808                         tr_torerr (tor, _("Piece %lu, which was just downloaded, failed its checksum test"),
     1809                        tr_logAddTorErr (tor, _("Piece %lu, which was just downloaded, failed its checksum test"),
    18091810                                 (unsigned long)p);
    18101811                    }
     
    20922093    if (tr_sessionIsAddressBlocked (session, addr))
    20932094    {
    2094         tr_dbg ("Banned IP address \"%s\" tried to connect to us", tr_address_to_string (addr));
     2095        tr_logAddDebug ("Banned IP address \"%s\" tried to connect to us", tr_address_to_string (addr));
    20952096        if (socket >= 0)
    20962097            tr_netClose (session, socket);
  • trunk/libtransmission/peer-msgs.c

    r13782 r13868  
    2525#include "completion.h"
    2626#include "crypto.h" /* tr_sha1 () */
     27#include "log.h"
    2728#include "peer-io.h"
    2829#include "peer-mgr.h"
     
    235236         const char * fmt, ...)
    236237{
    237     FILE * fp = tr_getLog ();
     238    FILE * fp = tr_logGetFile ();
    238239
    239240    if (fp)
     
    246247
    247248        evbuffer_add_printf (buf, "[%s] %s - %s [%s]: ",
    248                              tr_getLogTimeStr (timestr, sizeof (timestr)),
     249                             tr_logGetTimeStr (timestr, sizeof (timestr)),
    249250                             tr_torrentName (msgs->torrent),
    250251                             tr_peerIoGetAddrStr (msgs->peer->io),
     
    266267  do \
    267268    { \
    268       if (tr_deepLoggingIsActive ()) \
     269      if (tr_logGetDeepEnabled ()) \
    269270        myDebug (__FILE__, __LINE__, msgs, __VA_ARGS__); \
    270271    } \
  • trunk/libtransmission/platform.c

    r13754 r13868  
    7676#include "session.h"
    7777#include "list.h"
     78#include "log.h"
    7879#include "platform.h"
    7980#include "utils.h"
     
    379380
    380381          if (count)
    381             tr_inf (_("Migrated %1$d files from \"%2$s\" to \"%3$s\""), count, oldDir, newDir);
     382            tr_logAddInfo (_("Migrated %1$d files from \"%2$s\" to \"%3$s\""), count, oldDir, newDir);
    382383
    383384          closedir (dirh);
     
    556557  char * tmp = tr_buildPath (path, "index.html", NULL);
    557558  const int ret = !stat (tmp, &sb);
    558   tr_inf (_("Searching for web interface file \"%s\""), tmp);
     559  tr_logAddInfo (_("Searching for web interface file \"%s\""), tmp);
    559560  tr_free (tmp);
    560561
  • trunk/libtransmission/port-forwarding.c

    r13863 r13868  
    2020#include "transmission.h"
    2121#include "natpmp_local.h"
     22#include "log.h"
    2223#include "net.h"
    2324#include "peer-mgr.h"
     
    9091
    9192  if (newStatus != oldStatus)
    92     tr_ninf (getKey (), _("State changed from \"%1$s\" to \"%2$s\""),
     93    tr_logAddNamedInfo (getKey (), _("State changed from \"%1$s\" to \"%2$s\""),
    9394             getNatStateStr (oldStatus),
    9495             getNatStateStr (newStatus));
     
    180181stop_forwarding (tr_shared * s)
    181182{
    182   tr_ninf (getKey (), "%s", _("Stopped"));
     183  tr_logAddNamedInfo (getKey (), "%s", _("Stopped"));
    183184  natPulse (s, false);
    184185
  • trunk/libtransmission/resume.c

    r13829 r13868  
    1717#include "transmission.h"
    1818#include "completion.h"
     19#include "log.h"
    1920#include "metainfo.h" /* tr_metainfoGetBasename () */
    2021#include "peer-mgr.h" /* pex */
     
    9596    {
    9697        const int numAdded = addPeers (tor, str, len);
    97         tr_tordbg (tor, "Loaded %d IPv4 peers from resume file", numAdded);
     98        tr_logAddTorDbg (tor, "Loaded %d IPv4 peers from resume file", numAdded);
    9899        ret = TR_FR_PEERS;
    99100    }
     
    102103    {
    103104        const int numAdded = addPeers (tor, str, len);
    104         tr_tordbg (tor, "Loaded %d IPv6 peers from resume file", numAdded);
     105        tr_logAddTorDbg (tor, "Loaded %d IPv6 peers from resume file", numAdded);
    105106        ret = TR_FR_PEERS;
    106107    }
     
    152153        {
    153154            tr_torrentInitFileDLs (tor, dnd, dndCount, false);
    154             tr_tordbg (tor, "Resume file found %d files listed as dnd",
     155            tr_logAddTorDbg (tor, "Resume file found %d files listed as dnd",
    155156                       dndCount);
    156157        }
     
    158159        {
    159160            tr_torrentInitFileDLs (tor, dl, dlCount, true);
    160             tr_tordbg (tor,
     161            tr_logAddTorDbg (tor,
    161162                       "Resume file found %d files marked for download",
    162163                       dlCount);
     
    169170    else
    170171    {
    171         tr_tordbg (
     172        tr_logAddTorDbg (
    172173            tor,
    173174            "Couldn't load DND flags. DND list (%p) has %zu children; torrent has %d files",
     
    630631
    631632        if (err != NULL)
    632             tr_tordbg (tor, "Torrent needs to be verified - %s", err);
     633            tr_logAddTorDbg (tor, "Torrent needs to be verified - %s", err);
    633634        else
    634635            tr_cpBlockInit (&tor->completion, &blocks);
     
    709710    if (tr_variantFromFile (&top, TR_VARIANT_FMT_BENC, filename))
    710711    {
    711         tr_tordbg (tor, "Couldn't read \"%s\"", filename);
     712        tr_logAddTorDbg (tor, "Couldn't read \"%s\"", filename);
    712713
    713714        tr_free (filename);
     
    715716    }
    716717
    717     tr_tordbg (tor, "Read resume file \"%s\"", filename);
     718    tr_logAddTorDbg (tor, "Read resume file \"%s\"", filename);
    718719
    719720    if ((fieldsToLoad & TR_FR_CORRUPT)
  • trunk/libtransmission/rpc-server.c

    r13683 r13868  
    3131#include "fdlimit.h"
    3232#include "list.h"
     33#include "log.h"
    3334#include "net.h"
    3435#include "platform.h" /* tr_getWebClientDir () */
     
    7980#define dbgmsg(...) \
    8081    do { \
    81         if (tr_deepLoggingIsActive ()) \
    82             tr_deepLog (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
     82        if (tr_logGetDeepEnabled ()) \
     83            tr_logAddDeep (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
    8384    } while (0)
    8485
     
    799800        tr_list_append (&server->whitelist, token);
    800801        if (strcspn (token, "+-") < len)
    801             tr_ninf (MY_NAME, "Adding address to whitelist: %s (And it has a '+' or '-'!  Are you using an old ACL by mistake?)", token);
     802            tr_logAddNamedInfo (MY_NAME, "Adding address to whitelist: %s (And it has a '+' or '-'!  Are you using an old ACL by mistake?)", token);
    802803        else
    803             tr_ninf (MY_NAME, "Adding address to whitelist: %s", token);
     804            tr_logAddNamedInfo (MY_NAME, "Adding address to whitelist: %s", token);
    804805
    805806        if (walk[len]=='\0')
     
    923924{
    924925  const char * str = tr_quark_get_string (q, NULL);
    925   tr_nerr (MY_NAME, _("Couldn't find settings key \"%s\""), str);
     926  tr_logAddNamedError (MY_NAME, _("Couldn't find settings key \"%s\""), str);
    926927}
    927928
     
    992993        address = tr_inaddr_any;
    993994    } else if (!tr_address_from_string (&address, str)) {
    994         tr_nerr (MY_NAME, _("%s is not a valid address"), str);
     995        tr_logAddNamedError (MY_NAME, _("%s is not a valid address"), str);
    995996        address = tr_inaddr_any;
    996997    } else if (address.type != TR_AF_INET) {
    997         tr_nerr (MY_NAME, _("%s is not an IPv4 address. RPC listeners must be IPv4"), str);
     998        tr_logAddNamedError (MY_NAME, _("%s is not an IPv4 address. RPC listeners must be IPv4"), str);
    998999        address = tr_inaddr_any;
    9991000    }
     
    10021003    if (s->isEnabled)
    10031004    {
    1004         tr_ninf (MY_NAME, _("Serving RPC and Web requests on port 127.0.0.1:%d%s"), (int) s->port, s->url);
     1005        tr_logAddNamedInfo (MY_NAME, _("Serving RPC and Web requests on port 127.0.0.1:%d%s"), (int) s->port, s->url);
    10051006        tr_runInEventThread (session, startServer, s);
    10061007
    10071008        if (s->isWhitelistEnabled)
    1008             tr_ninf (MY_NAME, "%s", _("Whitelist enabled"));
     1009            tr_logAddNamedInfo (MY_NAME, "%s", _("Whitelist enabled"));
    10091010
    10101011        if (s->isPasswordEnabled)
    1011             tr_ninf (MY_NAME, "%s", _("Password required"));
     1012            tr_logAddNamedInfo (MY_NAME, "%s", _("Password required"));
    10121013    }
    10131014
  • trunk/libtransmission/rpcimpl.c

    r13815 r13868  
    2727#include "completion.h"
    2828#include "fdlimit.h"
     29#include "log.h"
    2930#include "rpcimpl.h"
    3031#include "session.h"
     
    5051#else
    5152#define dbgmsg(...) \
    52     do { \
    53         if (tr_deepLoggingIsActive ()) \
    54             tr_deepLog (__FILE__, __LINE__, "RPC", __VA_ARGS__); \
    55     } while (0)
     53  do \
     54    { \
     55      if (tr_logGetDeepEnabled ()) \
     56        tr_logAddDeep (__FILE__, __LINE__, "RPC", __VA_ARGS__); \
     57    } \
     58  while (0)
    5659#endif
    5760
     
    14801483
    14811484        if (*result)
    1482             tr_err ("%s", result);
     1485            tr_logAddError ("%s", result);
    14831486        else {
    14841487            /* feed it to the session and give the client a response */
  • trunk/libtransmission/session.c

    r13847 r13868  
    3636#include "fdlimit.h"
    3737#include "list.h"
     38#include "log.h"
    3839#include "net.h"
    3940#include "peer-io.h"
     
    7273  do \
    7374    { \
    74       if (tr_deepLoggingIsActive ()) \
    75         tr_deepLog (__FILE__, __LINE__, NULL, __VA_ARGS__); \
     75      if (tr_logGetDeepEnabled ()) \
     76        tr_logAddDeep (__FILE__, __LINE__, NULL, __VA_ARGS__); \
    7677    } \
    7778  while (0)
     
    186187    clientSocket = tr_netAccept (session, fd, &clientAddr, &clientPort);
    187188    if (clientSocket > 0) {
    188         tr_deepLog (__FILE__, __LINE__, NULL, "new incoming connection %d (%s)",
    189                    clientSocket, tr_peerIoAddrStr (&clientAddr, clientPort));
     189        tr_logAddDeep (__FILE__, __LINE__, NULL, "new incoming connection %d (%s)",
     190                       clientSocket, tr_peerIoAddrStr (&clientAddr, clientPort));
    190191        tr_peerMgrAddIncoming (session->peerMgr, &clientAddr, clientPort,
    191192                               clientSocket, NULL);
     
    323324    tr_variantDictAddStr  (d, TR_KEY_incomplete_dir,                  tr_getDefaultDownloadDir ());
    324325    tr_variantDictAddBool (d, TR_KEY_incomplete_dir_enabled,          false);
    325     tr_variantDictAddInt  (d, TR_KEY_message_level,                   TR_MSG_INF);
     326    tr_variantDictAddInt  (d, TR_KEY_message_level,                   TR_LOG_INFO);
    326327    tr_variantDictAddInt  (d, TR_KEY_download_queue_size,             5);
    327328    tr_variantDictAddBool (d, TR_KEY_download_queue_enabled,          true);
     
    395396  tr_variantDictAddStr  (d, TR_KEY_incomplete_dir,               tr_sessionGetIncompleteDir (s));
    396397  tr_variantDictAddBool (d, TR_KEY_incomplete_dir_enabled,       tr_sessionIsIncompleteDirEnabled (s));
    397   tr_variantDictAddInt  (d, TR_KEY_message_level,                tr_getMessageLevel ());
     398  tr_variantDictAddInt  (d, TR_KEY_message_level,                tr_logGetLevel ());
    398399  tr_variantDictAddInt  (d, TR_KEY_peer_limit_global,            s->peerLimit);
    399400  tr_variantDictAddInt  (d, TR_KEY_peer_limit_per_torrent,       s->peerLimitPerTorrent);
     
    544545
    545546    if (tr_cacheFlushDone (session->cache))
    546         tr_err ("Error while flushing completed pieces from cache");
     547        tr_logAddError ("Error while flushing completed pieces from cache");
    547548
    548549    while ((tor = tr_torrentNext (session, tor)))
     
    597598    /* nice to start logging at the very beginning */
    598599    if (tr_variantDictFindInt (clientSettings, TR_KEY_message_level, &i))
    599         tr_setMessageLevel (i);
     600        tr_logSetLevel (i);
    600601
    601602    /* start the libtransmission thread */
     
    695696#endif
    696697
    697     tr_setMessageQueuing (data->messageQueuingEnabled);
     698    tr_logSetQueueEnabled (data->messageQueuingEnabled);
    698699
    699700    tr_setConfigDir (session, data->configDir);
     
    723724    /* first %s is the application name
    724725       second %s is the version number */
    725     tr_inf (_("%s %s started"), TR_NAME, LONG_VERSION_STRING);
     726    tr_logAddInfo (_("%s %s started"), TR_NAME, LONG_VERSION_STRING);
    726727
    727728    tr_statsInit (session);
     
    764765
    765766    if (tr_variantDictFindInt (settings, TR_KEY_message_level, &i))
    766         tr_setMessageLevel (i);
     767        tr_logSetLevel (i);
    767768
    768769    if (tr_variantDictFindInt (settings, TR_KEY_umask, &i)) {
     
    13721373    if (!alreadySwitched)
    13731374    {
    1374         tr_inf ("Time to turn %s turtle mode!", (enabled?"on":"off"));
     1375        tr_logAddInfo ("Time to turn %s turtle mode!", (enabled?"on":"off"));
    13751376        t->autoTurtleState = newAutoTurtleState;
    13761377        useAltSpeed (s, t, enabled, false);
     
    14941495userPokedTheClock (tr_session * s, struct tr_turtle_info * t)
    14951496{
    1496     tr_dbg ("Refreshing the turtle mode clock due to user changes");
     1497    tr_logAddDebug ("Refreshing the turtle mode clock due to user changes");
    14971498
    14981499    t->autoTurtleState = TR_AUTO_SWITCH_UNUSED;
     
    19481949
    19491950    if (n)
    1950         tr_inf (_("Loaded %d torrents"), n);
     1951        tr_logAddInfo (_("Loaded %d torrents"), n);
    19511952
    19521953    if (data->setmeCount)
     
    24442445
    24452446    session->metainfoLookup = lookup;
    2446     tr_dbg ("Found %d torrents in \"%s\"", n, dirname);
     2447    tr_logAddDebug ("Found %d torrents in \"%s\"", n, dirname);
    24472448}
    24482449
  • trunk/libtransmission/stats.c

    r13683 r13868  
    1313#include "transmission.h"
    1414#include "session.h"
     15#include "log.h"
    1516#include "platform.h" /* tr_sessionGetConfigDir () */
    1617#include "stats.h"
     
    9697
    9798  filename = getFilename (session);
    98   tr_deepLog (__FILE__, __LINE__, NULL, "Saving stats to \"%s\"", filename);
     99  tr_logAddDeep (__FILE__, __LINE__, NULL, "Saving stats to \"%s\"", filename);
    99100  tr_variantToFile (&top, TR_VARIANT_FMT_JSON, filename);
    100101
  • trunk/libtransmission/torrent-magnet.c

    r13829 r13868  
    1919#include "transmission.h"
    2020#include "crypto.h" /* tr_sha1 () */
     21#include "log.h"
    2122#include "magnet.h"
    2223#include "metainfo.h"
     
    3132  do \
    3233    { \
    33       if (tr_deepLoggingIsActive ()) \
    34         tr_deepLog (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
     34      if (tr_logGetDeepEnabled ()) \
     35        tr_logAddDeep (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
    3536    } \
    3637  while (0)
     
    315316          dbgmsg (tor, "metadata error; trying again. %d pieces left", n);
    316317
    317           tr_err ("magnet status: checksum passed %d, metainfo parsed %d",
     318          tr_logAddError ("magnet status: checksum passed %d, metainfo parsed %d",
    318319                  (int)checksumPassed, (int)metainfoParsed);
    319320        }
  • trunk/libtransmission/torrent.c

    r13856 r13868  
    4141#include "fdlimit.h" /* tr_fdTorrentClose */
    4242#include "inout.h" /* tr_ioTestPiece () */
     43#include "log.h"
    4344#include "magnet.h"
    4445#include "metainfo.h"
     
    6364  do \
    6465    { \
    65       if (tr_deepLoggingIsActive ()) \
    66         tr_deepLog (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
     66      if (tr_logGetDeepEnabled ()) \
     67        tr_logAddDeep (__FILE__, __LINE__, tr_torrentName (tor), __VA_ARGS__); \
    6768    } \
    6869  while (0)
     
    456457    if (tr_torrentIsSeedRatioDone (tor))
    457458    {
    458         tr_torinf (tor, "%s", "Seed ratio reached; pausing torrent");
     459        tr_logAddTorInfo (tor, "%s", "Seed ratio reached; pausing torrent");
    459460
    460461        tor->isStopping = true;
     
    467468    else if (tr_torrentIsSeedIdleLimitDone (tor))
    468469    {
    469         tr_torinf (tor, "%s", "Seeding idle limit reached; pausing torrent");
     470        tr_logAddTorInfo (tor, "%s", "Seeding idle limit reached; pausing torrent");
    470471
    471472        tor->isStopping = true;
     
    495496    va_end (ap);
    496497
    497     tr_torerr (tor, "%s", tor->errorString);
     498    tr_logAddTorErr (tor, "%s", tor->errorString);
    498499
    499500    if (tor->isRunning)
     
    521522
    522523             if (allAreSeeds)
    523                 tr_tordbg (tor, "Got %zu seeds from tracker", event->pexCount);
     524                tr_logAddTorDbg (tor, "Got %zu seeds from tracker", event->pexCount);
    524525            else
    525                 tr_tordbg (tor, "Got %zu peers from tracker", event->pexCount);
     526                tr_logAddTorDbg (tor, "Got %zu peers from tracker", event->pexCount);
    526527
    527528            for (i = 0; i < event->pexCount; ++i)
     
    532533
    533534        case TR_TRACKER_WARNING:
    534             tr_torerr (tor, _("Tracker warning: \"%s\""), event->text);
     535            tr_logAddTorErr (tor, _("Tracker warning: \"%s\""), event->text);
    535536            tor->error = TR_STAT_TRACKER_WARNING;
    536537            tr_strlcpy (tor->errorTracker, event->tracker, sizeof (tor->errorTracker));
     
    539540
    540541        case TR_TRACKER_ERROR:
    541             tr_torerr (tor, _("Tracker error: \"%s\""), event->text);
     542            tr_logAddTorErr (tor, _("Tracker error: \"%s\""), event->text);
    542543            tor->error = TR_STAT_TRACKER_ERROR;
    543544            tr_strlcpy (tor->errorTracker, event->tracker, sizeof (tor->errorTracker));
     
    16511652    /* allow finished torrents to be resumed */
    16521653    if (tr_torrentIsSeedRatioDone (tor)) {
    1653         tr_torinf (tor, "%s", _("Restarted manually -- disabling its seed ratio"));
     1654        tr_logAddTorInfo (tor, "%s", _("Restarted manually -- disabling its seed ratio"));
    16541655        tr_torrentSetRatioMode (tor, TR_RATIOLIMIT_UNLIMITED);
    16551656    }
     
    17561757{
    17571758  tr_torrent * tor = vtor;
    1758   tr_torinf (tor, "%s", "Pausing");
     1759  tr_logAddTorInfo (tor, "%s", "Pausing");
    17591760
    17601761  assert (tr_isTorrent (tor));
     
    18061807    tr_variantDictAddInt (d, TR_KEY_date, tr_time ());
    18071808
    1808     tr_torinf (tor, "%s", _("Removing torrent"));
     1809    tr_logAddTorInfo (tor, "%s", _("Removing torrent"));
    18091810
    18101811    stopTorrent (tor);
     
    19931994            NULL };
    19941995
    1995         tr_torinf (tor, "Calling script \"%s\"", script);
     1996        tr_logAddTorInfo (tor, "Calling script \"%s\"", script);
    19961997
    19971998#ifdef WIN32
    19981999        if (_spawnvpe (_P_NOWAIT, script, (const char*)cmd, env) == -1)
    1999           tr_torerr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
     2000          tr_logAddTorErr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
    20002001#else
    20012002        signal (SIGCHLD, onSigCHLD);
     
    20072008
    20082009            if (execvp (script, cmd) == -1)
    2009               tr_torerr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
     2010              tr_logAddTorErr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
    20102011
    20112012            _exit (0);
     
    20332034
    20342035      if (recentChange)
    2035         tr_torinf (tor, _("State changed from \"%1$s\" to \"%2$s\""),
     2036        tr_logAddTorInfo (tor, _("State changed from \"%1$s\" to \"%2$s\""),
    20362037                   getCompletionString (tor->completeness),
    20372038                   getCompletionString (completeness));
     
    23572358        err = 5;
    23582359
    2359     if (err) tr_tordbg (tor, "index %lu offset %lu length %lu err %d\n",
     2360    if (err) tr_logAddTorDbg (tor, "index %lu offset %lu length %lu err %d\n",
    23602361                            (unsigned long)index,
    23612362                            (unsigned long)offset,
     
    28922893    assert (tr_isTorrent (tor));
    28932894
    2894     tr_dbg ("Moving \"%s\" location from currentDir \"%s\" to \"%s\"",
     2895    tr_logAddDebug ("Moving \"%s\" location from currentDir \"%s\" to \"%s\"",
    28952896            tr_torrentName (tor), tor->currentDir, location);
    28962897
     
    29172918                char * newpath = tr_buildPath (location, sub, NULL);
    29182919
    2919                 tr_dbg ("Found file #%d: %s", (int)i, oldpath);
     2920                tr_logAddDebug ("Found file #%d: %s", (int)i, oldpath);
    29202921
    29212922                if (do_move && !tr_is_same_file (oldpath, newpath))
     
    29232924                    bool renamed = false;
    29242925                    errno = 0;
    2925                     tr_torinf (tor, "moving \"%s\" to \"%s\"", oldpath, newpath);
     2926                    tr_logAddTorInfo (tor, "moving \"%s\" to \"%s\"", oldpath, newpath);
    29262927                    if (tr_moveFile (oldpath, newpath, &renamed))
    29272928                    {
    29282929                        err = true;
    2929                         tr_torerr (tor, "error moving \"%s\" to \"%s\": %s",
     2930                        tr_logAddTorErr (tor, "error moving \"%s\" to \"%s\": %s",
    29302931                                        oldpath, newpath, tr_strerror (errno));
    29312932                    }
     
    30303031
    30313032            if (rename (oldpath, newpath))
    3032                 tr_torerr (tor, "Error moving \"%s\" to \"%s\": %s", oldpath, newpath, tr_strerror (errno));
     3033                tr_logAddTorErr (tor, "Error moving \"%s\" to \"%s\": %s", oldpath, newpath, tr_strerror (errno));
    30333034
    30343035            tr_free (newpath);
  • trunk/libtransmission/tr-dht.c

    r13683 r13868  
    5252#include "transmission.h"
    5353#include "crypto.h"
     54#include "log.h"
    5455#include "net.h"
    5556#include "peer-mgr.h" /* tr_peerMgrCompactToPex () */
     
    123124    rc = getaddrinfo (name, pp, &hints, &info);
    124125    if (rc != 0) {
    125         tr_nerr ("DHT", "%s:%s: %s", name, pp, gai_strerror (rc));
     126        tr_logAddNamedError ("DHT", "%s:%s: %s", name, pp, gai_strerror (rc));
    126127        return;
    127128    }
     
    151152
    152153    if (cl->len > 0)
    153         tr_ninf ("DHT", "Bootstrapping from %d IPv4 nodes", num);
     154        tr_logAddNamedInfo ("DHT", "Bootstrapping from %d IPv4 nodes", num);
    154155
    155156    if (cl->len6 > 0)
    156         tr_ninf ("DHT", "Bootstrapping from %d IPv6 nodes", num6);
     157        tr_logAddNamedInfo ("DHT", "Bootstrapping from %d IPv6 nodes", num6);
    157158
    158159
     
    203204            f = fopen (bootstrap_file, "rb");
    204205        if (f != NULL) {
    205             tr_ninf ("DHT", "Attempting manual bootstrap");
     206            tr_logAddNamedInfo ("DHT", "Attempting manual bootstrap");
    206207            for (;;) {
    207208                char buf[201];
     
    217218                    port = atoi (p + 1);
    218219                if (p == NULL || port <= 0 || port >= 0x10000) {
    219                     tr_nerr ("DHT", "Couldn't parse %s", buf);
     220                    tr_logAddNamedError ("DHT", "Couldn't parse %s", buf);
    220221                    continue;
    221222                }
     
    244245                break;
    245246            if (i == 0)
    246                 tr_ninf ("DHT",
     247                tr_logAddNamedInfo ("DHT",
    247248                        "Attempting bootstrap from dht.transmissionbt.com");
    248249            bootstrap_from_name ("dht.transmissionbt.com", 6881,
     
    256257        tr_free (cl->nodes6);
    257258    tr_free (closure);
    258     tr_ndbg ("DHT", "Finished bootstrapping");
     259    tr_logAddNamedDbg ("DHT", "Finished bootstrapping");
    259260}
    260261
     
    274275        return -1;
    275276
    276     tr_ndbg ("DHT", "Initializing DHT");
     277    tr_logAddNamedDbg ("DHT", "Initializing DHT");
    277278
    278279    if (getenv ("TR_DHT_VERBOSE") != NULL)
     
    303304
    304305    if (have_id)
    305         tr_ninf ("DHT", "Reusing old id");
     306        tr_logAddNamedInfo ("DHT", "Reusing old id");
    306307    else {
    307308        /* Note that DHT ids need to be distributed uniformly,
    308309         * so it should be something truly random. */
    309         tr_ninf ("DHT", "Generating new id");
     310        tr_logAddNamedInfo ("DHT", "Generating new id");
    310311        tr_cryptoRandBuf (myid, 20);
    311312    }
     
    328329    tr_timerAdd (dht_timer, 0, tr_cryptoWeakRandInt (1000000));
    329330
    330     tr_ndbg ("DHT", "DHT initialized");
     331    tr_logAddNamedDbg ("DHT", "DHT initialized");
    331332
    332333    return 1;
    333334
    334335 fail:
    335     tr_ndbg ("DHT", "DHT initialization failed (errno = %d)", errno);
     336    tr_logAddNamedDbg ("DHT", "DHT initialization failed (errno = %d)", errno);
    336337    session = NULL;
    337338    return -1;
     
    344345        return;
    345346
    346     tr_ndbg ("DHT", "Uninitializing DHT");
     347    tr_logAddNamedDbg ("DHT", "Uninitializing DHT");
    347348
    348349    if (dht_timer != NULL) {
     
    355356    if ((tr_dhtStatus (ss, AF_INET, NULL) < TR_DHT_FIREWALLED) &&
    356357      (tr_dhtStatus (ss, AF_INET6, NULL) < TR_DHT_FIREWALLED)) {
    357         tr_ninf ("DHT", "Not saving nodes, DHT not ready");
     358        tr_logAddNamedInfo ("DHT", "Not saving nodes, DHT not ready");
    358359    } else {
    359360        tr_variant benc;
     
    365366        int n = dht_get_nodes (sins, &num, sins6, &num6);
    366367
    367         tr_ninf ("DHT", "Saving %d (%d + %d) nodes", n, num, num6);
     368        tr_logAddNamedInfo ("DHT", "Saving %d (%d + %d) nodes", n, num, num6);
    368369
    369370        j = 0;
     
    392393
    393394    dht_uninit ();
    394     tr_ndbg ("DHT", "Done uninitializing DHT");
     395    tr_logAddNamedDbg ("DHT", "Done uninitializing DHT");
    395396
    396397    session = NULL;
     
    531532                tr_peerMgrAddPex (tor, TR_PEER_FROM_DHT, pex+i, -1);
    532533            tr_free (pex);
    533             tr_tordbg (tor, "Learned %d %s peers from DHT",
     534            tr_logAddTorDbg (tor, "Learned %d %s peers from DHT",
    534535                    (int)n,
    535536                      event == DHT_EVENT_VALUES6 ? "IPv6" : "IPv4");
     
    541542        if (tor) {
    542543            if (event == DHT_EVENT_SEARCH_DONE) {
    543                 tr_torinf (tor, "%s", "IPv4 DHT announce done");
     544                tr_logAddTorInfo (tor, "%s", "IPv4 DHT announce done");
    544545                tor->dhtAnnounceInProgress = 0;
    545546            } else {
    546                 tr_torinf (tor, "%s", "IPv6 DHT announce done");
     547                tr_logAddTorInfo (tor, "%s", "IPv6 DHT announce done");
    547548                tor->dhtAnnounce6InProgress = 0;
    548549            }
     
    571572                         af, callback, NULL);
    572573        if (rc >= 1) {
    573             tr_torinf (tor, "Starting %s DHT announce (%s, %d nodes)",
     574            tr_logAddTorInfo (tor, "Starting %s DHT announce (%s, %d nodes)",
    574575                      af == AF_INET6 ? "IPv6" : "IPv4",
    575576                      tr_dhtPrintableStatus (status), numnodes);
     
    580581            ret = 1;
    581582        } else {
    582             tr_torerr (tor, "%s DHT announce failed (%s, %d nodes): %s",
     583            tr_logAddTorErr (tor, "%s DHT announce failed (%s, %d nodes): %s",
    583584                      af == AF_INET6 ? "IPv6" : "IPv4",
    584585                      tr_dhtPrintableStatus (status), numnodes,
     
    586587        }
    587588    } else {
    588         tr_tordbg (tor, "%s DHT not ready (%s, %d nodes)",
     589        tr_logAddTorDbg (tor, "%s DHT not ready (%s, %d nodes)",
    589590                  af == AF_INET6 ? "IPv6" : "IPv4",
    590591                  tr_dhtPrintableStatus (status), numnodes);
     
    644645            tosleep = 0;
    645646        } else {
    646             tr_nerr ("DHT", "dht_periodic failed: %s", tr_strerror (errno));
     647            tr_logAddNamedError ("DHT", "dht_periodic failed: %s", tr_strerror (errno));
    647648            if (errno == EINVAL || errno == EFAULT)
    648649                    abort ();
  • trunk/libtransmission/tr-lpd.c

    r13847 r13868  
    4949/* libT */
    5050#include "transmission.h"
     51#include "log.h"
    5152#include "net.h"
    5253#include "peer-mgr.h" /* tr_peerMgrAddPex () */
     
    281282        return -1;
    282283
    283     tr_ndbg ("LPD", "Initialising Local Peer Discovery");
     284    tr_logAddNamedDbg ("LPD", "Initialising Local Peer Discovery");
    284285
    285286    /* setup datagram socket (receive) */
     
    352353    tr_timerAdd (upkeep_timer, UPKEEP_INTERVAL_SECS, 0);
    353354
    354     tr_ndbg ("LPD", "Local Peer Discovery initialised");
     355    tr_logAddNamedDbg ("LPD", "Local Peer Discovery initialised");
    355356
    356357    return 1;
     
    363364        lpd_socket = lpd_socket2 = -1;
    364365        session = NULL;
    365         tr_ndbg ("LPD", "LPD initialisation failed (errno = %d)", save);
     366        tr_logAddNamedDbg ("LPD", "LPD initialisation failed (errno = %d)", save);
    366367        errno = save;
    367368    }
     
    376377        return;
    377378
    378     tr_ndbg ("LPD", "Uninitialising Local Peer Discovery");
     379    tr_logAddNamedDbg ("LPD", "Uninitialising Local Peer Discovery");
    379380
    380381    event_free (lpd_event);
     
    387388    evutil_closesocket (lpd_socket);
    388389    evutil_closesocket (lpd_socket2);
    389     tr_ndbg ("LPD", "Done uninitialising Local Peer Discovery");
     390    tr_logAddNamedDbg ("LPD", "Done uninitialising Local Peer Discovery");
    390391
    391392    session = NULL;
     
    471472    }
    472473
    473     tr_tordbg (t, "LPD announce message away");
     474    tr_logAddTorDbg (t, "LPD announce message away");
    474475
    475476    return true;
     
    532533            /* we found a suitable peer, add it to the torrent */
    533534            tr_peerMgrAddPex (tor, TR_PEER_FROM_LPD, peer, -1);
    534             tr_tordbg (tor, "Learned %d local peer from LPD (%s:%u)",
     535            tr_logAddTorDbg (tor, "Learned %d local peer from LPD (%s:%u)",
    535536                1, tr_address_to_string (&peer->addr), peerPort);
    536537
     
    540541        }
    541542        else
    542             tr_ndbg ("LPD", "Cannot serve torrent #%s", hashString);
     543            tr_logAddNamedDbg ("LPD", "Cannot serve torrent #%s", hashString);
    543544    }
    544545
     
    609610
    610611        if (lpd_unsolicitedMsgCounter < 0)
    611             tr_ninf ("LPD", "Dropped %d announces in the last interval (max. %d "
     612            tr_logAddNamedInfo ("LPD", "Dropped %d announces in the last interval (max. %d "
    612613                     "allowed)", -lpd_unsolicitedMsgCounter, maxAnnounceCap);
    613614
     
    667668        }
    668669
    669         tr_ndbg ("LPD", "Discarded invalid multicast message");
    670     }
    671 }
    672 
     670        tr_logAddNamedDbg ("LPD", "Discarded invalid multicast message");
     671    }
     672}
     673
  • trunk/libtransmission/tr-udp.c

    r13625 r13868  
    3333
    3434#include "transmission.h"
     35#include "log.h"
    3536#include "net.h"
    3637#include "session.h"
     
    5556    rc = setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof (size));
    5657    if (rc < 0)
    57         tr_nerr ("UDP", "Failed to set receive buffer: %s",
     58        tr_logAddNamedError ("UDP", "Failed to set receive buffer: %s",
    5859                tr_strerror (errno));
    5960
     
    6162    rc = setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size));
    6263    if (rc < 0)
    63         tr_nerr ("UDP", "Failed to set send buffer: %s",
     64        tr_logAddNamedError ("UDP", "Failed to set send buffer: %s",
    6465                tr_strerror (errno));
    6566
     
    7475
    7576        if (rbuf < RECV_BUFFER_SIZE) {
    76             tr_nerr ("UDP", "Failed to set receive buffer: requested %d, got %d",
     77            tr_logAddNamedError ("UDP", "Failed to set receive buffer: requested %d, got %d",
    7778                    RECV_BUFFER_SIZE, rbuf);
    7879#ifdef __linux__
    79             tr_ninf ("UDP",
     80            tr_logAddNamedInfo ("UDP",
    8081                    "Please add the line "
    8182                    "\"net.core.rmem_max = %d\" to /etc/sysctl.conf",
     
    8586
    8687        if (sbuf < SEND_BUFFER_SIZE) {
    87             tr_nerr ("UDP", "Failed to set send buffer: requested %d, got %d",
     88            tr_logAddNamedError ("UDP", "Failed to set send buffer: requested %d, got %d",
    8889                    SEND_BUFFER_SIZE, sbuf);
    8990#ifdef __linux__
    90             tr_ninf ("UDP",
     91            tr_logAddNamedInfo ("UDP",
    9192                    "Please add the line "
    9293                    "\"net.core.wmem_max = %d\" to /etc/sysctl.conf",
     
    178179    /* Something went wrong.  It's difficult to recover, so let's simply
    179180       set things up so that we try again next time. */
    180     tr_nerr ("UDP", "Couldn't rebind IPv6 socket");
     181    tr_logAddNamedError ("UDP", "Couldn't rebind IPv6 socket");
    181182    if (s >= 0)
    182183        close (s);
     
    220221            rc = tau_handle_message (ss, buf, rc);
    221222            if (!rc)
    222                 tr_ndbg ("UDP", "Couldn't parse UDP tracker packet.");
     223                tr_logAddNamedDbg ("UDP", "Couldn't parse UDP tracker packet.");
    223224        } else {
    224225            if (tr_sessionIsUTPEnabled (ss)) {
    225226                rc = tr_utpPacket (buf, rc, (struct sockaddr*)&from, fromlen, ss);
    226227                if (!rc)
    227                     tr_ndbg ("UDP", "Unexpected UDP packet");
     228                    tr_logAddNamedDbg ("UDP", "Unexpected UDP packet");
    228229            }
    229230        }
     
    248249    ss->udp_socket = socket (PF_INET, SOCK_DGRAM, 0);
    249250    if (ss->udp_socket < 0) {
    250         tr_nerr ("UDP", "Couldn't create IPv4 socket");
     251        tr_logAddNamedError ("UDP", "Couldn't create IPv4 socket");
    251252        goto ipv6;
    252253    }
     
    260261    rc = bind (ss->udp_socket, (struct sockaddr*)&sin, sizeof (sin));
    261262    if (rc < 0) {
    262         tr_nerr ("UDP", "Couldn't bind IPv4 socket");
     263        tr_logAddNamedError ("UDP", "Couldn't bind IPv4 socket");
    263264        close (ss->udp_socket);
    264265        ss->udp_socket = -1;
     
    269270                  event_callback, ss);
    270271    if (ss->udp_event == NULL)
    271         tr_nerr ("UDP", "Couldn't allocate IPv4 event");
     272        tr_logAddNamedError ("UDP", "Couldn't allocate IPv4 event");
    272273
    273274 ipv6:
     
    279280                      event_callback, ss);
    280281        if (ss->udp6_event == NULL)
    281             tr_nerr ("UDP", "Couldn't allocate IPv6 event");
     282            tr_logAddNamedError ("UDP", "Couldn't allocate IPv6 event");
    282283    }
    283284
  • trunk/libtransmission/tr-utp.c

    r13625 r13868  
    2929
    3030#include "transmission.h"
     31#include "log.h"
    3132#include "net.h"
    3233#include "session.h"
     
    4041#define dbgmsg(...) \
    4142    do { \
    42         if (tr_deepLoggingIsActive ()) \
    43             tr_deepLog (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
     43        if (tr_logGetDeepEnabled ()) \
     44            tr_logAddDeep (__FILE__, __LINE__, MY_NAME, __VA_ARGS__); \
    4445    } while (0)
    4546
     
    4950UTP_Close (struct UTPSocket * socket)
    5051{
    51     tr_nerr (MY_NAME, "UTP_Close (%p) was called.", socket);
     52    tr_logAddNamedError (MY_NAME, "UTP_Close (%p) was called.", socket);
    5253    dbgmsg ("UTP_Close (%p) was called.", socket);
    5354    assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
     
    5758UTP_RBDrained (struct UTPSocket *socket)
    5859{
    59     tr_nerr (MY_NAME, "UTP_RBDrained (%p) was called.", socket);
     60    tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p) was called.", socket);
    6061    dbgmsg ("UTP_RBDrained (%p) was called.", socket);
    6162    assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
     
    6566UTP_Write (struct UTPSocket *socket, size_t count)
    6667{
    67     tr_nerr (MY_NAME, "UTP_RBDrained (%p, %zu) was called.", socket, count);
     68    tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p, %zu) was called.", socket, count);
    6869    dbgmsg ("UTP_RBDrained (%p, %zu) was called.", socket, count);
    6970    assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
     
    116117    if (!tr_address_from_sockaddr_storage (&addr, &port, &from_storage))
    117118    {
    118         tr_nerr ("UTP", "Unknown socket family");
     119        tr_logAddNamedError ("UTP", "Unknown socket family");
    119120        UTP_Close (s);
    120121        return;
  • trunk/libtransmission/transmission.h

    r13845 r13868  
    802802typedef enum
    803803{
    804     TR_MSG_ERR = 1,
    805     TR_MSG_INF = 2,
    806     TR_MSG_DBG = 3
    807 }
    808 tr_msg_level;
    809 
    810 void tr_setMessageLevel (tr_msg_level);
    811 
    812 typedef struct tr_msg_list
    813 {
    814     /* TR_MSG_ERR, TR_MSG_INF, or TR_MSG_DBG */
    815     tr_msg_level level;
    816 
    817     /* The line number in the source file where this message originated */
    818     int line;
    819 
    820     /* Time the message was generated */
    821     time_t when;
    822 
    823     /* The torrent associated with this message,
    824      * or a module name such as "Port Forwarding" for non-torrent messages,
    825      * or NULL. */
    826     char *  name;
    827 
    828     /* The message */
    829     char *  message;
    830 
    831     /* The source file where this message originated */
    832     const char * file;
    833 
    834     /* linked list of messages */
    835     struct tr_msg_list * next;
    836 }
    837 tr_msg_list;
    838 
    839 void          tr_setMessageQueuing (bool isEnabled);
    840 
    841 bool          tr_getMessageQueuing (void);
    842 
    843 tr_msg_list * tr_getQueuedMessages (void);
    844 
    845 void          tr_freeMessageList (tr_msg_list * freeme);
     804  TR_LOG_ERROR    = 1,
     805  TR_LOG_INFO     = 2,
     806  TR_LOG_DEBUG    = 3,
     807  TR_LOG_FIREHOSE = 4
     808}
     809tr_log_level;
     810
     811void tr_logSetLevel (tr_log_level);
     812
     813typedef struct tr_log_message
     814{
     815  /* TR_LOG_ERROR, TR_LOG_INFO, or TR_LOG_DEBUG */
     816  tr_log_level level;
     817
     818  /* The line number in the source file where this message originated */
     819  int line;
     820
     821  /* Time the message was generated */
     822  time_t when;
     823
     824  /* The torrent associated with this message,
     825   * or a module name such as "Port Forwarding" for non-torrent messages,
     826   * or NULL. */
     827  char * name;
     828
     829  /* The message */
     830  char *  message;
     831
     832  /* The source file where this message originated */
     833  const char * file;
     834
     835  /* linked list of messages */
     836  struct tr_log_message * next;
     837}
     838tr_log_message;
     839
     840tr_log_message * tr_logGetQueue        (void);
     841bool             tr_logGetQueueEnabled (void);
     842void             tr_logSetQueueEnabled (bool isEnabled);
     843void             tr_logFreeQueue       (tr_log_message * freeme);
    846844
    847845/** @addtogroup Blocklists
  • trunk/libtransmission/trevent.c

    r13625 r13868  
    2121
    2222#include "transmission.h"
     23#include "log.h"
    2324#include "net.h"
    2425#include "session.h"
     
    4041    if ((s = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
    4142    {
    42         tr_dbg ("pgpipe failed to create socket: %ui", WSAGetLastError ());
     43        tr_logAddDebug ("pgpipe failed to create socket: %ui", WSAGetLastError ());
    4344        return -1;
    4445    }
     
    5051    if (bind (s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
    5152    {
    52         tr_dbg ("pgpipe failed to bind: %ui", WSAGetLastError ());
     53        tr_logAddDebug ("pgpipe failed to bind: %ui", WSAGetLastError ());
    5354        closesocket (s);
    5455        return -1;
     
    5657    if (listen (s, 1) == SOCKET_ERROR)
    5758    {
    58         tr_ndbg ("event","pgpipe failed to listen: %ui", WSAGetLastError ());
     59        tr_logAddNamedDbg ("event","pgpipe failed to listen: %ui", WSAGetLastError ());
    5960        closesocket (s);
    6061        return -1;
     
    6263    if (getsockname (s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR)
    6364    {
    64         tr_dbg ("pgpipe failed to getsockname: %ui", WSAGetLastError ());
     65        tr_logAddDebug ("pgpipe failed to getsockname: %ui", WSAGetLastError ());
    6566        closesocket (s);
    6667        return -1;
     
    6869    if ((handles[1] = socket (PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
    6970    {
    70         tr_dbg ("pgpipe failed to create socket 2: %ui", WSAGetLastError ());
     71        tr_logAddDebug ("pgpipe failed to create socket 2: %ui", WSAGetLastError ());
    7172        closesocket (s);
    7273        return -1;
     
    7576    if (connect (handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
    7677    {
    77         tr_dbg ("pgpipe failed to connect socket: %ui", WSAGetLastError ());
     78        tr_logAddDebug ("pgpipe failed to connect socket: %ui", WSAGetLastError ());
    7879        closesocket (s);
    7980        return -1;
     
    8182    if ((handles[0] = accept (s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
    8283    {
    83         tr_dbg ("pgpipe failed to accept socket: %ui", WSAGetLastError ());
     84        tr_logAddDebug ("pgpipe failed to accept socket: %ui", WSAGetLastError ());
    8485        closesocket (handles[1]);
    8586        handles[1] = INVALID_SOCKET;
     
    155156#define dbgmsg(...) \
    156157    do { \
    157         if (tr_deepLoggingIsActive ()) \
    158             tr_deepLog (__FILE__, __LINE__, "event", __VA_ARGS__); \
     158        if (tr_logGetDeepEnabled ()) \
     159            tr_logAddDeep (__FILE__, __LINE__, "event", __VA_ARGS__); \
    159160    } while (0)
    160161
     
    214215{
    215216    if (severity >= _EVENT_LOG_ERR)
    216         tr_err ("%s", message);
     217        tr_logAddError ("%s", message);
    217218    else
    218         tr_dbg ("%s", message);
     219        tr_logAddDebug ("%s", message);
    219220}
    220221
     
    253254    eh->session->events = NULL;
    254255    tr_free (eh);
    255     tr_dbg ("Closing libevent thread");
     256    tr_logAddDebug ("Closing libevent thread");
    256257}
    257258
     
    280281
    281282    session->events->die = true;
    282     tr_deepLog (__FILE__, __LINE__, NULL, "closing trevent pipe");
     283    tr_logAddDeep (__FILE__, __LINE__, NULL, "closing trevent pipe");
    283284    tr_netCloseSocket (session->events->fds[1]);
    284285}
  • trunk/libtransmission/upnp.c

    r13631 r13868  
    2727
    2828#include "transmission.h"
     29#include "log.h"
    2930#include "port-forwarding.h"
    3031#include "session.h"
     
    102103
    103104    if (ret != UPNPCOMMAND_SUCCESS)
    104         tr_ndbg (getKey (), "upnpDiscover failed (errno %d - %s)", err, tr_strerror (err));
     105        tr_logAddNamedDbg (getKey (), "upnpDiscover failed (errno %d - %s)", err, tr_strerror (err));
    105106
    106107    return ret;
     
    150151
    151152    if (err)
    152         tr_ndbg (getKey (), "%s Port forwarding failed with error %d (errno %d - %s)", proto, err, errno, tr_strerror (errno));
     153        tr_logAddNamedDbg (getKey (), "%s Port forwarding failed with error %d (errno %d - %s)", proto, err, errno, tr_strerror (errno));
    153154
    154155    errno = old_errno;
     
    198199                             handle->lanaddr, sizeof (handle->lanaddr)) == UPNP_IGD_VALID_CONNECTED)
    199200        {
    200             tr_ninf (getKey (), _(
     201            tr_logAddNamedInfo (getKey (), _(
    201202                         "Found Internet Gateway Device \"%s\""),
    202203                     handle->urls.controlURL);
    203             tr_ninf (getKey (), _(
     204            tr_logAddNamedInfo (getKey (), _(
    204205                         "Local Address is \"%s\""), handle->lanaddr);
    205206            handle->state = TR_UPNP_IDLE;
     
    209210        {
    210211            handle->state = TR_UPNP_ERR;
    211             tr_ndbg (
     212            tr_logAddNamedDbg (
    212213                 getKey (), "UPNP_GetValidIGD failed (errno %d - %s)",
    213214                errno,
    214215                tr_strerror (errno));
    215             tr_ndbg (
     216            tr_logAddNamedDbg (
    216217                getKey (),
    217218                "If your router supports UPnP, please make sure UPnP is enabled!");
     
    231232          (tr_upnpGetSpecificPortMappingEntry (handle, "UDP") != UPNPCOMMAND_SUCCESS))
    232233        {
    233             tr_ninf (getKey (), _("Port %d isn't forwarded"), handle->port);
     234            tr_logAddNamedInfo (getKey (), _("Port %d isn't forwarded"), handle->port);
    234235            handle->isMapped = false;
    235236        }
     
    241242        tr_upnpDeletePortMapping (handle, "UDP", handle->port);
    242243
    243         tr_ninf (getKey (),
     244        tr_logAddNamedInfo (getKey (),
    244245                 _("Stopping port forwarding through \"%s\", service \"%s\""),
    245246                 handle->urls.controlURL, handle->data.first.servicetype);
     
    274275            handle->isMapped = !err_tcp | !err_udp;
    275276        }
    276         tr_ninf (getKey (),
     277        tr_logAddNamedInfo (getKey (),
    277278                 _("Port forwarding through \"%s\", service \"%s\". (local address: %s:%d)"),
    278279                 handle->urls.controlURL, handle->data.first.servicetype,
     
    280281        if (handle->isMapped)
    281282        {
    282             tr_ninf (getKey (), "%s", _("Port forwarding successful!"));
     283            tr_logAddNamedInfo (getKey (), "%s", _("Port forwarding successful!"));
    283284            handle->port = port;
    284285            handle->state = TR_UPNP_IDLE;
     
    286287        else
    287288        {
    288             tr_ndbg (getKey (), "If your router supports UPnP, please make sure UPnP is enabled!");
     289            tr_logAddNamedDbg (getKey (), "If your router supports UPnP, please make sure UPnP is enabled!");
    289290            handle->port = -1;
    290291            handle->state = TR_UPNP_ERR;
  • trunk/libtransmission/utils.c

    r13863 r13868  
    5757#include "ConvertUTF.h"
    5858#include "list.h"
     59#include "log.h"
    5960#include "utils.h"
    6061#include "platform.h" /* tr_lockLock (), TR_PATH_MAX */
     
    6364
    6465
    65 time_t       __tr_current_time   = 0;
    66 tr_msg_level __tr_message_level  = TR_MSG_ERR;
    67 
    68 static bool           messageQueuing = false;
    69 static tr_msg_list *  messageQueue = NULL;
    70 static tr_msg_list ** messageQueueTail = &messageQueue;
    71 static int            messageQueueCount = 0;
    72 
    73 #ifndef WIN32
    74   /* make null versions of these win32 functions */
    75   static inline int IsDebuggerPresent (void) { return false; }
    76   static inline void OutputDebugString (const void * unused UNUSED) { }
    77 #endif
     66time_t __tr_current_time   = 0;
    7867
    7968/***
    8069****
    8170***/
    82 
    83 static tr_lock*
    84 getMessageLock (void)
    85 {
    86   static tr_lock * l = NULL;
    87 
    88   if (!l)
    89     l = tr_lockNew ();
    90 
    91   return l;
    92 }
    93 
    94 void*
    95 tr_getLog (void)
    96 {
    97   static bool initialized = false;
    98   static FILE * file = NULL;
    99 
    100   if (!initialized)
    101     {
    102       int fd = 0;
    103       const char * str = getenv ("TR_DEBUG_FD");
    104 
    105       if (str && *str)
    106         fd = atoi (str);
    107 
    108       switch (fd)
    109         {
    110           case 1:
    111             file = stdout;
    112             break;
    113 
    114           case 2:
    115             file = stderr;
    116             break;
    117 
    118           default:
    119             file = NULL;
    120             break;
    121         }
    122 
    123       initialized = true;
    124     }
    125 
    126   return file;
    127 }
    128 
    129 void
    130 tr_setMessageLevel (tr_msg_level level)
    131 {
    132     __tr_message_level = level;
    133 }
    134 
    135 void
    136 tr_setMessageQueuing (bool enabled)
    137 {
    138   messageQueuing = enabled;
    139 }
    140 
    141 bool
    142 tr_getMessageQueuing (void)
    143 {
    144   return messageQueuing != 0;
    145 }
    146 
    147 tr_msg_list *
    148 tr_getQueuedMessages (void)
    149 {
    150   tr_msg_list * ret;
    151   tr_lockLock (getMessageLock ());
    152 
    153   ret = messageQueue;
    154   messageQueue = NULL;
    155   messageQueueTail = &messageQueue;
    156 
    157   messageQueueCount = 0;
    158 
    159   tr_lockUnlock (getMessageLock ());
    160   return ret;
    161 }
    162 
    163 void
    164 tr_freeMessageList (tr_msg_list * list)
    165 {
    166   tr_msg_list * next;
    167 
    168   while (NULL != list)
    169     {
    170       next = list->next;
    171       free (list->message);
    172       free (list->name);
    173       free (list);
    174       list = next;
    175     }
    176 }
    177 
    178 /**
    179 ***
    180 **/
    18171
    18272struct tm *
     
    19181  return p;
    19282#endif
    193 }
    194 
    195 char*
    196 tr_getLogTimeStr (char * buf, int buflen)
    197 {
    198   char tmp[64];
    199   struct tm now_tm;
    200   struct timeval tv;
    201   time_t seconds;
    202   int milliseconds;
    203 
    204   gettimeofday (&tv, NULL);
    205 
    206   seconds = tv.tv_sec;
    207   tr_localtime_r (&seconds, &now_tm);
    208   strftime (tmp, sizeof (tmp), "%H:%M:%S", &now_tm);
    209   milliseconds = tv.tv_usec / 1000;
    210   tr_snprintf (buf, buflen, "%s.%03d", tmp, milliseconds);
    211 
    212   return buf;
    213 }
    214 
    215 bool
    216 tr_deepLoggingIsActive (void)
    217 {
    218   static int8_t deepLoggingIsActive = -1;
    219 
    220   if (deepLoggingIsActive < 0)
    221     deepLoggingIsActive = IsDebuggerPresent () || (tr_getLog ()!=NULL);
    222 
    223   return deepLoggingIsActive != 0;
    224 }
    225 
    226 void
    227 tr_deepLog (const char  * file,
    228             int           line,
    229             const char  * name,
    230             const char  * fmt,
    231             ...)
    232 {
    233   FILE * fp = tr_getLog ();
    234   if (fp || IsDebuggerPresent ())
    235     {
    236       va_list args;
    237       char timestr[64];
    238       char * message;
    239       struct evbuffer * buf = evbuffer_new ();
    240       char * base = tr_basename (file);
    241 
    242       evbuffer_add_printf (buf, "[%s] ",
    243                            tr_getLogTimeStr (timestr, sizeof (timestr)));
    244       if (name)
    245         evbuffer_add_printf (buf, "%s ", name);
    246       va_start (args, fmt);
    247       evbuffer_add_vprintf (buf, fmt, args);
    248       va_end (args);
    249       evbuffer_add_printf (buf, " (%s:%d)\n", base, line);
    250       /* FIXME (libevent2) ifdef this out for nonwindows platforms */
    251       message = evbuffer_free_to_str (buf);
    252       OutputDebugString (message);
    253       if (fp)
    254         fputs (message, fp);
    255 
    256       tr_free (message);
    257       tr_free (base);
    258     }
    259 }
    260 
    261 /***
    262 ****
    263 ***/
    264 
    265 void
    266 tr_msg (const char * file, int line,
    267         tr_msg_level level,
    268         const char * name,
    269         const char * fmt, ...)
    270 {
    271   const int err = errno; /* message logging shouldn't affect errno */
    272   char buf[1024];
    273   va_list ap;
    274   tr_lockLock (getMessageLock ());
    275 
    276   /* build the text message */
    277   *buf = '\0';
    278   va_start (ap, fmt);
    279   evutil_vsnprintf (buf, sizeof (buf), fmt, ap);
    280   va_end (ap);
    281 
    282   OutputDebugString (buf);
    283 
    284   if (*buf)
    285     {
    286       if (messageQueuing)
    287         {
    288           tr_msg_list * newmsg;
    289           newmsg = tr_new0 (tr_msg_list, 1);
    290           newmsg->level = level;
    291           newmsg->when = tr_time ();
    292           newmsg->message = tr_strdup (buf);
    293           newmsg->file = file;
    294           newmsg->line = line;
    295           newmsg->name = tr_strdup (name);
    296 
    297           *messageQueueTail = newmsg;
    298           messageQueueTail = &newmsg->next;
    299           ++messageQueueCount;
    300 
    301           if (messageQueueCount > TR_MAX_MSG_LOG)
    302             {
    303               tr_msg_list * old = messageQueue;
    304               messageQueue = old->next;
    305               old->next = NULL;
    306               tr_freeMessageList (old);
    307               --messageQueueCount;
    308               assert (messageQueueCount == TR_MAX_MSG_LOG);
    309             }
    310         }
    311       else
    312         {
    313           FILE * fp;
    314           char timestr[64];
    315 
    316           fp = tr_getLog ();
    317           if (fp == NULL)
    318             fp = stderr;
    319 
    320           tr_getLogTimeStr (timestr, sizeof (timestr));
    321 
    322           if (name)
    323             fprintf (fp, "[%s] %s: %s\n", timestr, name, buf);
    324           else
    325             fprintf (fp, "[%s] %s\n", timestr, buf);
    326           fflush (fp);
    327         }
    328     }
    329 
    330   tr_lockUnlock (getMessageLock ());
    331   errno = err;
    33283}
    33384
     
    447198    {
    448199      const int err = errno;
    449       tr_dbg (err_fmt, path, tr_strerror (errno));
     200      tr_logAddDebug (err_fmt, path, tr_strerror (errno));
    450201      errno = err;
    451202      return NULL;
     
    454205  if ((sb.st_mode & S_IFMT) != S_IFREG)
    455206    {
    456       tr_err (err_fmt, path, _("Not a regular file"));
     207      tr_logAddError (err_fmt, path, _("Not a regular file"));
    457208      errno = EISDIR;
    458209      return NULL;
     
    464215    {
    465216      const int err = errno;
    466       tr_err (err_fmt, path, tr_strerror (errno));
     217      tr_logAddError (err_fmt, path, tr_strerror (errno));
    467218      errno = err;
    468219      return NULL;
     
    472223    {
    473224      const int err = errno;
    474       tr_err (err_fmt, path, _("Memory allocation failed"));
     225      tr_logAddError (err_fmt, path, _("Memory allocation failed"));
    475226      tr_close_file (fd);
    476227      errno = err;
     
    481232    {
    482233      const int err = errno;
    483       tr_err (err_fmt, path, tr_strerror (errno));
     234      tr_logAddError (err_fmt, path, tr_strerror (errno));
    484235      tr_close_file (fd);
    485236      free (buf);
     
    580331            {
    581332              tmperr = errno;
    582               tr_err (_("Couldn't create \"%1$s\": %2$s"), path, tr_strerror (tmperr));
     333              tr_logAddError (_("Couldn't create \"%1$s\": %2$s"), path, tr_strerror (tmperr));
    583334              tr_free (path);
    584335              errno = tmperr;
     
    590341          /* Node exists but isn't a folder */
    591342          char * buf = tr_strdup_printf (_("File \"%s\" is in the way"), path);
    592           tr_err (_("Couldn't create \"%1$s\": %2$s"), path_in, buf);
     343          tr_logAddError (_("Couldn't create \"%1$s\": %2$s"), path_in, buf);
    593344          tr_free (buf);
    594345          tr_free (path);
  • trunk/libtransmission/utils.h

    r13708 r13868  
    101101*****
    102102****/
    103 
    104 #define TR_MAX_MSG_LOG 10000
    105 
    106 extern tr_msg_level __tr_message_level;
    107 
    108 static inline tr_msg_level tr_getMessageLevel (void)
    109 {
    110     return __tr_message_level;
    111 }
    112 
    113 static inline bool tr_msgLoggingIsActive (tr_msg_level level)
    114 {
    115     return tr_getMessageLevel () >= level;
    116 }
    117 
    118 void tr_msg (const char * file, int line,
    119              tr_msg_level level,
    120              const char * torrent,
    121              const char * fmt, ...) TR_GNUC_PRINTF (5, 6);
    122 
    123 #define tr_nerr(n, ...) \
    124     do { \
    125         if (tr_msgLoggingIsActive (TR_MSG_ERR)) \
    126             tr_msg (__FILE__, __LINE__, TR_MSG_ERR, n, __VA_ARGS__); \
    127     } while (0)
    128 
    129 #define tr_ninf(n, ...) \
    130     do { \
    131         if (tr_msgLoggingIsActive (TR_MSG_INF)) \
    132             tr_msg (__FILE__, __LINE__, TR_MSG_INF, n, __VA_ARGS__); \
    133     } while (0)
    134 
    135 #define tr_ndbg(n, ...) \
    136     do { \
    137         if (tr_msgLoggingIsActive (TR_MSG_DBG)) \
    138             tr_msg (__FILE__, __LINE__, TR_MSG_DBG, n, __VA_ARGS__); \
    139     } while (0)
    140 
    141 #define tr_torerr(tor, ...) \
    142     do { \
    143         if (tr_msgLoggingIsActive (TR_MSG_ERR)) \
    144             tr_msg (__FILE__, __LINE__, TR_MSG_ERR, tr_torrentName (tor), __VA_ARGS__); \
    145     } while (0)
    146 
    147 #define tr_torinf(tor, ...) \
    148     do { \
    149         if (tr_msgLoggingIsActive (TR_MSG_INF)) \
    150             tr_msg (__FILE__, __LINE__, TR_MSG_INF, tr_torrentName (tor), __VA_ARGS__); \
    151     } while (0)
    152 
    153 #define tr_tordbg(tor, ...) \
    154     do { \
    155         if (tr_msgLoggingIsActive (TR_MSG_DBG)) \
    156             tr_msg (__FILE__, __LINE__, TR_MSG_DBG, tr_torrentName (tor), __VA_ARGS__); \
    157     } while (0)
    158 
    159 #define tr_err(...) \
    160     do { \
    161         if (tr_msgLoggingIsActive (TR_MSG_ERR)) \
    162             tr_msg (__FILE__, __LINE__, TR_MSG_ERR, NULL, __VA_ARGS__); \
    163     } while (0)
    164 
    165 #define tr_inf(...) \
    166     do { \
    167         if (tr_msgLoggingIsActive (TR_MSG_INF)) \
    168             tr_msg (__FILE__, __LINE__, TR_MSG_INF, NULL, __VA_ARGS__); \
    169     } while (0)
    170 
    171 #define tr_dbg(...) \
    172     do { \
    173         if (tr_msgLoggingIsActive (TR_MSG_DBG)) \
    174             tr_msg (__FILE__, __LINE__, TR_MSG_DBG, NULL, __VA_ARGS__); \
    175     } while (0)
    176 
    177 
    178 
    179 void* tr_getLog (void);
    180 
    181 /** @brief return true if deep logging has been enabled by the user; false otherwise */
    182 bool tr_deepLoggingIsActive (void);
    183 
    184 void           tr_deepLog (const char * file,
    185                            int          line,
    186                            const char * name,
    187                            const char * fmt,
    188                            ...) TR_GNUC_PRINTF (4, 5) TR_GNUC_NONNULL (1,4);
    189 
    190 /** @brief set the buffer with the current time formatted for deep logging. */
    191 char* tr_getLogTimeStr (char * buf, int buflen) TR_GNUC_NONNULL (1);
    192 
    193103
    194104/**
  • trunk/libtransmission/variant-json.c

    r13858 r13868  
    2929#include "ConvertUTF.h"
    3030#include "list.h"
     31#include "log.h"
    3132#include "ptrarray.h"
    3233#include "utils.h"
     
    9192  if (data->source)
    9293    {
    93       tr_err ("JSON parse failed in %s at pos %zu: %s -- remaining text \"%.16s\"",
     94      tr_logAddError ("JSON parse failed in %s at pos %zu: %s -- remaining text \"%.16s\"",
    9495              data->source,
    9596              jsn->pos,
     
    99100  else
    100101    {
    101       tr_err ("JSON parse failed at pos %zu: %s -- remaining text \"%.16s\"",
     102      tr_logAddError ("JSON parse failed at pos %zu: %s -- remaining text \"%.16s\"",
    102103              jsn->pos,
    103104              jsonsl_strerror (error),
  • trunk/libtransmission/variant.c

    r13861 r13868  
    3232#include "ConvertUTF.h" 
    3333#include "fdlimit.h" /* tr_close_file() */
     34#include "log.h"
    3435#include "platform.h" /* TR_PATH_MAX */
    3536#include "utils.h" /* tr_new(), tr_free() */
     
    889890          default:
    890891            /* did caller give us an uninitialized val? */
    891             tr_err ("%s", _("Invalid metadata"));
     892            tr_logAddError ("%s", _("Invalid metadata"));
    892893            break;
    893894        }
     
    979980     else
    980981       {
    981          tr_err ("tr_variantListCopy skipping item");
     982         tr_logAddError ("tr_variantListCopy skipping item");
    982983       }
    983984   }
     
    10751076          else
    10761077            {
    1077               tr_dbg ("tr_variantMergeDicts skipping \"%s\"", tr_quark_get_string(key,NULL));
     1078              tr_logAddDebug ("tr_variantMergeDicts skipping \"%s\"", tr_quark_get_string(key,NULL));
    10781079            }
    10791080        }
     
    11911192      if (nleft > 0)
    11921193        {
    1193           tr_err (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
     1194          tr_logAddError (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
    11941195          tr_close_file (fd);
    11951196          unlink (tmp);
     
    12051206#endif
    12061207            {
    1207               tr_inf (_("Saved \"%s\""), filename);
     1208              tr_logAddInfo (_("Saved \"%s\""), filename);
    12081209            }
    12091210          else
    12101211            {
    12111212              err = errno;
    1212               tr_err (_("Couldn't save file \"%1$s\": %2$s"), filename, tr_strerror (err));
     1213              tr_logAddError (_("Couldn't save file \"%1$s\": %2$s"), filename, tr_strerror (err));
    12131214              unlink (tmp);
    12141215            }
     
    12181219    {
    12191220      err = errno;
    1220       tr_err (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
     1221      tr_logAddError (_("Couldn't save temporary file \"%1$s\": %2$s"), tmp, tr_strerror (err));
    12211222    }
    12221223
  • trunk/libtransmission/verify.c

    r13631 r13868  
    2525#include "fdlimit.h"
    2626#include "list.h"
     27#include "log.h"
    2728#include "platform.h" /* tr_lock () */
    2829#include "torrent.h"
     
    5960  SHA1_Init (&sha);
    6061
    61   tr_tordbg (tor, "%s", "verifying torrent...");
     62  tr_logAddTorDbg (tor, "%s", "verifying torrent...");
    6263  tr_torrentSetChecked (tor, 0);
    6364  while (!*stopFlag && (pieceIndex < tor->info.pieceCount))
     
    160161  /* stopwatch */
    161162  end = tr_time ();
    162   tr_tordbg (tor, "Verification is done. It took %d seconds to verify %"PRIu64" bytes (%"PRIu64" bytes per second)",
     163  tr_logAddTorDbg (tor, "Verification is done. It took %d seconds to verify %"PRIu64" bytes (%"PRIu64" bytes per second)",
    163164             (int)(end-begin), tor->info.totalSize,
    164165             (uint64_t)(tor->info.totalSize/ (1+ (end-begin))));
     
    227228      tr_lockUnlock (getVerifyLock ());
    228229
    229       tr_torinf (tor, "%s", _("Verifying torrent"));
     230      tr_logAddTorInfo (tor, "%s", _("Verifying torrent"));
    230231      tr_torrentSetVerifyState (tor, TR_VERIFY_NOW);
    231232      changed = verifyTorrent (tor, &stopCurrent);
     
    271272
    272273  assert (tr_isTorrent (tor));
    273   tr_torinf (tor, "%s", _("Queued for verification"));
     274  tr_logAddTorInfo (tor, "%s", _("Queued for verification"));
    274275
    275276  node = tr_new (struct verify_node, 1);
  • trunk/libtransmission/web.c

    r13863 r13868  
    2525
    2626#include "transmission.h"
     27#include "log.h"
    2728#include "net.h" /* tr_address */
    2829#include "platform.h" /* mutex */
     
    5152#define dbgmsg(...) \
    5253  do { \
    53     if (tr_deepLoggingIsActive ()) \
    54       tr_deepLog (__FILE__, __LINE__, "web", __VA_ARGS__); \
     54    if (tr_logGetDeepEnabled ()) \
     55      tr_logAddDeep (__FILE__, __LINE__, "web", __VA_ARGS__); \
    5556  } while (0)
    5657#endif
     
    337338  if (web->curl_ssl_verify)
    338339    {
    339       tr_ninf ("web", "will verify tracker certs using envvar CURL_CA_BUNDLE: %s",
     340      tr_logAddNamedInfo ("web", "will verify tracker certs using envvar CURL_CA_BUNDLE: %s",
    340341               web->curl_ca_bundle == NULL ? "none" : web->curl_ca_bundle);
    341       tr_ninf ("web", "NB: this only works if you built against libcurl with openssl or gnutls, NOT nss");
    342       tr_ninf ("web", "NB: invalid certs will show up as 'Could not connect to tracker' like many other errors");
     342      tr_logAddNamedInfo ("web", "NB: this only works if you built against libcurl with openssl or gnutls, NOT nss");
     343      tr_logAddNamedInfo ("web", "NB: invalid certs will show up as 'Could not connect to tracker' like many other errors");
    343344    }
    344345  web->cookie_filename = tr_buildPath (session->configDir, "cookies.txt", NULL);
  • trunk/macosx/MessageWindowController.m

    r13492 r13868  
    185185- (void) updateLog: (NSTimer *) timer
    186186{
    187     tr_msg_list * messages;
    188     if ((messages = tr_getQueuedMessages()) == NULL)
     187    tr_log_message * messages;
     188    if ((messages = tr_logGetQueue()) == NULL)
    189189        return;
    190190   
     
    202202    BOOL changed = NO;
    203203   
    204     for (tr_msg_list * currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
     204    for (tr_log_message * currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
    205205    {
    206206        NSString * name = currentMessage->name != NULL ? [NSString stringWithUTF8String: currentMessage->name]
     
    227227    }
    228228   
    229     if ([fMessages count] > TR_MAX_MSG_LOG)
     229    if ([fMessages count] > TR_LOG_MAX_QUEUE_LENGTH)
    230230    {
    231231        const NSUInteger oldCount = [fDisplayedMessages count];
    232232       
    233         NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fMessages count]-TR_MAX_MSG_LOG)];
     233        NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fMessages count]-TR_LOG_MAX_QUEUE_LENGTH)];
    234234        NSArray * itemsToRemove = [fMessages objectsAtIndexes: removeIndexes];
    235235       
     
    251251    [fLock unlock];
    252252   
    253     tr_freeMessageList(messages);
     253    tr_logFreeQueue (messages);
    254254}
    255255
  • trunk/qt/details.cc

    r13810 r13868  
    844844        myFileTreeView->clear( );
    845845    if( single )
    846         myFileTreeView->update( torrents[0]->files( ) , myChangedTorrents );
     846        myFileTreeView->update( torrents[0]->files( ) , myFilesDirty || myChangedTorrents );
     847
    847848    myFilesDirty = false;
    848 
    849849    myChangedTorrents = false;
    850850    myHavePendingRefresh = false;
  • trunk/qt/file-tree.cc

    r13867 r13868  
    184184                        uint64_t totalSize,
    185185                        uint64_t haveSize,
    186                         bool     torrentChanged)
     186                        bool     updateFields)
    187187{
    188188  bool changed = false;
     189
     190std::cerr << __FILE__ << ':' << __LINE__ << " index " << index << " wanted " << wanted << " myIndex " << myIndex << " myWanted" << myIsWanted << std::endl;
    189191
    190192  if (myIndex != index)
     
    194196    }
    195197
    196   if (torrentChanged && myIsWanted != wanted)
     198  if (updateFields && myIsWanted != wanted)
    197199    {
    198200      myIsWanted = wanted;
    199201      changed = true;
    200     }
    201 
    202   if (torrentChanged && myPriority != priority)
     202std::cerr << __FILE__ << ':' << __LINE__ << " setting myIsWanted to " << myIsWanted << std::endl;
     203    }
     204
     205  if (updateFields && myPriority != priority)
    203206    {
    204207      myPriority = priority;
     
    286289  else
    287290    p = TR_PRI_LOW;
     291std::cerr << __FILE__ << ':' << __LINE__ << " twiddlePriority, p " << p << std::endl;
    288292
    289293  setSubtreePriority (p, ids);
     
    317321FileTreeItem :: setSubtreeWanted (bool b, QSet<int>& ids)
    318322{
    319   if(myIsWanted != b)
     323std::cerr << __FILE__ << ':' << __LINE__ << " twiddleWanted, wanted " << b << std::endl;
     324  if (myIsWanted != b)
    320325    {
    321326      myIsWanted = b;
     
    332337FileTreeItem :: twiddleWanted (QSet<int>& ids, bool& wanted)
    333338{
     339std::cerr << __FILE__ << ':' << __LINE__ << " twiddleWanted" << std::endl;
    334340  wanted = isSubtreeWanted() != Qt::Checked;
    335341  setSubtreeWanted (wanted, ids);
     
    349355FileTreeModel :: ~FileTreeModel()
    350356{
     357std::cerr << __FILE__ << ':' << __LINE__ << " dtor " << std::endl;
    351358  clear();
    352359
     
    517524{
    518525  size_t i = rowCount (top);
     526std::cerr << __FILE__ << ':' << __LINE__ << " clearSubtree " << i << std::endl;
    519527
    520528  while (i > 0)
    521529    clearSubtree(index(--i, 0, top));
    522530
    523     delete static_cast<FileTreeItem*>(top.internalPointer());
     531  delete static_cast<FileTreeItem*>(top.internalPointer());
    524532}
    525533
     
    527535FileTreeModel :: clear ()
    528536{
     537std::cerr << __FILE__ << ':' << __LINE__ << " clear"  << std::endl;
    529538  clearSubtree (QModelIndex());
    530539
     
    540549                          uint64_t              have,
    541550                          QList<QModelIndex>  & rowsAdded,
    542                           bool                  torrentChanged)
    543 {
     551                          bool                  updateFields)
     552{
     553  bool added = false;
    544554  FileTreeItem * i (rootItem);
    545555
     
    549559      if (!child)
    550560        {
     561          added = true;
    551562          QModelIndex parentIndex (indexOf(i, 0));
    552563          const int n (i->childCount());
     
    560571
    561572  if (i != rootItem)
    562     if (i->update (index, wanted, priority, size, have, torrentChanged))
    563       dataChanged (indexOf(i, 0), indexOf(i, NUM_COLUMNS-1));
     573    {
     574      if (i->update (index, wanted, priority, size, have, added || updateFields))
     575        {
     576          std::cerr << __FILE__ << ':' << __LINE__ << " emitting dataChanged for row " << i << std::endl;
     577          dataChanged (indexOf(i, 0), indexOf(i, NUM_COLUMNS-1));
     578        }
     579    }
    564580}
    565581
     
    622638      FileTreeItem * item;
    623639
     640std::cerr << "clicked in COL_PRIORITY" << std::endl;
    624641      item = static_cast<FileTreeItem*>(index.internalPointer());
    625642      item->twiddlePriority (file_ids, priority);
     
    800817FileTreeView :: onClicked (const QModelIndex& proxyIndex)
    801818{
    802   const QModelIndex modelIndex = myProxy->mapToSource(proxyIndex);
    803   myModel.clicked(modelIndex);
     819  const QModelIndex modelIndex = myProxy->mapToSource (proxyIndex);
     820std::cerr << __FILE__ << ':' << __LINE__ << " calling myModel.clicked()" << std::endl;
     821  myModel.clicked (modelIndex);
    804822}
    805823
     
    836854    }
    837855
     856#if 0
    838857  // handle using the keyboard to toggle the
    839858  // wanted/unwanted state or the file priority
    840   else if(event->type() == QEvent::KeyPress)
    841     {
     859  else if (event->type() == QEvent::KeyPress)
     860    {
     861std::cerr << __FILE__ << ':' << __LINE__ << " " << qPrintable(dynamic_cast<QKeyEvent*>(event)->text()) << std::endl;
    842862      switch(dynamic_cast<QKeyEvent*>(event)->key())
    843863        {
    844864          case Qt::Key_Space:
     865            std::cerr << __FILE__ << ':' << __LINE__ << " calling COL_WANTED.clicked()" << std::endl;
    845866            foreach (QModelIndex i, selectionModel()->selectedRows(COL_WANTED))
    846867              clicked (i);
     
    849870          case Qt::Key_Enter:
    850871          case Qt::Key_Return:
     872            std::cerr << __FILE__ << ':' << __LINE__ << " calling COL_PRIORITY.clicked()" << std::endl;
    851873            foreach (QModelIndex i, selectionModel()->selectedRows(COL_PRIORITY))
    852874              clicked (i);
     
    854876        }
    855877    }
     878#endif
    856879
    857880  return false;
     
    865888
    866889void
    867 FileTreeView :: update (const FileList& files, bool torrentChanged)
    868 {
     890FileTreeView :: update (const FileList& files, bool updateFields)
     891{
     892std::cerr << "update updateFields " << updateFields << std::endl;
    869893  foreach (const TrFile file, files)
    870894    {
    871895      QList<QModelIndex> added;
    872       myModel.addFile (file.index, file.filename, file.wanted, file.priority, file.size, file.have, added, torrentChanged);
     896std::cerr << __FILE__ << ':' << __LINE__ << " add file " << qPrintable(file.filename) << " wanted " << file.wanted << std::endl;
     897      myModel.addFile (file.index, file.filename, file.wanted, file.priority, file.size, file.have, added, updateFields);
    873898      foreach (QModelIndex i, added)
    874899        expand (myProxy->mapFromSource(i));
     
    879904FileTreeView :: clear ()
    880905{
     906std::cerr << __FILE__ << ':' << __LINE__ << " clear" << std::endl;
    881907  myModel.clear();
    882908}
  • trunk/qt/file-tree.h

    r13866 r13868  
    6464    const QString& name () const { return myName; }
    6565    QVariant data (int column, int role) const;
    66     bool update (int index, bool want, int priority, uint64_t total, uint64_t have, bool torrentChanged);
     66    bool update (int index, bool want, int priority, uint64_t total, uint64_t have, bool updateFields);
    6767    void twiddleWanted (QSet<int>& fileIds, bool&);
    6868    void twiddlePriority (QSet<int>& fileIds, int&);
  • trunk/utils/create.c

    r13800 r13868  
    136136  tr_metainfo_builder * b = NULL;
    137137
    138   tr_setMessageLevel (TR_MSG_ERR);
     138  tr_logSetLevel (TR_LOG_ERROR);
    139139
    140140  if (parseCommandLine (argc, (const char**)argv))
  • trunk/utils/edit.c

    r13840 r13868  
    296296  files = tr_new0 (const char*, argc);
    297297
    298   tr_setMessageLevel (TR_MSG_ERR);
     298  tr_logSetLevel (TR_LOG_ERROR);
    299299
    300300  if (parseCommandLine (argc, (const char**)argv))
  • trunk/utils/show.c

    r13722 r13868  
    311311  tr_ctor * ctor;
    312312
    313   tr_setMessageLevel (TR_MSG_ERR);
     313  tr_logSetLevel (TR_LOG_ERROR);
    314314  tr_formatter_mem_init (MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR);
    315315  tr_formatter_size_init (DISK_K, DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR);
Note: See TracChangeset for help on using the changeset viewer.