From 612ff469956e4ca6f9040dd1442596a360a8fe44 Mon Sep 17 00:00:00 2001 From: Francois Marier Date: Thu, 24 Apr 2014 16:20:44 +1200 Subject: [PATCH] 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 --- data/aggregate.js | 12 ++++++------ data/content-script.js | 4 ++-- data/lightbeam.js | 6 +++--- data/list.js | 6 +++--- data/ui.js | 2 +- lib/connection.js | 9 ++++----- lib/persist.js | 4 ++-- lib/ui.js | 6 +++--- 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/data/aggregate.js b/data/aggregate.js index ca5646e..a4ad4d9 100644 --- a/data/aggregate.js +++ b/data/aggregate.js @@ -29,9 +29,9 @@ aggregate.nodemap = {}; aggregate.edgemap = {}; function resetData() { - console.log('aggregate::resetData'); + console.debug('aggregate::resetData'); aggregate.getBlockedDomains().forEach(function (domain) { - console.log("deleting", domain); + console.debug("deleting", domain); delete userSettings[domain]; }); aggregate.nodemap = {}; @@ -54,7 +54,7 @@ aggregate.getBlockedDomains = function () { aggregate.getAllNodes = function () { 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 { @@ -126,7 +126,7 @@ aggregate.connectionAsObject = function (conn) { // visualizations. function onLoad(connections) { 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); aggregate.initialized = true; filteredAggregate = aggregate.filters[aggregate.currentFilter](); @@ -136,11 +136,11 @@ function onLoad(connections) { global.currentVisualization.emit('init'); } 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) { - console.log("in aggregate prefs"); + console.debug("in aggregate prefs"); global.updateUIFromPrefs(prefs); } diff --git a/data/content-script.js b/data/content-script.js index 8660c0a..049b737 100644 --- a/data/content-script.js +++ b/data/content-script.js @@ -23,12 +23,12 @@ self.port.on('update-blocklist-all', function (domains) { }); self.port.on('init', function () { - console.log('content-script::init()'); + console.debug('content-script::init()'); global.aggregate.emit('load', global.allConnections); }); self.port.on("updateUIFromPrefs", function (prefs) { - console.log("Got set prefs", prefs); + console.debug("Got set prefs", prefs); global.aggregate.emit("updateUIFromPrefs", prefs); }); })(this); diff --git a/data/lightbeam.js b/data/lightbeam.js index 554f0cb..c60ccf4 100644 --- a/data/lightbeam.js +++ b/data/lightbeam.js @@ -86,12 +86,12 @@ global.elem = function elem(name, attributes, children) { }; window.addEventListener('load', function (evt) { - console.log('window onload'); + console.debug('window onload'); self.port.emit('uiready'); // Wire up events document.querySelector('[data-value=Graph]').setAttribute("data-selected", true); var visualizationName = "graph"; - console.log("current vis", visualizationName); + console.debug("current vis", visualizationName); g.currentVisualization = visualizations[visualizationName]; switchVisualization(visualizationName); }); @@ -102,7 +102,7 @@ function initCap(str) { global.switchVisualization = function switchVisualization(name) { // var startTime = Date.now(); - console.log('switchVisualizations(' + name + ')'); + console.debug('switchVisualizations(' + name + ')'); if (g.currentVisualization != visualizations[name]) { g.currentVisualization.emit('remove'); } diff --git a/data/list.js b/data/list.js index 69e3852..10af0aa 100644 --- a/data/list.js +++ b/data/list.js @@ -20,7 +20,7 @@ list.on("showFilteredTable", function (filter) { list.on('reset', onReset); function onReset() { - console.log("reset list"); + console.debug("reset list"); breadcrumbStack = []; onRemove(); aggregate.emit('load', global.allConnections); @@ -302,7 +302,7 @@ function resetSelectedRows() { var lastFilter = null; function showFilteredTable(filter) { - console.log("showFilteredTable", filter); + console.debug("showFilteredTable", filter); if (lastFilter != filter) updateBreadcrumb(filter); lastFilter = filter; // remove existing table tbodys, if any @@ -311,7 +311,7 @@ function showFilteredTable(filter) { var tbodyParent = tbody.parentElement; tbodyParent.removeChild(tbody); var nodes = getNodes(filter); - console.log("getNodes", nodes); + console.debug("getNodes", nodes); tbodyParent.appendChild(createBody(nodes)); // update other UI elements document.querySelector('.selected-header').checked = false; diff --git a/data/ui.js b/data/ui.js index ade3db5..b881c27 100644 --- a/data/ui.js +++ b/data/ui.js @@ -467,7 +467,7 @@ function updateUIFromPrefs(event) { if ("defaultVisualization" in event) { global.currentVisualization = visualizations[event["defaultVisualization"]]; if (global.currentVisualization) { - console.log("Got viz"); + console.debug("Got viz"); } else { console.error("NO viz"); } diff --git a/lib/connection.js b/lib/connection.js index b685080..726873d 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -38,12 +38,11 @@ function addConnection(connection) { if (connBatch.length == connBatchSize) { flushToStorage(); } - console.log("got", connBatch.length, "connections"); + console.debug("got", connBatch.length, "connections"); } exports.getAllConnections = function getAllConnections() { - console.log("got", connBatch.length, "buffered connections", - ss.storage.connections.length, "persisted connections"); + console.debug("got", connBatch.length, "buffered connections", ss.storage.connections.length, "persisted connections"); return ss.storage.connections.concat(connBatch); } @@ -54,7 +53,7 @@ function excludePrivateConnections(connections) { } function flushToStorage() { - console.log("flushing", connBatch.length, "buffered connections"); + console.debug("flushing", connBatch.length, "buffered connections"); persist.storeConnections(excludePrivateConnections(connBatch)); connBatch.length = 0; } @@ -145,7 +144,7 @@ Connection.prototype.restoreFromSubject = function (event) { try { var tab = getTabForChannel(channel); } catch (e) { - console.log('EXCEPTION CAUGHT: No tab for connection'); + console.debug('EXCEPTION CAUGHT: No tab for connection'); tab = null; } var isAjax = getAjaxRequestHeader(channel); diff --git a/lib/persist.js b/lib/persist.js index 1c5fb7c..f27aef9 100644 --- a/lib/persist.js +++ b/lib/persist.js @@ -25,7 +25,7 @@ function serializeConnections(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 request = Request({ url: uploadServer, @@ -33,7 +33,7 @@ function upload(connections) { onComplete: function (response) { let status = Number(response.status); if (status >= 200 && status < 300) { - console.log("successful upload: ", response.text); + console.debug("successful upload: ", response.text); } else { // Ignore errors for now. We could save last upload time and try // uploading again the ones that failed previously. diff --git a/lib/ui.js b/lib/ui.js index cdba8d2..ccd72fe 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -128,7 +128,7 @@ function hasPrivateTab() { // Connect the tab to the content script of the UI page. There may only ever be // one UI page. function attachToLightbeamPage(worker) { - console.log("Attaching to lightbeam page"); + console.debug("Attaching to lightbeam page"); uiworker = worker; // 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: var button; if (usingAustralis) { - console.log("Using australis"); + console.debug("Using australis"); button = ActionButton({ id: "lightbeam_Widget", label: "Lightbeam", @@ -275,7 +275,7 @@ if (usingAustralis) { } }); } else { - console.log("Not using australis"); + console.debug("Not using australis"); button = Widget({ id: "lightbeam_Widget", label: "Lightbeam",