Skip to content

Instantly share code, notes, and snippets.

@colintoh
Last active August 29, 2015 14:07
Show Gist options
  • Save colintoh/8b0ed9d23939a8405c82 to your computer and use it in GitHub Desktop.
Save colintoh/8b0ed9d23939a8405c82 to your computer and use it in GitHub Desktop.
overwrite console
var _consoleLog = console.log;
console.log = function(){
var name = _consoleLog.apply(console,arguments);
var str = "";
for(var index in arguments){
if(Array.isArray(arguments[index])){
arguments[index] = arguments[index].map(function(item){
if(typeof item == "object"){
item = JSON.stringify(item,null,4)+"<br>";
}
return item;
});
str += arguments[index]+" ";
} else if(typeof arguments[index] == "object"){
str += JSON.stringify(arguments[index],null,4);
} else {
str += arguments[index]+" ";
}
}
document.querySelector("body").innerHTML += ("<div>"+str+"</div>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment