[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r2304: Reenable all the logging in src/torcontrol that I had to dis (in vidalia/trunk: . src/torcontrol)



Author: edmanm
Date: 2008-01-18 16:15:45 -0500 (Fri, 18 Jan 2008)
New Revision: 2304

Modified:
   vidalia/trunk/
   vidalia/trunk/src/torcontrol/addressmap.cpp
   vidalia/trunk/src/torcontrol/controlcommand.cpp
   vidalia/trunk/src/torcontrol/controlconnection.cpp
   vidalia/trunk/src/torcontrol/controlsocket.cpp
   vidalia/trunk/src/torcontrol/torevents.cpp
   vidalia/trunk/src/torcontrol/torprocess.cpp
   vidalia/trunk/src/torcontrol/torservice.cpp
Log:
 r42@lysithea:  edmanm | 2008-01-18 16:15:28 -0500
 Reenable all the logging in src/torcontrol that I had to disable during the
 re-org when we moved to CMake.



Property changes on: vidalia/trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r42] on 90112fd6-a33b-4cea-8d39-48ff1d78625c

Modified: vidalia/trunk/src/torcontrol/addressmap.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/addressmap.cpp	2008-01-18 21:15:35 UTC (rev 2303)
+++ vidalia/trunk/src/torcontrol/addressmap.cpp	2008-01-18 21:15:45 UTC (rev 2304)
@@ -26,8 +26,7 @@
  */
 
 #include <QStringList>
-//#include <vidalia.h>
-
+#include "debug.h"
 #include "addressmap.h"
 
 /** Format of expiry times in address map events. */
@@ -39,11 +38,10 @@
 void
 AddressMap::add(QString from, QString to, QDateTime expires)
 {
-#if 0
-  vInfo("New address mapping: %1 -> %2 (expires %3)")
-    .arg(from).arg(to)
-    .arg(expires.isValid() ? expires.toString(DATE_FMT) : "never");
-#endif
+  log::debug("New address mapping: %1 -> %2 (expires %3)").arg(from)
+                                                          .arg(to)
+                          .arg(expires.isValid() ? expires.toString(DATE_FMT)
+                                                 : "never");
   insert(from, addr_map_entry_t(to, expires));
 }
 

Modified: vidalia/trunk/src/torcontrol/controlcommand.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/controlcommand.cpp	2008-01-18 21:15:35 UTC (rev 2303)
+++ vidalia/trunk/src/torcontrol/controlcommand.cpp	2008-01-18 21:15:45 UTC (rev 2304)
@@ -25,7 +25,6 @@
  * \brief A command sent to Tor's control interface
  */
 
-
 #include "controlcommand.h"
 
 /** Default constructor. */

Modified: vidalia/trunk/src/torcontrol/controlconnection.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/controlconnection.cpp	2008-01-18 21:15:35 UTC (rev 2303)
+++ vidalia/trunk/src/torcontrol/controlconnection.cpp	2008-01-18 21:15:45 UTC (rev 2304)
@@ -29,6 +29,7 @@
 #include <QCoreApplication>
 #include <QMutexLocker>
 #include <stringutil.h>
+#include "debug.h"
 
 #include "controlconnection.h"
 
@@ -59,10 +60,8 @@
 ControlConnection::connect(QHostAddress addr, quint16 port)
 {
   if (isRunning()) {
-#if 0
-    vError("Bug: Tried to call ControlConnection::connect() when the "
-          "control thread is already running.");
-#endif
+    log::error("Bug: Tried to call ControlConnection::connect() when the "
+              "control thread is already running.");
     return;
   }
 
@@ -84,10 +83,9 @@
 ControlConnection::connect()
 {
   _connectAttempt++;
-#if 0
-  vInfo("Connecting to Tor (Attempt %1 of %2)").arg(_connectAttempt)
-                                               .arg(MAX_CONNECT_ATTEMPTS);
-#endif
+  log::debug("Connecting to Tor (Attempt %1 of %2)").arg(_connectAttempt)
+                                                   .arg(MAX_CONNECT_ATTEMPTS);
+  
   _connMutex.lock();
   _sock->connectToHost(_addr, _port);
   _connMutex.unlock();
@@ -132,15 +130,13 @@
      * running, but it doesn't have a ControlPort open yet. */
     if (error == QAbstractSocket::ConnectionRefusedError &&
         _connectAttempt < MAX_CONNECT_ATTEMPTS) {
-#if 0
-      vInfo("Control connection refused. Retrying in %1ms.")
-                                                  .arg(CONNECT_RETRY_DELAY);
-#endif
+      log::debug("Control connection refused. Retrying in %1ms.")
+                                       .arg(CONNECT_RETRY_DELAY);
       _connectTimer->start(CONNECT_RETRY_DELAY);
     } else {
       /* Exceeded maximum number of connect attempts. Give up. */
       QString errstr = ControlSocket::toString(error);
-//      vWarn("Vidalia was unable to connect to Tor: %1").arg(errstr);
+      log::error("Vidalia was unable to connect to Tor: %1").arg(errstr);
       emit connectFailed(tr("Vidalia was unable to connect to Tor. (%1)")
                                                              .arg(errstr));
       setStatus(Disconnected);
@@ -148,12 +144,12 @@
   } else if (error == QAbstractSocket::RemoteHostClosedError) {
     /* Tor closed the connection. This is common when we send a 'shutdown' or
      * 'halt' signal to Tor and doesn't need to be logged as loudly. */
-//    vNotice("Tor closed the control connection.");
+    log::warn("Tor closed the control connection.");
   } else {
     /* Some other error. */
     /*XXX We may want to be emitting these so the GUI thread can learn about
      * them and display an error message. */
-//    vWarn("Control socket error: %1").arg(ControlSocket::toString(error));
+    log::error("Control socket error: %1").arg(ControlSocket::toString(error));
   }
 }
 
@@ -161,7 +157,7 @@
 void
 ControlConnection::cancelConnect()
 {
-//  vNotice("Control connection attempt cancelled.");
+  log::warn("Control connection attempt cancelled.");
   setStatus(Disconnected);
   exit(0);
 }
@@ -203,11 +199,9 @@
 ControlConnection::setStatus(Status status)
 {
   QMutexLocker locker(&_statusMutex);
-#if 0
-  vNotice("Control connection status changed from '%1' to '%2'")
-                                    .arg(statusString(_status))
-                                    .arg(statusString(status));
-#endif
+  log::debug("Control connection status changed from '%1' to '%2'")
+                                       .arg(statusString(_status))
+                                       .arg(statusString(status));
   _status = status;
 }
 
@@ -227,12 +221,12 @@
 
     /* Wait for and get the result, clean up, and return */
     result = w->getResult(&reply, &errstr);
-//    if (!result)
-//      vWarn("Failed to receive control reply: %1").arg(errstr);
+    if (!result)
+      log::error("Failed to receive control reply: %1").arg(errstr);
     delete w;
   } else {
-//    vWarn("Failed to send control command (%1): %2")
-//      .arg(cmd.keyword()).arg(errstr);
+    log::error("Failed to send control command (%1): %2").arg(cmd.keyword())
+                                                        .arg(errstr);
     _recvMutex.unlock();
   }
 
@@ -253,8 +247,8 @@
   /* Check for a valid and connected socket */
   _connMutex.lock();
   if (!_sock || _status != Connected) {
-//    vDebug("Unable to send control command '%1' when socket status is '%2'")
-//                                            .arg(cmd.keyword()).arg(_status);
+    log::warn("Unable to send control command '%1' when socket status is '%2'")
+                                              .arg(cmd.keyword()).arg(_status);
     _connMutex.unlock();
     return err(errmsg, tr("Control socket is not connected."));
   }
@@ -291,14 +285,14 @@
     if (_sock->readReply(reply, &errmsg)) {
       if (reply.getStatus() == "650") {
         /* Asynchronous event message */
-//        vDebug("Control Event: %1").arg(reply.toString());
+        log::debug("Control Event: %1").arg(reply.toString());
         
         if (_events) {
           _events->handleEvent(reply);
         }
       } else {
         /* Response to a previous command */
-//        vInfo("Control Reply: %1").arg(reply.toString());
+        log::debug("Control Reply: %1").arg(reply.toString());
         
         _recvMutex.lock();
         if (!_recvQueue.isEmpty()) {
@@ -308,7 +302,7 @@
         _recvMutex.unlock();
       }
     } else {
-//      vWarn("Unable to read control reply: %1").arg(errmsg);
+      log::error("Unable to read control reply: %1").arg(errmsg);
     }
   }
 }
@@ -375,9 +369,9 @@
   
   /* Attempt to connect to Tor */
   connect();
-//  vDebug("Starting control connection event loop.");
+  log::debug("Starting control connection event loop.");
   exec();
-//  vDebug("Exited control connection event loop.");
+  log::debug("Exited control connection event loop.");
 
   /* Clean up the socket */
   _connMutex.lock();

Modified: vidalia/trunk/src/torcontrol/controlsocket.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/controlsocket.cpp	2008-01-18 21:15:35 UTC (rev 2303)
+++ vidalia/trunk/src/torcontrol/controlsocket.cpp	2008-01-18 21:15:45 UTC (rev 2304)
@@ -26,7 +26,7 @@
  */
 
 #include <stringutil.h>
-//#include <vidalia.h>
+#include "debug.h"
 
 #include "controlsocket.h"
 
@@ -64,7 +64,7 @@
   
   /* Format the control command */
   QString strCmd = cmd.toString();
-//  vInfo("Control Command: %1").arg(strCmd.trimmed());
+  log::debug("Control Command: %1").arg(strCmd.trimmed());
 
   /* Attempt to send the command to Tor */
   if (write(strCmd.toAscii()) != strCmd.length()) {

Modified: vidalia/trunk/src/torcontrol/torevents.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/torevents.cpp	2008-01-18 21:15:35 UTC (rev 2303)
+++ vidalia/trunk/src/torcontrol/torevents.cpp	2008-01-18 21:15:45 UTC (rev 2304)
@@ -27,7 +27,6 @@
 
 #include <QApplication>
 #include <stringutil.h>
-//#include <vidalia.h>
 
 #include "circuit.h"
 #include "stream.h"

Modified: vidalia/trunk/src/torcontrol/torprocess.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/torprocess.cpp	2008-01-18 21:15:35 UTC (rev 2303)
+++ vidalia/trunk/src/torcontrol/torprocess.cpp	2008-01-18 21:15:45 UTC (rev 2304)
@@ -26,8 +26,8 @@
  */
 
 #include <QString>
-//#include <vidalia.h>
 #include <stringutil.h>
+#include "debug.h"
 
 /* Needed for _PROCESS_INFORMATION so that pid() works on Win32 */
 #if defined (Q_OS_WIN32)
@@ -87,7 +87,7 @@
 #endif
   setEnvironment(env);
 
-//  vNotice("Starting Tor using '%1 %2'").arg(app).arg(formatArguments(args));
+  log::debug("Starting Tor using '%1 %2'").arg(app).arg(formatArguments(args));
   QProcess::start(exe, args, QIODevice::ReadOnly | QIODevice::Text);
 }
 
@@ -101,7 +101,7 @@
     return true;
   }
 
-//  vNotice("Stopping the Tor process.");
+  log::debug("Stopping the Tor process.");
   /* Tell the process to stop */
 #if defined(Q_OS_WIN32)
   /* Tor on Windows doesn't understand a WM_CLOSE message (which is what 
@@ -112,7 +112,7 @@
 
   /* Wait for it to complete */
   if (!waitForFinished(5000)) {
-//    vWarn("Tor failed to stop: %1").arg(errorString());
+    log::error("Tor failed to stop: %1").arg(errorString());
     if (errmsg) {
       *errmsg = 
         tr("Process %1 failed to stop. [%2]").arg(pid()).arg(errorString());
@@ -181,11 +181,11 @@
 TorProcess::onError(QProcess::ProcessError error)
 {
   if (error == QProcess::FailedToStart) {
-//    vWarn("The Tor process failed to start: %1").arg(errorString());
+    log::error("The Tor process failed to start: %1").arg(errorString());
     /* Tor didn't start, so let everyone know why. */
     emit startFailed(errorString());
   } else {
-//    vWarn("Tor process error: %1").arg(errorString());
+    log::error("Tor process error: %1").arg(errorString());
   }
 }
 

Modified: vidalia/trunk/src/torcontrol/torservice.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/torservice.cpp	2008-01-18 21:15:35 UTC (rev 2303)
+++ vidalia/trunk/src/torcontrol/torservice.cpp	2008-01-18 21:15:45 UTC (rev 2304)
@@ -27,6 +27,7 @@
 
 #include <QLibrary>
 
+#include "debug.h"
 #include "torservice.h"
 
 /** Returned by TorService::exitCode() when we are unable to determine the
@@ -149,7 +150,7 @@
   SC_HANDLE service = openService();
 
   if (!service) {
-//    vWarn("Bug: We tried to start the Tor service, but it is not installed.");
+    log::error("Bug: We tried to start the Tor service, but it is not installed.");
     emit startFailed(tr("The Tor service is not installed."));
     return;
   }
@@ -157,7 +158,7 @@
   /* Starting a service can take up to 30 seconds! */
   if (status() != SERVICE_RUNNING) {
     int tries = 0;
-//    vNotice("Starting the Tor service.");
+    log::debug("Starting the Tor service.");
     _service_fns.StartServiceA(service, 0, NULL);
 
     while ((status() != SERVICE_RUNNING) && ++tries <= 5)
@@ -167,7 +168,7 @@
   if (status() == SERVICE_RUNNING) {
     emit started();
   } else {
-//    vWarn("Unable to start the Tor service.");
+    log::error("Unable to start the Tor service.");
     emit startFailed(tr("Unable to start the Tor service."));
   }
   closeHandle(service);
@@ -185,7 +186,7 @@
   if (status() != SERVICE_STOPPED) {
     SERVICE_STATUS stat;
     stat.dwCurrentState = SERVICE_RUNNING;
-//    vNotice("Stopping the Tor service.");
+    log::debug("Stopping the Tor service.");
     if (_service_fns.ControlService(service, SERVICE_CONTROL_STOP, &stat)) {
       /* XXX Five seconds isn't long enough to wait when we're stopping a Tor
        * that is running as a server, but we don't want to block for 30
@@ -204,7 +205,7 @@
     return true;
   }
   /* XXX This needs an actual reason message. */
-//  vWarn("Unable to stop the Tor service.");
+  log::error("Unable to stop the Tor service.");
   return false;
 }
 
@@ -261,8 +262,8 @@
                                                  .arg(torrc)
                                                  .arg(controlPort);
 
-//    vNotice("Installing the Tor service using the command line '%1'")
-//                                                        .arg(command);
+    log::debug("Installing the Tor service using the command line '%1'")
+                                                          .arg(command);
     service = _service_fns.CreateServiceA(_scm, 
                               (LPCTSTR)TOR_SERVICE_NAME, (LPCTSTR)TOR_SERVICE_DISP,
                               TOR_SERVICE_ACCESS, SERVICE_WIN32_OWN_PROCESS,
@@ -271,7 +272,7 @@
                               NULL, NULL);
     if (!service) {
       /* XXX This needs an actual reason message. */
-//      vWarn("Failed to install the Tor service.");
+      log::error("Failed to install the Tor service.");
       return false;
     }
 
@@ -294,13 +295,13 @@
 
   if (service) {
     stop();
-//    vNotice("Removing the Tor service.");
+    log::debug("Removing the Tor service.");
     removed = _service_fns.DeleteService(service);
     closeHandle(service);
   }
   if (!removed) {
     /* XXX This needs an actual reason message. */
-//    vWarn("Failed to remove the Tor service.");
+    log::error("Failed to remove the Tor service.");
   }
   return removed;
 }