Skip to content

Commit

Permalink
added kuaminika logger to properly wrap the console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jun 13, 2020
1 parent a468c86 commit 2a504b3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions KLIB.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
console.log(logMe);
// console.log(new Error().stack);
}

function logErrorIfYouCan(error)
{
if(!console) return;
Expand Down Expand Up @@ -410,6 +411,8 @@

kLib.filterWithDataAttribute = filterWithDataAttribute;

// kLib.logIfYouCan = logIfYouCan;
// kLib.logErrorIfYouCan = logErrorIfYouCan;
kLib.getFromClassWithDataAttribute = getFromClassWithDataAttribute;
kLib.isElement = isElement;
w.kLib = kLib;
Expand Down
31 changes: 31 additions & 0 deletions KuaminikaLogger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

(function(kLib) {



var w = window||this;

function blankFunction(){};

var fucntionsInConsole = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];

var kLogger = {};
var consoleObject = w.console || {};

for (var index = 0; index < fucntionsInConsole.length; index++) {
var fn = fucntionsInConsole[index];
kLogger[fn] = consoleObject[fn]||blankFunction;
}

kLib.log = kLogger.log;
kLib.logError = kLogger.error;

kLib.logger = kLogger;


})(kLib);

0 comments on commit 2a504b3

Please sign in to comment.