add debug switch for console outputs in JS utilRegistry
This commit is contained in:
parent
2c04f6f670
commit
c32fee8a9b
@ -4,6 +4,8 @@
|
||||
var registeredUtils = [];
|
||||
var activeUtilInstances = [];
|
||||
|
||||
var DEBUG_MODE = 2;
|
||||
|
||||
// Registry
|
||||
// (revealing module pattern)
|
||||
window.UtilRegistry = (function() {
|
||||
@ -24,7 +26,13 @@
|
||||
* @param util Object Utility that should be added to the registry
|
||||
*/
|
||||
function registerUtil(util) {
|
||||
console.log('registering util', util);
|
||||
if (DEBUG_MODE > 0) {
|
||||
console.log('registering util "' + util.name + '"');
|
||||
}
|
||||
if (DEBUG_MODE > 2) {
|
||||
console.log({ util });
|
||||
}
|
||||
|
||||
registeredUtils.push(util);
|
||||
}
|
||||
|
||||
@ -41,14 +49,16 @@
|
||||
}
|
||||
|
||||
function setupAllUtils() {
|
||||
console.log('setting up all registered utils');
|
||||
registeredUtils.forEach(function(util) {
|
||||
setupUtil(util);
|
||||
});
|
||||
}
|
||||
|
||||
function setupUtil(util, scope) {
|
||||
console.log('setting up util', { util });
|
||||
if (DEBUG_MODE > 2) {
|
||||
console.log('setting up util', { util });
|
||||
}
|
||||
|
||||
scope = scope || document;
|
||||
|
||||
if (util && typeof util.setup === 'function') {
|
||||
@ -60,7 +70,9 @@
|
||||
try {
|
||||
utilInstance = util.setup(element);
|
||||
} catch(err) {
|
||||
console.warn('Error while trying to initialize a utility!', { util , element, err });
|
||||
if (DEBUG_MODE > 0) {
|
||||
console.warn('Error while trying to initialize a utility!', { util , element, err });
|
||||
}
|
||||
}
|
||||
|
||||
if (utilInstance) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user