Created
April 9, 2018 13:23
-
-
Save xploshioOn/56606807cc0b30b02ee430809ff0f048 to your computer and use it in GitHub Desktop.
add all errors/console.log to div on html dynamically
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
var baseLogFunction = console.log; | |
console.log = function(){ | |
baseLogFunction.apply(console, arguments); | |
var args = Array.prototype.slice.call(arguments); | |
for(var i=0;i<args.length;i++){ | |
var node = createLogNode(args[i]); | |
document.querySelector("#debugDiv").appendChild(node); | |
} | |
} | |
function createLogNode(message){ | |
var node = document.createElement("div"); | |
var textNode = document.createTextNode(message); | |
node.appendChild(textNode); | |
return node; | |
} | |
window.onerror = function(message, url, linenumber) { | |
console.log("JavaScript error: " + message + " on line " + | |
linenumber + " for " + url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment