Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(889)

Unified Diff: build/android/pylib/device/logcat_monitor.py

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/device/device_utils_test.py ('k') | build/android/pylib/device/logcat_monitor_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/logcat_monitor.py
diff --git a/build/android/pylib/device/logcat_monitor.py b/build/android/pylib/device/logcat_monitor.py
index 1d4cc24fa955467c8be13d82e95e5dff72ff4251..2eebc2dbbbe70065d324a97603939b9305f81a1c 100644
--- a/build/android/pylib/device/logcat_monitor.py
+++ b/build/android/pylib/device/logcat_monitor.py
@@ -19,8 +19,9 @@ from pylib.device import device_errors
class LogcatMonitor(object):
- # Format: <DATE> <TIME> <PID> <TID> <LEVEL> <COMPONENT>: <MESSAGE>
- _THREADTIME_RE_FORMAT = r'\S* +\S* +(%s) +(%s) +(%s) +(%s): +(%s)$'
+ _THREADTIME_RE_FORMAT = (
+ r'(?P<date>\S*) +(?P<time>\S*) +(?P<proc_id>%s) +(?P<thread_id>%s) +'
+ r'(?P<log_level>%s) +(?P<component>%s) *: +(?P<message>%s)$')
def __init__(self, adb, clear=True, filter_specs=None):
"""Create a LogcatMonitor instance.
@@ -97,18 +98,12 @@ class LogcatMonitor(object):
log_level: The log level to match. If None, matches any log level.
component: The component to match. If None, matches any component.
- Returns:
- An iterable containing objects with five attributes:
- |proc_id|: the process ID
- |thread_id|: the thread ID
- |log_level|: the log level
- |component|: the component
- |message|: the logcat message
+ Yields:
+ A match object for each matching line in the logcat. The match object
+ will always contain, in addition to groups defined in |message_regex|,
+ the following named groups: 'date', 'time', 'proc_id', 'thread_id',
+ 'log_level', 'component', and 'message'.
"""
- LogcatLine = collections.namedtuple(
- 'LogcatLine',
- ['proc_id', 'thread_id', 'log_level', 'component', 'message'])
-
if proc_id is None:
proc_id = r'\d+'
if thread_id is None:
@@ -121,11 +116,10 @@ class LogcatMonitor(object):
type(self)._THREADTIME_RE_FORMAT % (
proc_id, thread_id, log_level, component, message_regex))
- regexed_lines = (
- re.match(threadtime_re, l)
- for l in self._adb.Logcat(dump=True, logcat_format='threadtime'))
- only_matches = (m for m in regexed_lines if m)
- return (LogcatLine(*m.group(1, 2, 3, 4, 5)) for m in only_matches)
+ for line in self._adb.Logcat(dump=True, logcat_format='threadtime'):
+ m = re.match(threadtime_re, line)
+ if m:
+ yield m
def Start(self):
"""Starts the logcat monitor.
« no previous file with comments | « build/android/pylib/device/device_utils_test.py ('k') | build/android/pylib/device/logcat_monitor_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698