Skip to content

Instantly share code, notes, and snippets.

@airyboy
Last active January 17, 2025 13:13
Show Gist options
  • Save airyboy/ee874574f0ec0fcb228965abd1ffc1ad to your computer and use it in GitHub Desktop.
Save airyboy/ee874574f0ec0fcb228965abd1ffc1ad to your computer and use it in GitHub Desktop.
Redirecting console.log output to a webpage
<pre id="log"></pre>
(function(){
var oldLog = console.log;
console.log = function (message) {
const logger = document.getElementById('log');
logger.innerHTML += `> ${message}\n`;
oldLog.apply(console, arguments);
};
})();
@peshala-prabhapoorna
Copy link

Thanks! I was looking for this all over Stack Overflow.

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