ADB Logcat candy

Normally, when I’m debugging stuff on my android code, I use the command line version of adb in a terminal window on my mac.  I’ve been using various tags after the -S command to filter the output to just the stuff I care about, like so:

adb logcat -S Unity PBAndroid

This will filter the output to show only lines that have Unity or PBAndroid as tags, and I use PBAndroid for all my Log.? outputs in my java plugins.  Normally this has served me well, but I was running into an issue with using the new Unity IAP system and there were messages I was missing that would have lead me to a solution to the problem much sooner if I’d seen them, but I was filtering them out.

After some googling, I found the following awesome line on StackOverflow that is going to be my new go to ADB command:

adb logcat | grep `adb shell ps | grep com.example.package | cut -c10-15`

I replaced the com.example.package with com.purplebuttons. and it shows me ALL the output for my application.

I added the following to my /bin folder as ‘adblog’:

!/bin/bash
#call adb logcat on a specific bundle id
if [ $# -eq 0 ];
then
 echo "Syntax: $(basename $0) bundleid (e.g. com.purplebuttons)"
 exit 1
fi
adb logcat | grep `adb shell ps | grep $1 | cut -c10-15`

Now I can filter the output to my application by using:

adblog com.purplebuttons

 

Leave a Reply