mirror of
https://github.com/imcarlost/pidcat-repl.git
synced 2026-08-08 23:17:43 -04:00
Merge pull request #94 from dmarcato/master
Allow tag filters with regex
This commit is contained in:
@@ -234,6 +234,9 @@ def parse_start_proc(line):
|
|||||||
return line_package, '', line_pid, line_uid, ''
|
return line_package, '', line_pid, line_uid, ''
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def tag_in_tags_regex(tag, tags):
|
||||||
|
return any(re.match(r'^' + t + r'$', tag) for t in map(str.strip, tags))
|
||||||
|
|
||||||
ps_command = base_adb_command + ['shell', 'ps']
|
ps_command = base_adb_command + ['shell', 'ps']
|
||||||
ps_pid = subprocess.Popen(ps_command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
ps_pid = subprocess.Popen(ps_command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
while ps_pid.poll() is None:
|
while ps_pid.poll() is None:
|
||||||
@@ -269,6 +272,7 @@ while adb.poll() is None:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
level, tag, owner, message = log_line.groups()
|
level, tag, owner, message = log_line.groups()
|
||||||
|
tag = tag.strip()
|
||||||
start = parse_start_proc(line)
|
start = parse_start_proc(line)
|
||||||
if start:
|
if start:
|
||||||
line_package, target, line_pid, line_uid, line_gids = start
|
line_package, target, line_pid, line_uid, line_gids = start
|
||||||
@@ -297,7 +301,7 @@ while adb.poll() is None:
|
|||||||
last_tag = None # Ensure next log gets a tag printed
|
last_tag = None # Ensure next log gets a tag printed
|
||||||
|
|
||||||
# Make sure the backtrace is printed after a native crash
|
# Make sure the backtrace is printed after a native crash
|
||||||
if tag.strip() == 'DEBUG':
|
if tag == 'DEBUG':
|
||||||
bt_line = BACKTRACE_LINE.match(message.lstrip())
|
bt_line = BACKTRACE_LINE.match(message.lstrip())
|
||||||
if bt_line is not None:
|
if bt_line is not None:
|
||||||
message = message.lstrip()
|
message = message.lstrip()
|
||||||
@@ -307,15 +311,14 @@ while adb.poll() is None:
|
|||||||
continue
|
continue
|
||||||
if level in LOG_LEVELS_MAP and LOG_LEVELS_MAP[level] < min_level:
|
if level in LOG_LEVELS_MAP and LOG_LEVELS_MAP[level] < min_level:
|
||||||
continue
|
continue
|
||||||
if args.ignored_tag and tag.strip() in args.ignored_tag:
|
if args.ignored_tag and tag_in_tags_regex(tag, args.ignored_tag):
|
||||||
continue
|
continue
|
||||||
if args.tag and tag.strip() not in args.tag:
|
if args.tag and not tag_in_tags_regex(tag, args.tag):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
linebuf = ''
|
linebuf = ''
|
||||||
|
|
||||||
# right-align tag title and allocate color if needed
|
# right-align tag title and allocate color if needed
|
||||||
tag = tag.strip()
|
|
||||||
if tag != last_tag or args.always_tags:
|
if tag != last_tag or args.always_tags:
|
||||||
last_tag = tag
|
last_tag = tag
|
||||||
color = allocate_color(tag)
|
color = allocate_color(tag)
|
||||||
|
|||||||
Reference in New Issue
Block a user