Created
September 20, 2021 20:46
-
-
Save TanmayChakrabarty/9c581d847b6052d0576c4a5ca39cd38f to your computer and use it in GitHub Desktop.
Display console log data to a div
This file contains hidden or 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
var consoleLog = document.getElementById('console_log'); | |
console = { | |
log: function (text) { | |
let consoleLine = document.createElement('pre'); | |
consoleLine.setAttribute('class', 'console-line'); | |
consoleLine.innerText = (typeof text === 'object' ? JSON.stringify(text, null, 4) : text); | |
consoleLog.appendChild(consoleLine); | |
} | |
}; |
This file contains hidden or 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
<div id="console_log"></div> |
This file contains hidden or 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
.console-line | |
{ | |
font-family: monospace; | |
margin: 2px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment