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

brade at torproject.org brade at torproject.org
Fri Aug 1 18:20:49 UTC 2014


commit 40751d8580192902227a447ee89d8018a34800c9
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 bcff6ab..0e78736 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);
 
@@ -497,6 +503,7 @@ TorProtocolService.prototype =
 
 
   // Private Member Variables ////////////////////////////////////////////////
+  mConsoleSvc: null,
   mControlPort: null,
   mControlHost: null,
   mControlPassword: null,     // JS string that contains hex-encoded password.
@@ -1275,6 +1282,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