How can I get console.log output from my mobile ON the mobile device?
I do a lot of my dev work from mobile devices. Is there a way to get js access to console.log output from within a mobile browser?
Currently, the best method would be to ‘hook into’ the native console and display the output as HTML, while still allowing the output to go to the native console.
You could implement your own version very easily….
….but rather than reinvent the wheel, there’s a couple projects you might be interested in trying.
I’m personally using hnlDesign’s mobileConsole and have been very happy with it. It’s simple and just what you’d want and expect.
I recently became aware of Eruda but haven’t had a chance to test it, other than playing with their demo. It implements a lot more developer tools, but for this reason might also be overkill for a lot of projects. It doesn’t feel as lightweight (its file size is definitely much larger, even minified!), and if you want the breadth and intensity of developer tools, it would be better to use remote debugging. Most of us who are wanting a mobile console are just wanting the basics for quick tests and the like.
For Android – I found this works:
- Open Android Studio IDE
- Connecting the device in debug mode
- Open logcat
- Run the browser UI on android device – to see the console log output
Here’s a few console.log() lines from logcat:
[INFO:CONSOLE(18)] "100 - checking FUNC PARAM ... ", source: https://somewhere/util/message_util.js (18)
[INFO:CONSOLE(18)] "101 - > ENTER: AppAuth.onHasAuthFunc", source: https://somewhere/util/message_util.js (18)
Idea to try this approach, thanks to @Marcus’s answer , suggesting:
” ‘hook into’ the native console “
Also, saw other posts suggesting to type:
.. into the address bar of device browser. Not sure if that had anything to do with getting the connection to work