Skip to content

Instantly share code, notes, and snippets.

@timothy
Created April 19, 2017 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothy/d6a2073445c31494264261a058d7cb63 to your computer and use it in GitHub Desktop.
Save timothy/d6a2073445c31494264261a058d7cb63 to your computer and use it in GitHub Desktop.
show console output on web page
<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>
@timothy
Copy link
Author

timothy commented Apr 19, 2017

Note need to base this off of original at: https://github.com/pmed/v8pp/blob/master/plugins/console.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment