Created
November 8, 2014 18:03
-
-
Save danemacaulay/ef69c80e3727cb66a536 to your computer and use it in GitHub Desktop.
console log shim for older browsers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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