Create list of hardcoded tags for logcat filter-spec
Sometimes if you're taking over a project you might find your source files have tags for debugging scattered throughout rather than in static strings. It's useful when getting an understanding of what the app is doing to add traces throughout. The unfiltered output from logcat
can often be overwhelming.
Using bash to match log lines in java files then awk to output the first bit of the string and then sorting and passing to xargs to format on a line makes it easy when opening a new project:
function android_tags {
# Gets the list of unique tags in a project for logcat filterspecs
grep Log\. -r --include "*.java" | awk -F\" '{print $2}' | sort -u | xargs
}
adb -d logcat -s `android_tags`
For example:
[18:00][wario][jaymz][app][master]$ android_tags
APITest Colors DetailsTask FilterTask HomeActivity SearchTask
[18:02][wario][jaymz][app][master]$ adb -d logcat -s `android_tags`
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
D/ClearCacheService( 3594): Cleaning cache...
D/ClearCacheService( 3594): Cleaning cache DONE
D/HomeActivity( 3594): 404 -> Exception, url: null, json: null
Written by jaymz campbell
Related protips
1 Response
Actually, once you start any refactoring maybe take a look at Gonçalo Silva's tip of using the class name automatically: https://coderwall.com/p/bq7nya?&p=1&q=
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#