Created
April 19, 2017 20:10
-
-
Save timothy/d6a2073445c31494264261a058d7cb63 to your computer and use it in GitHub Desktop.
show console output on web page
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
<pre id="log"></pre> | |
<script> | |
(function() { | |
var old = console.log; | |
var logger = document.getElementById('log'); | |
console.log = function() { | |
for (var i = 0; i < arguments.length; i++) { | |
if (i > 0) { | |
logger.innerHTML += " "; | |
} | |
if (typeof arguments[i] === 'object') { | |
logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(arguments[i], undefined, 2) : arguments[i]); | |
} else { | |
logger.innerHTML += arguments[i]; | |
} | |
} | |
logger.innerHTML += "<br />"; | |
old.apply(console, arguments); | |
}; | |
})(); | |
console.log("Does","this","work"); | |
console.log("Yes it does"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note need to base this off of original at: https://github.com/pmed/v8pp/blob/master/plugins/console.cpp