Bug 1049774 - GMPInstallManager logs when logging disabled. r=gfritzsche

This commit is contained in:
Brian R. Bondy 2014-09-15 20:25:12 -04:00
Родитель 9a1ec24aef
Коммит 70f2e5e54b
1 изменённых файлов: 18 добавлений и 18 удалений

Просмотреть файл

@ -32,10 +32,16 @@ this.EXPORTED_SYMBOLS = ["GMPInstallManager", "GMPExtractor", "GMPDownloader",
var gLocale = null;
const PARENT_LOGGER_ID = "GMPInstallManager";
// Used to determine if logging should be enabled
XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function() {
return Preferences.get("media.gmp-manager.log", false);
});
// Setup the parent logger with dump logging. It'll only be used if logging is
// enabled though.
// enabled though. We don't actually have any fatal logging errors, so setting
// the log level to fatal effectively disables it.
let parentLogger = Log.repository.getLogger(PARENT_LOGGER_ID);
parentLogger.level = Log.Level.Debug;
parentLogger.level = gLogEnabled ? Log.Level.Debug : Log.Level.Fatal;
let appender = new Log.DumpAppender();
parentLogger.addAppender(appender);
@ -49,18 +55,12 @@ XPCOMUtils.defineLazyGetter(this, "gCertUtils", function() {
XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel",
"resource://gre/modules/UpdateChannel.jsm");
// Used to determine if logging should be enabled
XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function() {
return GMPPrefs.get(GMPPrefs.KEY_LOG_ENABLED);
});
function getScopedLogger(prefix) {
var parentScope = gLogEnabled ? PARENT_LOGGER_ID + "." : "";
return Log.repository.getLogger(parentScope + prefix);
// `PARENT_LOGGER_ID.` being passed here effectively links this logger
// to the parentLogger.
return Log.repository.getLogger(PARENT_LOGGER_ID + "." + prefix);
}
/**
* Manages preferences for GMP addons
*/
@ -294,7 +294,7 @@ GMPInstallManager.prototype = {
* Obtains a URL with replacement of vars
*/
_getURL: function() {
let log = getScopedLogger("GMPInstallManager._getURL");
let log = getScopedLogger("_getURL");
// Use the override URL if it is specified. The override URL is just like
// the normal URL but it does not check the cert.
let url = GMPPrefs.get(GMPPrefs.KEY_URL_OVERRIDE);
@ -336,7 +336,7 @@ GMPInstallManager.prototype = {
* type: Sometimes specifies type of rejection
*/
checkForAddons: function() {
let log = getScopedLogger("GMPInstallManager.checkForAddons");
let log = getScopedLogger("checkForAddons");
if (this._deferred) {
log.error("checkForAddons already called");
return Promise.reject({type: "alreadycalled"});
@ -419,7 +419,7 @@ GMPInstallManager.prototype = {
* This will only install/update the OpenH264 plugin
*/
simpleCheckAndInstall: function() {
let log = getScopedLogger("GMPInstallManager.simpleCheckAndInstall");
let log = getScopedLogger("simpleCheckAndInstall");
let autoUpdate = GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE,
OPEN_H264_ID, true);
@ -505,7 +505,7 @@ GMPInstallManager.prototype = {
* @param event The nsIDOMEvent for the load
*/
onLoadXML: function(event) {
let log = getScopedLogger("GMPInstallManager.onLoadXML");
let log = getScopedLogger("onLoadXML");
log.info("request completed downloading document");
let certs = null;
@ -526,7 +526,7 @@ GMPInstallManager.prototype = {
* Returns the status code for the XMLHttpRequest
*/
_getChannelStatus: function(request) {
let log = getScopedLogger("GMPInstallManager._getChannelStatus");
let log = getScopedLogger("_getChannelStatus");
let status = 0;
try {
status = request.status;
@ -546,7 +546,7 @@ GMPInstallManager.prototype = {
* @param event The nsIDOMEvent for the error
*/
onErrorXML: function(event) {
let log = getScopedLogger("GMPInstallManager.onErrorXML");
let log = getScopedLogger("onErrorXML");
let request = event.target;
let status = this._getChannelStatus(request);
let message = "request.status: " + status;
@ -566,7 +566,7 @@ GMPInstallManager.prototype = {
*/
parseResponseXML: function() {
try {
let log = getScopedLogger("GMPInstallManager.parseResponseXML");
let log = getScopedLogger("parseResponseXML");
let updatesElement = this._request.responseXML.documentElement;
if (!updatesElement) {
let message = "empty updates document";