Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pidcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
parser.add_argument('-c', '--clear', dest='clear_logcat', action='store_true', help='Clear the entire log before running')
parser.add_argument('-t', '--tag', dest='tag', action='append', help='Filter output by specified tag(s)')
parser.add_argument('-i', '--ignore-tag', dest='ignored_tag', action='append', help='Filter output by ignoring specified tag(s)')
parser.add_argument('-m', '--msgs', dest='msg', action='append', help='Only output messages with regex(s)')
parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__, help='Print the version number and exit')
parser.add_argument('-a', '--all', dest='all', action='store_true', default=False, help='Print all log messages')

Expand Down Expand Up @@ -254,6 +255,9 @@ def parse_start_proc(line):
def tag_in_tags_regex(tag, tags):
return any(re.match(r'^' + t + r'$', tag) for t in map(str.strip, tags))

def msg_in_msgs_regex(msg, msgs):
return any(re.match('.*' + t + r'.*', msg) for t in map(str.strip, msgs))

ps_command = base_adb_command + ['shell', 'ps']
ps_pid = subprocess.Popen(ps_command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
while True:
Expand Down Expand Up @@ -332,6 +336,8 @@ def tag_in_tags_regex(tag, tags):
continue
if args.tag and not tag_in_tags_regex(tag, args.tag):
continue
if args.msg and not msg_in_msgs_regex(message, args.msg):
continue

linebuf = ''

Expand Down