1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 10:10:46 +00:00

devlib/AndroidTarget: Allow passing format options to dump_logcat()

logcat has a modifier for its output format.  Add a logcat_format
parameter to dump_logcat() so that we can pass it on to logcat.
This commit is contained in:
Javi Merino 2020-01-17 17:00:59 +00:00 committed by Marc Bonnici
parent 6fe78b4d47
commit a5640502ac

View File

@ -1507,15 +1507,18 @@ class AndroidTarget(Target):
self._ensure_executables_directory_is_writable() self._ensure_executables_directory_is_writable()
self.remove(on_device_executable, as_root=self.needs_su) self.remove(on_device_executable, as_root=self.needs_su)
def dump_logcat(self, filepath, filter=None, append=False, timeout=30): # pylint: disable=redefined-builtin def dump_logcat(self, filepath, filter=None, logcat_format=None, append=False,
timeout=30): # pylint: disable=redefined-builtin
op = '>>' if append else '>' op = '>>' if append else '>'
filtstr = ' -s {}'.format(quote(filter)) if filter else '' filtstr = ' -s {}'.format(quote(filter)) if filter else ''
formatstr = ' -v {}'.format(quote(logcat_format)) if logcat_format else ''
logcat_opts = '-d' + formatstr + filtstr
if isinstance(self.conn, AdbConnection): if isinstance(self.conn, AdbConnection):
command = 'logcat -d{} {} {}'.format(filtstr, op, quote(filepath)) command = 'logcat {} {} {}'.format(logcat_opts, op, quote(filepath))
adb_command(self.adb_name, command, timeout=timeout) adb_command(self.adb_name, command, timeout=timeout)
else: else:
dev_path = self.get_workpath('logcat') dev_path = self.get_workpath('logcat')
command = 'logcat -d{} {} {}'.format(filtstr, op, quote(dev_path)) command = 'logcat {} {} {}'.format(logcat_opts, op, quote(dev_path))
self.execute(command, timeout=timeout) self.execute(command, timeout=timeout)
self.pull(dev_path, filepath) self.pull(dev_path, filepath)
self.remove(dev_path) self.remove(dev_path)