@@ -27,6 +27,8 @@ const SERVICE_CTRID = "@eff.org/https-everywhere;1";
2727const SERVICE_ID = Components . ID ( "{32c165b4-fe5e-4964-9250-603c410631b4}" ) ;
2828const SERVICE_NAME = "Encrypts your communications with a number of major websites" ;
2929
30+ const LLVAR = "LogLevel" ;
31+
3032const IOS = CC [ "@mozilla.org/network/io-service;1" ] . getService ( CI . nsIIOService ) ;
3133const OS = CC [ '@mozilla.org/observer-service;1' ] . getService ( CI . nsIObserverService ) ;
3234const LOADER = CC [ "@mozilla.org/moz/jssubscript-loader;1" ] . getService ( CI . mozIJSSubScriptLoader ) ;
@@ -94,9 +96,6 @@ const DUMMYOBJ = {};
9496
9597const EARLY_VERSION_CHECK = ! ( "nsISessionStore" in CI && typeof ( / / ) === "object" ) ;
9698
97-
98-
99-
10099function xpcom_generateQI ( iids ) {
101100 var checks = [ ] ;
102101 for each ( var iid in iids ) {
@@ -300,41 +299,55 @@ HTTPSEverywhere.prototype = {
300299 var branch_name = "extensions.https_everywhere." ;
301300 var o_prefs = false ;
302301 var o_branch = false ;
302+ // this function needs to be called from inside https_everywhereLog, so
303+ // it needs to do its own logging...
304+ var econsole = Components . classes [ "@mozilla.org/consoleservice;1" ]
305+ . getService ( Components . interfaces . nsIConsoleService ) ;
303306
304- this . log ( 1 , "called get_prefbranch()" ) ;
305307 o_prefs = Components . classes [ "@mozilla.org/preferences-service;1" ]
306308 . getService ( Components . interfaces . nsIPrefService ) ;
309+
307310 if ( ! o_prefs )
308311 {
309- this . log ( WARN , " Failed to get preferences-service!") ;
312+ econsole . logStringMessage ( "HTTPS Everywhere: Failed to get preferences-service!") ;
310313 return false ;
311314 }
312315
313316 o_branch = o_prefs . getBranch ( branch_name ) ;
314317 if ( ! o_branch )
315318 {
316- this . log ( WARN , " Failed to get prefs branch!") ;
319+ econsole . logStringMessage ( "HTTPS Everywhere: Failed to get prefs branch!") ;
317320 return false ;
318321 }
319322
323+ // make sure there's an entry for our log level
324+ try {
325+ o_branch . getIntPref ( LLVAR ) ;
326+ } catch ( e ) {
327+ econsole . logStringMessage ( "Creating new about:config https_everywhere.LogLevel variable" ) ;
328+ o_branch . setIntPref ( LLVAR , WARN ) ;
329+ }
330+
320331 return o_branch ;
321332 } ,
322333
323334} ;
324335
325- const LLVAR = "LogLevel" ;
326- var prefs = HTTPSEverywhere . instance . get_prefs ( ) ;
327- try {
328- prefs . getBoolPref ( LLVAR ) ;
329- } catch ( e ) {
330- prefs . setBoolPref ( LLVAR , true ) ;
331- }
332-
336+ var prefs = 0 ;
333337function https_everywhereLog ( level , str ) {
334- if ( level >= prefs . getBoolPref ( LLVAR ) ) {
338+ var econsole = Components . classes [ "@mozilla.org/consoleservice;1" ]
339+ . getService ( Components . interfaces . nsIConsoleService ) ;
340+ if ( prefs == 0 ) {
341+ prefs = HTTPSEverywhere . instance . get_prefs ( ) ;
342+ }
343+ try {
344+ var threshold = prefs . getIntPref ( LLVAR ) ;
345+ } catch ( e ) {
346+ econsole . logStringMessage ( "HTTPS Everywhere: Failed to read about:config LogLevel" ) ;
347+ threshold = WARN ;
348+ }
349+ if ( level >= threshold ) {
335350 dump ( str + "\n" ) ;
336- var econsole = Components . classes [ "@mozilla.org/consoleservice;1" ]
337- . getService ( Components . interfaces . nsIConsoleService ) ;
338351 econsole . logStringMessage ( "HTTPS Everywhere: " + str ) ;
339352 }
340353}
0 commit comments