GUI -- added 'debug' query param and cut out noisy debug console messages by default.

Change-Id: I8b3eff58677a3882c62c7f2267a5258ba2cd2593
This commit is contained in:
Simon Hunt 2015-06-10 16:18:25 -07:00 committed by Gerrit Code Review
parent 53ae34f312
commit 4deb0e8de7
8 changed files with 90 additions and 37 deletions

View File

@ -1,33 +1,44 @@
# Framework related code # Framework related code
- Util - layer
- General Functions
- Key Handler
- Theme Service
- Alert Service
- Preference Service
- Mast
- Masthead
- Svg
- Glyph Service
- Icon Service
- Map Service
- Zoom Service
- Layers
- Flash Service (transient messages) - Flash Service (transient messages)
- Panel Service (floating panels) - Panel Service (floating panels)
- Quick Help Service (key bindings, mouse gestures) - Quick Help Service (key bindings, mouse gestures)
- Death Mask Service (loss of server connection) - Veil Service (loss of server connection)
- Remote - mast
- Login Service - Masthead Service
- nav
- Navigation Service (navigation menu)
- remote
- REST Service
- URL functin Service
- Web Socket Service - Web Socket Service
- Web Socket Event Service
- Web Socket encapsulation
- Widget - (Login Service) << planned
- Table Styling Directives
- svg
- GeoData Service (TopoJSON map functions)
- Glyph Service
- Icon Service
- Map Service
- SVG Utilities Service
- Zoom Service
- util
- General Functions
- Key Handler
- User Preference Service
- Randomization Service
- Theme Service
- widget
- Button Service
- Table Service (table styling directives)
- Table Builder Service - Table Builder Service
- Toolbar Service - Toolbar Service
- Button Service - Tooltip Service

View File

@ -185,16 +185,22 @@
$log.warn('Panel with ID "' + id + '" already exists'); $log.warn('Panel with ID "' + id + '" already exists');
return null; return null;
} }
$log.debug('creating panel:', id, settings); if (fs.debugOn('widget')) {
$log.debug('creating panel:', id, settings);
}
return makePanel(id, settings); return makePanel(id, settings);
} }
function destroyPanel(id) { function destroyPanel(id) {
if (panels[id]) { if (panels[id]) {
$log.debug('destroying panel:', id); if (fs.debugOn('widget')) {
$log.debug('destroying panel:', id);
}
removePanel(id); removePanel(id);
} else { } else {
$log.debug('no panel to destroy:', id); if (fs.debugOn('widget')) {
$log.debug('no panel to destroy:', id);
}
} }
} }

View File

@ -67,6 +67,7 @@
} }
// function that only invokes the veil if the caller is the current view // function that only invokes the veil if the caller is the current view
// TODO: review - is this deprecated ?
function lostServer(ctrlName, msg) { function lostServer(ctrlName, msg) {
if ($route.current.$$route.controller === ctrlName) { if ($route.current.$$route.controller === ctrlName) {
$log.debug('VEIL-service: ', ctrlName); $log.debug('VEIL-service: ', ctrlName);

View File

@ -61,7 +61,9 @@
$log.info('Web socket open - ', url); $log.info('Web socket open - ', url);
vs.hide(); vs.hide();
$log.debug('Sending ' + pendingEvents.length + ' pending event(s)...'); if (fs.debugOn('txrx')) {
$log.debug('Sending ' + pendingEvents.length + ' pending event(s)...');
}
pendingEvents.forEach(function (ev) { pendingEvents.forEach(function (ev) {
_send(ev); _send(ev);
}); });
@ -82,7 +84,9 @@
$log.error('Message.data is not valid JSON', msgEvent.data, e); $log.error('Message.data is not valid JSON', msgEvent.data, e);
return null; return null;
} }
$log.debug(' << *Rx* ', ev.event, ev.payload); if (fs.debugOn('txrx')) {
$log.debug(' << *Rx* ', ev.event, ev.payload);
}
if (h = handlers[ev.event]) { if (h = handlers[ev.event]) {
try { try {
@ -140,7 +144,9 @@
} }
function _send(ev) { function _send(ev) {
$log.debug(' *Tx* >> ', ev.event, ev.payload); if (fs.debugOn('txrx')) {
$log.debug(' *Tx* >> ', ev.event, ev.payload);
}
ws.send(JSON.stringify(ev)); ws.send(JSON.stringify(ev));
} }

View File

@ -20,7 +20,20 @@
(function () { (function () {
'use strict'; 'use strict';
var $window; // injected services
var $window, $log;
// internal state
var debugFlags = {};
function _parseDebugFlags(dbgstr) {
var bits = dbgstr ? dbgstr.split(",") : [];
bits.forEach(function (key) {
debugFlags[key] = true;
});
$log.debug('Debug flags:', dbgstr);
}
function isF(f) { function isF(f) {
return typeof f === 'function' ? f : null; return typeof f === 'function' ? f : null;
@ -186,10 +199,18 @@
.replace(/\.\d*/, '')); .replace(/\.\d*/, ''));
} }
// return true if the given debug flag was specified in the query params
function debugOn(tag) {
return debugFlags[tag];
}
angular.module('onosUtil') angular.module('onosUtil')
.factory('FnService', ['$window', function (_$window_) { .factory('FnService',
['$window', '$location', '$log', function (_$window_, $loc, _$log_) {
$window = _$window_; $window = _$window_;
$log = _$log_;
_parseDebugFlags($loc.search().debug);
return { return {
isF: isF, isF: isF,
@ -201,6 +222,7 @@
areFunctionsNonStrict: areFunctionsNonStrict, areFunctionsNonStrict: areFunctionsNonStrict,
windowSize: windowSize, windowSize: windowSize,
isMobile: isMobile, isMobile: isMobile,
debugOn: debugOn,
find: find, find: find,
inArray: inArray, inArray: inArray,
removeFromArray: removeFromArray, removeFromArray: removeFromArray,

View File

@ -21,7 +21,7 @@
'use strict'; 'use strict';
// injected refs // injected refs
var $log, $cookies; var $log, $cookies, fs;
// internal state // internal state
var cache = {}; var cache = {};
@ -106,14 +106,17 @@
// FORCE cookie to be set by writing directly to document.cookie... // FORCE cookie to be set by writing directly to document.cookie...
document.cookie = name + '=' + encodeURIComponent(str); document.cookie = name + '=' + encodeURIComponent(str);
$log.debug('<<>> Wrote cookie <'+name+'>:', str); if (fs.debugOn('prefs')) {
$log.debug('<<>> Wrote cookie <'+name+'>:', str);
}
} }
angular.module('onosUtil') angular.module('onosUtil')
.factory('PrefsService', ['$log', '$cookies', .factory('PrefsService', ['$log', '$cookies', 'FnService',
function (_$log_, _$cookies_) { function (_$log_, _$cookies_, _fs_) {
$log = _$log_; $log = _$log_;
$cookies = _$cookies_; $cookies = _$cookies_;
fs = _fs_;
return { return {
getPrefs: getPrefs, getPrefs: getPrefs,

View File

@ -70,7 +70,9 @@
cstmWidths[index] = h.attr(colWidth); cstmWidths[index] = h.attr(colWidth);
} }
}); });
$log.debug('Headers with custom widths: ', cstmWidths); if (fs.debugOn('widget')) {
$log.debug('Headers with custom widths: ', cstmWidths);
}
} }
function setTdWidths(elem) { function setTdWidths(elem) {

View File

@ -69,7 +69,9 @@
function startRefresh() { function startRefresh() {
promise = $interval(function () { promise = $interval(function () {
$log.debug('Refreshing ' + root + ' page'); if (fs.debugOn('widget')) {
$log.debug('Refreshing ' + root + ' page');
}
sortCb(o.scope.sortParams); sortCb(o.scope.sortParams);
}, refreshInterval); }, refreshInterval);
} }