Reduce the priority of debugging messages going to the console

These messages are in the normal (non-error) path and add to the
cout/cerr noise.

By default, `cfx run` has its output level set to `info` which
excludes the debug messages. To change this, set the
`extensions.sdk.console.logLevel` pref to `debug` or `all`.

https://developer.mozilla.org/Add-ons/SDK/Tools/console#Logging_Levels
This commit is contained in:
Francois Marier 2014-04-24 16:20:44 +12:00
Родитель 749cea2ae6
Коммит 612ff46995
8 изменённых файлов: 24 добавлений и 25 удалений

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

@ -29,9 +29,9 @@ aggregate.nodemap = {};
aggregate.edgemap = {}; aggregate.edgemap = {};
function resetData() { function resetData() {
console.log('aggregate::resetData'); console.debug('aggregate::resetData');
aggregate.getBlockedDomains().forEach(function (domain) { aggregate.getBlockedDomains().forEach(function (domain) {
console.log("deleting", domain); console.debug("deleting", domain);
delete userSettings[domain]; delete userSettings[domain];
}); });
aggregate.nodemap = {}; aggregate.nodemap = {};
@ -54,7 +54,7 @@ aggregate.getBlockedDomains = function () {
aggregate.getAllNodes = function () { aggregate.getAllNodes = function () {
var blockedDomains = aggregate.getBlockedDomains(); var blockedDomains = aggregate.getBlockedDomains();
console.log("getAllNodes", JSON.stringify(blockedDomains)); console.debug("getAllNodes", JSON.stringify(blockedDomains));
return aggregate.nodes.concat(blockedDomains.map(function (domain) { return aggregate.nodes.concat(blockedDomains.map(function (domain) {
return { return {
@ -126,7 +126,7 @@ aggregate.connectionAsObject = function (conn) {
// visualizations. // visualizations.
function onLoad(connections) { function onLoad(connections) {
var startTime = Date.now(); var startTime = Date.now();
console.log("aggregate::onLoad", connections.length, "connections", aggregate.currentFilter); console.debug("aggregate::onLoad", connections.length, "connections", aggregate.currentFilter);
connections.forEach(onConnection); connections.forEach(onConnection);
aggregate.initialized = true; aggregate.initialized = true;
filteredAggregate = aggregate.filters[aggregate.currentFilter](); filteredAggregate = aggregate.filters[aggregate.currentFilter]();
@ -136,11 +136,11 @@ function onLoad(connections) {
global.currentVisualization.emit('init'); global.currentVisualization.emit('init');
} }
updateStatsBar(); updateStatsBar();
console.log('aggregate::onLoad end, took %s ms', Date.now() - startTime); console.debug('aggregate::onLoad end, took %s ms', Date.now() - startTime);
} }
function updateUIFromPrefs(prefs) { function updateUIFromPrefs(prefs) {
console.log("in aggregate prefs"); console.debug("in aggregate prefs");
global.updateUIFromPrefs(prefs); global.updateUIFromPrefs(prefs);
} }

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

@ -23,12 +23,12 @@ self.port.on('update-blocklist-all', function (domains) {
}); });
self.port.on('init', function () { self.port.on('init', function () {
console.log('content-script::init()'); console.debug('content-script::init()');
global.aggregate.emit('load', global.allConnections); global.aggregate.emit('load', global.allConnections);
}); });
self.port.on("updateUIFromPrefs", function (prefs) { self.port.on("updateUIFromPrefs", function (prefs) {
console.log("Got set prefs", prefs); console.debug("Got set prefs", prefs);
global.aggregate.emit("updateUIFromPrefs", prefs); global.aggregate.emit("updateUIFromPrefs", prefs);
}); });
})(this); })(this);

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

@ -86,12 +86,12 @@ global.elem = function elem(name, attributes, children) {
}; };
window.addEventListener('load', function (evt) { window.addEventListener('load', function (evt) {
console.log('window onload'); console.debug('window onload');
self.port.emit('uiready'); self.port.emit('uiready');
// Wire up events // Wire up events
document.querySelector('[data-value=Graph]').setAttribute("data-selected", true); document.querySelector('[data-value=Graph]').setAttribute("data-selected", true);
var visualizationName = "graph"; var visualizationName = "graph";
console.log("current vis", visualizationName); console.debug("current vis", visualizationName);
g.currentVisualization = visualizations[visualizationName]; g.currentVisualization = visualizations[visualizationName];
switchVisualization(visualizationName); switchVisualization(visualizationName);
}); });
@ -102,7 +102,7 @@ function initCap(str) {
global.switchVisualization = function switchVisualization(name) { global.switchVisualization = function switchVisualization(name) {
// var startTime = Date.now(); // var startTime = Date.now();
console.log('switchVisualizations(' + name + ')'); console.debug('switchVisualizations(' + name + ')');
if (g.currentVisualization != visualizations[name]) { if (g.currentVisualization != visualizations[name]) {
g.currentVisualization.emit('remove'); g.currentVisualization.emit('remove');
} }

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

@ -20,7 +20,7 @@ list.on("showFilteredTable", function (filter) {
list.on('reset', onReset); list.on('reset', onReset);
function onReset() { function onReset() {
console.log("reset list"); console.debug("reset list");
breadcrumbStack = []; breadcrumbStack = [];
onRemove(); onRemove();
aggregate.emit('load', global.allConnections); aggregate.emit('load', global.allConnections);
@ -302,7 +302,7 @@ function resetSelectedRows() {
var lastFilter = null; var lastFilter = null;
function showFilteredTable(filter) { function showFilteredTable(filter) {
console.log("showFilteredTable", filter); console.debug("showFilteredTable", filter);
if (lastFilter != filter) updateBreadcrumb(filter); if (lastFilter != filter) updateBreadcrumb(filter);
lastFilter = filter; lastFilter = filter;
// remove existing table tbodys, if any // remove existing table tbodys, if any
@ -311,7 +311,7 @@ function showFilteredTable(filter) {
var tbodyParent = tbody.parentElement; var tbodyParent = tbody.parentElement;
tbodyParent.removeChild(tbody); tbodyParent.removeChild(tbody);
var nodes = getNodes(filter); var nodes = getNodes(filter);
console.log("getNodes", nodes); console.debug("getNodes", nodes);
tbodyParent.appendChild(createBody(nodes)); tbodyParent.appendChild(createBody(nodes));
// update other UI elements // update other UI elements
document.querySelector('.selected-header').checked = false; document.querySelector('.selected-header').checked = false;

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

@ -467,7 +467,7 @@ function updateUIFromPrefs(event) {
if ("defaultVisualization" in event) { if ("defaultVisualization" in event) {
global.currentVisualization = visualizations[event["defaultVisualization"]]; global.currentVisualization = visualizations[event["defaultVisualization"]];
if (global.currentVisualization) { if (global.currentVisualization) {
console.log("Got viz"); console.debug("Got viz");
} else { } else {
console.error("NO viz"); console.error("NO viz");
} }

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

@ -38,12 +38,11 @@ function addConnection(connection) {
if (connBatch.length == connBatchSize) { if (connBatch.length == connBatchSize) {
flushToStorage(); flushToStorage();
} }
console.log("got", connBatch.length, "connections"); console.debug("got", connBatch.length, "connections");
} }
exports.getAllConnections = function getAllConnections() { exports.getAllConnections = function getAllConnections() {
console.log("got", connBatch.length, "buffered connections", console.debug("got", connBatch.length, "buffered connections", ss.storage.connections.length, "persisted connections");
ss.storage.connections.length, "persisted connections");
return ss.storage.connections.concat(connBatch); return ss.storage.connections.concat(connBatch);
} }
@ -54,7 +53,7 @@ function excludePrivateConnections(connections) {
} }
function flushToStorage() { function flushToStorage() {
console.log("flushing", connBatch.length, "buffered connections"); console.debug("flushing", connBatch.length, "buffered connections");
persist.storeConnections(excludePrivateConnections(connBatch)); persist.storeConnections(excludePrivateConnections(connBatch));
connBatch.length = 0; connBatch.length = 0;
} }
@ -145,7 +144,7 @@ Connection.prototype.restoreFromSubject = function (event) {
try { try {
var tab = getTabForChannel(channel); var tab = getTabForChannel(channel);
} catch (e) { } catch (e) {
console.log('EXCEPTION CAUGHT: No tab for connection'); console.debug('EXCEPTION CAUGHT: No tab for connection');
tab = null; tab = null;
} }
var isAjax = getAjaxRequestHeader(channel); var isAjax = getAjaxRequestHeader(channel);

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

@ -25,7 +25,7 @@ function serializeConnections(connections) {
} }
function upload(connections) { function upload(connections) {
console.log("received upload event in addon"); console.debug("received upload event in addon");
let uploadServer = 'https://data.mozilla.com/submit/lightbeam'; let uploadServer = 'https://data.mozilla.com/submit/lightbeam';
let request = Request({ let request = Request({
url: uploadServer, url: uploadServer,
@ -33,7 +33,7 @@ function upload(connections) {
onComplete: function (response) { onComplete: function (response) {
let status = Number(response.status); let status = Number(response.status);
if (status >= 200 && status < 300) { if (status >= 200 && status < 300) {
console.log("successful upload: ", response.text); console.debug("successful upload: ", response.text);
} else { } else {
// Ignore errors for now. We could save last upload time and try // Ignore errors for now. We could save last upload time and try
// uploading again the ones that failed previously. // uploading again the ones that failed previously.

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

@ -128,7 +128,7 @@ function hasPrivateTab() {
// Connect the tab to the content script of the UI page. There may only ever be // Connect the tab to the content script of the UI page. There may only ever be
// one UI page. // one UI page.
function attachToLightbeamPage(worker) { function attachToLightbeamPage(worker) {
console.log("Attaching to lightbeam page"); console.debug("Attaching to lightbeam page");
uiworker = worker; uiworker = worker;
// The blocklist is maintained on both sides to reduce latency. However, // The blocklist is maintained on both sides to reduce latency. However,
@ -259,7 +259,7 @@ exports.openOrSwitchToOrClose = openOrSwitchToOrClose;
// Set up the status bar button to open the main UI page: // Set up the status bar button to open the main UI page:
var button; var button;
if (usingAustralis) { if (usingAustralis) {
console.log("Using australis"); console.debug("Using australis");
button = ActionButton({ button = ActionButton({
id: "lightbeam_Widget", id: "lightbeam_Widget",
label: "Lightbeam", label: "Lightbeam",
@ -275,7 +275,7 @@ if (usingAustralis) {
} }
}); });
} else { } else {
console.log("Not using australis"); console.debug("Not using australis");
button = Widget({ button = Widget({
id: "lightbeam_Widget", id: "lightbeam_Widget",
label: "Lightbeam", label: "Lightbeam",