Skip to content

Instantly share code, notes, and snippets.

@sstur
Created January 23, 2014 00:11
Show Gist options
  • Save sstur/8570261 to your computer and use it in GitHub Desktop.
Save sstur/8570261 to your computer and use it in GitHub Desktop.
Normalize console.log/warn/error
(function(console) {
var _apply = Function.prototype.apply;
if (!console) {
window.console = {
log: function() {},
warn: function() {},
error: function() {}
};
} else
if (console.log && typeof console.log.apply == 'unknown') {
window.console = {
log: function() {
return _apply.call(console.log, console, arguments);
},
warn: function() {
return _apply.call(console.warn, console, arguments);
},
error: function() {
return _apply.call(console.error, console, arguments);
}
};
}
})(window.console);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment