Bug 412990: Re-enable search service logging for opt builds (without the performance hit of checking the pref for each LOG call), r=mano, a=schrep
git-svn-id: svn://10.0.0.236/trunk@244369 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -201,11 +201,21 @@ function isUsefulLine(aLine) {
|
||||
const SEARCH_LOG_PREFIX = "*** Search: ";
|
||||
|
||||
/**
|
||||
* Outputs aText to the JavaScript console as well as to stdout, if the search
|
||||
* logging pref (browser.search.log) is set to true.
|
||||
* Outputs aText to the JavaScript console as well as to stdout.
|
||||
*/
|
||||
function LOG(aText) {
|
||||
function DO_LOG(aText) {
|
||||
dump(SEARCH_LOG_PREFIX + aText + "\n");
|
||||
var consoleService = Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService);
|
||||
consoleService.logStringMessage(aText);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* In debug builds, use a live, pref-based (browser.search.log) LOG function
|
||||
* to allow enabling/disabling without a restart.
|
||||
*/
|
||||
function PREF_LOG(aText) {
|
||||
var prefB = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
var shouldLog = false;
|
||||
@@ -214,13 +224,20 @@ function LOG(aText) {
|
||||
} catch (ex) {}
|
||||
|
||||
if (shouldLog) {
|
||||
dump(SEARCH_LOG_PREFIX + aText + "\n");
|
||||
var consoleService = Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService);
|
||||
consoleService.logStringMessage(aText);
|
||||
DO_LOG(aText);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
var LOG = PREF_LOG;
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Otherwise, don't log at all by default. This can be overridden at startup
|
||||
* by the pref, see SearchService's _init method.
|
||||
*/
|
||||
var LOG = function(){};
|
||||
|
||||
#endif
|
||||
|
||||
function ERROR(message, resultCode) {
|
||||
NS_ASSERT(false, SEARCH_LOG_PREFIX + message);
|
||||
@@ -2203,6 +2220,18 @@ SearchService.prototype = {
|
||||
_needToSetOrderPrefs: false,
|
||||
|
||||
_init: function() {
|
||||
var prefB = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
var shouldLog = false;
|
||||
try {
|
||||
shouldLog = prefB.getBoolPref(BROWSER_SEARCH_PREF + "log");
|
||||
} catch (ex) {}
|
||||
|
||||
if (shouldLog) {
|
||||
// Replace the empty LOG function with the useful one
|
||||
LOG = DO_LOG;
|
||||
}
|
||||
|
||||
engineMetadataService.init();
|
||||
engineUpdateService.init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user