Skip to content

Instantly share code, notes, and snippets.

@waynegraham
Last active October 16, 2022 19:03
Show Gist options
  • Save waynegraham/5766565 to your computer and use it in GitHub Desktop.
Save waynegraham/5766565 to your computer and use it in GitHub Desktop.
print console.log output to a debug div (for mobile)
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
<!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>
@DivekJohns
Copy link

DivekJohns commented Sep 13, 2020

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

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