Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to post console output on the html page instead of the console? #65

Open
supreen opened this issue Mar 7, 2021 · 2 comments

Comments

@supreen
Copy link

supreen commented Mar 7, 2021

I had searched for it in the documentation but I can not find it.

Is there any function or way that start showing the terminal output in some

of index.htm, instead of the console in inspection.?

@supreen
Copy link
Author

supreen commented Mar 9, 2021

Just found it.
If anyone is looking for it

<html>
<body>
<pre id="log"></pre>
</body>
<script>

(function () {
    if (!console) {
        console = {};
    }
    var old = console.log 
    var logger = document.getElementById('log');
    console.log = function (message) {
        if (typeof message == 'object') {
            logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(message) : String(message))+ '<br>';
        } else {
            logger.innerHTML += message+ '<br>';
        }
    }
})();


</script>
</html>

@jwarkentin
Copy link
Owner

I need to look around and see if there's a good existing library for displaying interactive objects logged to the console in the document itself.

When I started this project there were a bunch of attempts people made but they all fell short of the actual browser built-in devtools and I wanted something that would just use the built-in tools so it wasn't making app debugging harder than it needs to be. It would be a nice additional option for simple use cases though.

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

No branches or pull requests

2 participants