node-monkey
node-monkey copied to clipboard
Is there any way to post console output on the html page instead of the console?
I had searched for it in the documentation but I can not find it.
Is there any function or way that start showing the terminal output in some
Just found it. If anyone is looking for it
<html>
<body>
<pre id="log"></pre>
</body>
<script>
(function () {
if (!console) {
console = {};
}
var old = console.log
var logger = document.getElementById('log');
console.log = function (message) {
if (typeof message == 'object') {
logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(message) : String(message))+ '<br>';
} else {
logger.innerHTML += message+ '<br>';
}
}
})();
</script>
</html>
I need to look around and see if there's a good existing library for displaying interactive objects logged to the console in the document itself.
When I started this project there were a bunch of attempts people made but they all fell short of the actual browser built-in devtools and I wanted something that would just use the built-in tools so it wasn't making app debugging harder than it needs to be. It would be a nice additional option for simple use cases though.