Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using LogCat for android USB debugging of the browser

So I am running logcat on my Incredible 2 connected to my computer and am trying to debug a web app I am working on. Unfortunately, the device is spamming the console so I can't see any of my console.logs from my javascript. Does anyone know of a way to filter out everything but the console.logs coming from the browser? I tried running logcat with these options

adb logcat -s "console"

thinking it would filter out everything but the console, since the android docs says the the browser console.logs spit out in this format listed here:

Console: Hello World http://www.example.com/hello.html :82

http://developer.android.com/guide/webapps/debugging.html

anyone know the real trick to this? Thanks.

like image 229
gabaum10 Avatar asked Jan 27 '12 02:01

gabaum10


2 Answers

Update, in newer Android versions that is:

adb logcat browser:V *:S
like image 181
David Avatar answered Nov 15 '22 00:11

David


Can console.log be used to specify a tag? If so, you can use logcat to get only entries with a given tag with this:

adb logcat MYTAG:V

Turns out that console.log() specifies a tag of WebCore automatically, so you should be able to filter things the way you want like this:

adb logcat WebCore:V *:S

This means, "Show me everything tagged WebCore, and nothing that isn't." Other people have had success using browser instead of WebCore (Is there a way to enable the JavaScript Error/Debug Console for Safari within Android?), so try both and see what works.

like image 25
David Merriman Avatar answered Nov 15 '22 01:11

David Merriman