From 19a325feb28dfe650888e68534341499ece34334 Mon Sep 17 00:00:00 2001 From: Piotr Maszota <37781044+piotruela@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:35:33 +0100 Subject: [PATCH] Add logcat method to adb (#2397) Co-authored-by: piotruela --- packages/adb/CHANGELOG.md | 4 ++++ packages/adb/lib/src/adb.dart | 26 ++++++++++++++++++++++++++ packages/adb/pubspec.yaml | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/adb/CHANGELOG.md b/packages/adb/CHANGELOG.md index dbd5bdb34..9c424dedf 100644 --- a/packages/adb/CHANGELOG.md +++ b/packages/adb/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.0 + +- Add `logcat` method to `Adb` (#2387) + ## 0.4.1 - Bump minimum Dart SDK to version 3.5.0 (#2371) diff --git a/packages/adb/lib/src/adb.dart b/packages/adb/lib/src/adb.dart index 4bdbc3542..c1aebab84 100644 --- a/packages/adb/lib/src/adb.dart +++ b/packages/adb/lib/src/adb.dart @@ -222,6 +222,32 @@ class Adb { return process; } + /// Returns process that listen for adb logs. + Future logcat({ + String? device, + Map arguments = const {}, + String? filter, + }) async { + await _adbInternals.ensureServerRunning(); + + final process = await io.Process.start( + 'adb', + [ + if (device != null) ...['-s', device], + 'shell', + 'logcat', + for (final arg in arguments.entries) ...[ + arg.key, + arg.value, + ], + if (filter != null) filter, + ], + runInShell: true, + ); + + return process; + } + /// Returns the list of currently attached devices. /// /// See also: diff --git a/packages/adb/pubspec.yaml b/packages/adb/pubspec.yaml index 7096ef177..1211ec08a 100644 --- a/packages/adb/pubspec.yaml +++ b/packages/adb/pubspec.yaml @@ -1,6 +1,6 @@ name: adb description: Simple Dart wrapper around Android Debug Bridge. -version: 0.4.1 +version: 0.5.0 repository: https://github.com/leancodepl/patrol/tree/master/packages/adb issue_tracker: https://github.com/leancodepl/patrol/issues?q=is%3Aopen+is%3Aissue+label%3A%22package%3A+adb%22