Skip to content

Instantly share code, notes, and snippets.

@danemacaulay
Created November 8, 2014 18:03
Show Gist options
  • Save danemacaulay/ef69c80e3727cb66a536 to your computer and use it in GitHub Desktop.
Save danemacaulay/ef69c80e3727cb66a536 to your computer and use it in GitHub Desktop.
console log shim for older browsers
(function () {
'use strict';
window.console = window.console || {};
if (typeof Envjs !== 'undefined') {
return;
}
var methodNames = [
'assert',
'clear',
'count',
'debug',
'dir',
'dirxml',
'error',
'exception',
'firebug',
'group',
'groupCollapsed',
'groupEnd',
'info',
'log',
'memoryProfile',
'memoryProfileEnd',
'profile',
'profileEnd',
'table',
'time',
'timeEnd',
'timeStamp',
'trace',
'warn'
];
function emptyFunction() {}
for (var i = 0; i < methodNames.length; i++) {
if (!window.console[methodNames[i]]) {
window.console[methodNames[i]] = console[methodNames[i]] || emptyFunction;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment