49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
(function (context, $) {
|
|
|
|
"use strict";
|
|
|
|
/*
|
|
internal logger with no-ops when console is missing.
|
|
*/
|
|
context.JK = context.JK || {};
|
|
|
|
var console_methods = [
|
|
'log', 'debug', 'info', 'warn', 'error', 'assert',
|
|
'clear', 'dir', 'dirxml', 'trace', 'group',
|
|
'groupCollapsed', 'groupEnd', 'time', 'timeEnd',
|
|
'timeStamp', 'profile', 'profileEnd', 'count',
|
|
'exception', 'table'
|
|
];
|
|
|
|
if ('undefined' === typeof(context.console)) {
|
|
context.console = {};
|
|
$.each(console_methods, function(index, value) {
|
|
context.console[value] = $.noop;
|
|
});
|
|
}
|
|
|
|
if (!console.debug) {
|
|
console.log("No console.debug found - defining...");
|
|
context.console.debug = function() { console.log(arguments); }
|
|
}
|
|
|
|
context.JK.logger = context.console;
|
|
|
|
// JW - some code to tone down logging. Uncomment the following, and
|
|
// then do your logging to logger.dbg - and it will be the only thing output.
|
|
// TODO - find a way to wrap this up so that debug logs can stay in, but this
|
|
// class can provide a way to enable/disable certain namespaces of logs.
|
|
/*
|
|
var fakeLogger = {};
|
|
$.each(console_methods, function(index, value) {
|
|
fakeLogger[value] = $.noop;
|
|
});
|
|
fakeLogger.dbg = function(m) {
|
|
context.console.debug(m);
|
|
};
|
|
context.JK.logger = fakeLogger;
|
|
*/
|
|
|
|
|
|
|
|
})(window, jQuery); |