Bug 1159929 - Cache the pref value for devtools.dump.emit in event emitter;r=fitzgen

This commit is contained in:
Brian Grinstead 2015-04-30 07:30:22 -07:00
parent c7e0b742a2
commit 89e2259a7f

View File

@ -25,6 +25,16 @@ module.exports = EventEmitter;
const { Cu, components } = require("chrome");
const Services = require("Services");
const promise = require("promise");
let loggingEnabled = true;
if (!isWorker) {
loggingEnabled = Services.prefs.getBoolPref("devtools.dump.emit");
Services.prefs.addObserver("devtools.dump.emit", {
observe: () => {
loggingEnabled = Services.prefs.getBoolPref("devtools.dump.emit");
}
}, false);
}
/**
* Decorate an object with event emitter functionality.
@ -147,9 +157,10 @@ EventEmitter.prototype = {
},
logEvent: function(aEvent, args) {
let logging = isWorker ? true : Services.prefs.getBoolPref("devtools.dump.emit");
if (!loggingEnabled) {
return;
}
if (logging) {
let caller, func, path;
if (!isWorker) {
caller = components.stack.caller.caller;
@ -200,7 +211,6 @@ EventEmitter.prototype = {
out += "emit" + argOut + " from " + func + "() -> " + path + "\n";
dump(out);
}
},
};