Skip to content

Instantly share code, notes, and snippets.

@hejrobin
Created October 24, 2011 06:46
Show Gist options
  • Save hejrobin/1308501 to your computer and use it in GitHub Desktop.
Save hejrobin/1308501 to your computer and use it in GitHub Desktop.
(function() {
this.log = function() {
// Really old browsers
if(typeof console == undefined)
var console = {};
// Just makin' sure...
if(typeof console.log == undefined)
console.log = function() {};
// Now we're talkin'
else if(typeof console == 'function') {
if(arguments.length == 1)
arguments = arguments[0];
console.log(arguments);
}
// Dude, what... ffffuuuuu.jpg sent to IE9
else if(Function.prototype.bind && typeOf(console.log) == 'object') {
// In IE9, console.log is an object and not a function
["log","info","warn","error","assert","dir","clear","profile","profileEnd"].each(function(method) {
console[method] = this.bind(console[method], console);
}, Function.prototype.call);
}
};
}).call(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment