[tbb-commits] [tor-launcher/master] Bug 9516: Show Tor log in TorBrowser

brade at torproject.org brade at torproject.org
Thu Jul 31 18:22:52 UTC 2014


commit 423552fe7009ebe8bd61f92ca525018c124a1b56
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Thu Jul 31 14:18:56 2014 -0400

    Bug 9516: Show Tor log in TorBrowser
    
    Provide a stopgap solution:  route all tor messages captured by
    Tor Launcher to the Browser Console.
---
 src/components/tl-protocol.js |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/components/tl-protocol.js b/src/components/tl-protocol.js
index 85a0165..9c4d957 100644
--- a/src/components/tl-protocol.js
+++ b/src/components/tl-protocol.js
@@ -25,6 +25,12 @@ function TorProtocolService()
 
   try
   {
+    this.mConsoleSvc = Cc["@mozilla.org/consoleservice;1"]
+                         .getService(Ci.nsIConsoleService);
+  } catch (e) {}
+
+  try
+  {
     var env = Cc["@mozilla.org/process/environment;1"]
                 .getService(Ci.nsIEnvironment);
 
@@ -496,6 +502,7 @@ TorProtocolService.prototype =
 
 
   // Private Member Variables ////////////////////////////////////////////////
+  mConsoleSvc: null,
   mControlPort: null,
   mControlHost: null,
   mControlPassword: null,     // JS string that contains hex-encoded password.
@@ -1295,6 +1302,15 @@ TorProtocolService.prototype =
               this.mTorLog.splice(0, 1);
           }
           this.mTorLog.push(logObj);
+
+          // We could use console.info(), console.error(), and console.warn()
+          // but when those functions are used the console output includes
+          // extraneous double quotes.  See Mozilla bug # 977586.
+          if (this.mConsoleSvc)
+          {
+            let s = "Tor " + logObj.type + ": " + logObj.msg;
+            this.mConsoleSvc.logStringMessage(s);
+          }
           break;
         case "STATUS_CLIENT":
           this._parseBootstrapStatus(msg);



More information about the tbb-commits mailing list