Last active
October 16, 2022 19:03
-
-
Save waynegraham/5766565 to your computer and use it in GitHub Desktop.
print console.log output to a debug div (for mobile)
This file contains 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
if (typeof console != "undefined") | |
if (typeof console.log != 'undefined') | |
console.olog = console.log; | |
else | |
console.olog = function() {}; | |
console.log = function(message) { | |
console.olog(message); | |
$('#debugDiv').append('<p>' + message + '</p>'); | |
}; | |
console.error = console.debug = console.info = console.log |
This file contains 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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<style> | |
#debugDiv {height: 200px; width: 500px; border: 1px solid #333; overflow:scroll;} | |
</style> | |
<script src="console.js"></script> | |
</head> | |
<body> | |
<div id="debugDiv"></div> | |
<script> | |
console.log('test'); | |
</script> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to print with styles like color, font etc..
Example : �[32m[Nest] 32612 - �[39m09/13/2020, 1:36:17 PM �[33m[RoutesResolver] �[39m�[32mControlsController {/BackendApp/api/controls}:�[39m�[33m +1ms�[39m