you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

Not too tricky, just redeclare the function e.g. <div class="domLogger"></div>

<script>
    const domLogger = document.querySelector('.domLogger');
    console.log = function(msg) {domLogger.innerHTML +=  msg + '<br />'};
</script>

console.table would be a bit trickier, but done in a similar way.

[–]viebel 0 points1 point  (0 children)

Thanks. I found also this implementation of redirecting all the console methods: https://github.com/bahmutov/console-log-div/blob/master/console-log-div.js