[or-cvs] r11741: Change window mapper log messages to check loglevel. (torbutton/trunk/src/components)
mikeperry at seul.org
mikeperry at seul.org
Tue Oct 2 06:21:28 UTC 2007
Author: mikeperry
Date: 2007-10-02 02:21:27 -0400 (Tue, 02 Oct 2007)
New Revision: 11741
Modified:
torbutton/trunk/src/components/window-mapper.js
Log:
Change window mapper log messages to check loglevel.
Modified: torbutton/trunk/src/components/window-mapper.js
===================================================================
--- torbutton/trunk/src/components/window-mapper.js 2007-10-02 06:03:40 UTC (rev 11740)
+++ torbutton/trunk/src/components/window-mapper.js 2007-10-02 06:21:27 UTC (rev 11741)
@@ -22,9 +22,20 @@
this.cache = new Object();
this.cache["bah"] = 0;
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ this._loglevel = prefs.getIntPref("extensions.torbutton.loglevel");
+
+ this.log = function(str) {
+ // TODO: This could be done better/unified with the main log system..
+ if(this._loglevel <= 2) {
+ dump(str);
+ }
+ },
+
this.checkCache = function(topContentWindow) {
if(typeof(this.cache[topContentWindow]) != "undefined") {
- dump("Found cached element\n");
+ this.log("Found cached element\n");
return this.cache[topContentWindow].browser;
}
@@ -36,7 +47,7 @@
insertion.browser = browser;
insertion.time = Date.now();
this.cache[topContentWindow] = insertion;
- dump("Cached element\n");
+ this.log("Cached element\n");
};
this.expireOldCache = function() {
@@ -44,7 +55,7 @@
for(var elem in this.cache) {
if((now - this.cache[elem].time) > EXPIRATION_TIME) {
- dump("Deleting expired entry\n");
+ this.log("Deleting expired entry\n");
delete this.cache[elem];
}
}
@@ -70,9 +81,9 @@
}
if(topContentWindow && topContentWindow.document && topContentWindow.document.location)
- dump("No browser found: "+topContentWindow.document.location+"\n");
+ this.log("No browser found: "+topContentWindow.document.location+"\n");
else
- dump("No browser found!\n");
+ this.log("No browser found!\n");
return null;
};
More information about the tor-commits
mailing list