Created
February 20, 2012 04:51
-
-
Save ajaykumarns/1867908 to your computer and use it in GitHub Desktop.
Script to automate adb logcat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import subprocess as sp | |
import re | |
from sets import Set | |
if __name__ == '__main__': | |
print "Current working directory = %s" % (os.getcwd()) | |
cmd = "find %s -name *.java -exec grep 'Logger\.forK(' '{}' \;" % os.getcwd() | |
suspend = 'PhoneInterfaceManager,InputDispatcher,NetlinkEvent,UsbObserver,Tethering,Finsky,battery_widget_monitor,KINETO'.split(",") | |
exclusions = [] #['PackageManager'] | |
debugs = Set() | |
for line in sp.check_output(cmd, shell=True).split("\n"): | |
m = re.search('(?<=Logger\.forK\()(\w+)(?=.*\))', line) | |
if m: | |
debugs.add(m.group(0)) | |
#oggers += m.group(0) +":D " | |
cmd = 'find %s -name *.java' % os.getcwd() | |
for line in sp.check_output(cmd, shell=True).split("\n"): | |
m = re.search('(\w+).java$', line) | |
if m: | |
debugs.add(m.group(1)) | |
for ex in exclusions: | |
debugs.add(ex) | |
logs =" ".join([logger + ':D' for logger in debugs]) | |
if len(suspend) > 0: | |
logs += " " + " ".join([l + ':S' for l in suspend]) | |
cmd = "adb logcat %s *:E" % logs | |
print "Executing '%s'" % cmd | |
os.system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment