Skip to content

Commit

Permalink
Merge pull request #12 from shawnma/master
Browse files Browse the repository at this point in the history
Support logcat level filtering
  • Loading branch information
JakeWharton committed Jun 19, 2013
2 parents d6819b0 + 4095d3a commit f624fe4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pidcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@
import subprocess
from subprocess import PIPE


LOG_LEVELS = ['V','D','I','W','E']
LOG_LEVELS_MAP = dict([(LOG_LEVELS[i], i) for i in range(len(LOG_LEVELS))])
parser = argparse.ArgumentParser(description='Filter logcat by package name')
parser.add_argument('package', nargs='+', help='Application package name(s)')
parser.add_argument('--tag-width', metavar='N', dest='tag_width', type=int, default=22, help='Width of log tag')
parser.add_argument('-w', '--tag-width', metavar='N', dest='tag_width', type=int, default=22, help='Width of log tag')
parser.add_argument('-l', '--min-level', dest='min_level', type=str, choices=LOG_LEVELS, default='V', help='Minimum level to be displayed')
parser.add_argument('--color-gc', dest='color_gc', action='store_true', help='Color garbage collection')

args = parser.parse_args()
min_level=LOG_LEVELS_MAP[args.min_level]

header_size = args.tag_width + 1 + 3 + 1 # space, level, space

Expand Down Expand Up @@ -201,6 +206,8 @@ def parse_death(tag, message):

if owner not in pids:
continue
if LOG_LEVELS_MAP[level] < min_level:
continue

linebuf = ''

Expand Down

0 comments on commit f624fe4

Please sign in to comment.