safer logging in JS utilRegistry

This commit is contained in:
Felix Hamann 2019-04-07 22:32:14 +02:00
parent d43fbca0c3
commit 32bc5f4852
2 changed files with 7 additions and 6 deletions

View File

@ -4,7 +4,7 @@
var registeredUtils = [];
var activeUtilInstances = [];
var DEBUG_MODE = 2;
var DEBUG_MODE = /localhost/.test(window.location.href) && 2;
// Registry
// (revealing module pattern)
@ -26,10 +26,8 @@
* @param util Object Utility that should be added to the registry
*/
function registerUtil(util) {
if (DEBUG_MODE > 0) {
console.log('registering util "' + util.name + '"');
}
if (DEBUG_MODE > 2) {
console.log('registering util "' + util.name + '"');
console.log({ util });
}
@ -49,6 +47,11 @@
}
function setupAllUtils() {
if (DEBUG_MODE > 1) {
console.info('registered js utilities:');
console.table(registeredUtils);
}
registeredUtils.forEach(function(util) {
setupUtil(util);
});

View File

@ -1,8 +1,6 @@
(function() {
'use strict';
window.utils = window.utils || {};
/**
*
* Check All Checkbox Utility