Repository: google/mobly

Issue:
logcat is empty for some NBU devices
When starting adb logcat, we use `-b all` to catch all buffers.

But some NBU devices (like HTC Desire 526g+) don't have the buffer option "all", and their adb logcat would only have one line saying "Unable to open log device '/dev/log/all': No such file or directory".

We need to handle this properly so we get the logs from the buffers the device does have, like 'main', 'system', 'radio', and 'events'.

Discussion:
adorokhine: 



Review status: 0 of 1 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.

---

*[mobly/controllers/android_device.py, line 762 at r1](https://reviewable.io:443/reviews/google/mobly/194#-Kin5wTIpvyhcpSOfSyt:-Kin5wTJNBtMJIyFu1bh:b-twcozc) ([raw file](https://github.com/google/mobly/blob/7d4fb4ef105e2e00a9657f4c9dc45c4dc953a501/mobly/controllers/android_device.py#L762)):*
> ```Python
>             extra_params = self.adb_logcat_param
>         except AttributeError:
>             extra_params = '-b main -b crash -b system -b radio'
> ```

Are we leaving out 'events' on purpose?

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

xpconanfan: 



Review status: 0 of 1 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.

---

*[mobly/controllers/android_device.py, line 762 at r1](https://reviewable.io:443/reviews/google/mobly/194#-Kin5wTIpvyhcpSOfSyt:-KinHEozjaAsJESifOf6:bjhi5gh) ([raw file](https://github.com/google/mobly/blob/7d4fb4ef105e2e00a9657f4c9dc45c4dc953a501/mobly/controllers/android_device.py#L762)):*
<details><summary><i>Previously, adorokhine (Alexander Dorokhine) wrote…</i></summary><blockquote>

Are we leaving out 'events' on purpose?
</blockquote></details>

I just realized that `-b radio` will not work for tablets...
Perhaps we should drop the custom '-b' values for good and use default?...
But that means all internal users would need to supply `-b radio` to get radio logs...

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

adorokhine: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-Kj5Th6VbQv3k2tRBlhx:b-2ypkyj) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
> ```Python
>         try:
>             process = utils.start_standing_subprocess(
>                 cmd, check_health_delay=0.1, shell=True)
> ```

Instead of assuming 100ms is enough for logcat to start up on a potentially overloaded machine and potentially slow phone, and dropping all log buffers, is there a way to detect which buffers are available so we can solve both problems? Does it perhaps show up in logcat --help?

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

xpconanfan: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-Kj5UlCJxa19whyjUC1-:b-2w7mwb) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, adorokhine (Alexander Dorokhine) wrote…</i></summary><blockquote>

Instead of assuming 100ms is enough for logcat to start up on a potentially overloaded machine and potentially slow phone, and dropping all log buffers, is there a way to detect which buffers are available so we can solve both problems? Does it perhaps show up in logcat --help?
</blockquote></details>

there is no reliable way.
parsing the help menu is not reliable bc each manufacturer may have different text for it.

We don't need to wait for logcat to start up though, the wait is to make sure the process didn't die.

Or could you think of other ways.

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

adorokhine: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-Kj5VWTp0QWe-4A_lrD3:bwaslzj) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, xpconanfan (Ang Li) wrote…</i></summary><blockquote>

there is no reliable way.
parsing the help menu is not reliable bc each manufacturer may have different text for it.

We don't need to wait for logcat to start up though, the wait is to make sure the process didn't die.

Or could you think of other ways.
</blockquote></details>

Can we add the buffers to the `logcat -c` call and wait for it to complete? According to the documentation, `logcat -c` takes the same set of buffers so it should be possible to use its success as a gauge for what buffers are supported right?
https://developer.android.com/studio/command-line/logcat.html

I want to get away from time-based checks.

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

xpconanfan: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-Kj5X8lbdIYnw5sMxRDw:b-u395ce) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, adorokhine (Alexander Dorokhine) wrote…</i></summary><blockquote>

Can we add the buffers to the `logcat -c` call and wait for it to complete? According to the documentation, `logcat -c` takes the same set of buffers so it should be possible to use its success as a gauge for what buffers are supported right?
https://developer.android.com/studio/command-line/logcat.html

I want to get away from time-based checks.
</blockquote></details>

We actually can't bc the failure does not cause ret code to be non-zero........

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

adorokhine: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-Kj6-Y3nqYU7kijXUXdC:beebema) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, xpconanfan (Ang Li) wrote…</i></summary><blockquote>

We actually can't bc the failure does not cause ret code to be non-zero........
</blockquote></details>

What does it print in the correct and incorrect case? Anything we can key off of? I really want to move away from blanket catching all errors and doing something else. In my experience, especially when it comes to Android, the thing you "expect" went wrong is actually totally unrelated to what actually went wrong. :) 

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

xpconanfan: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-Kj9LLZZp_DzFKO9mzNl:b-7n246i) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, adorokhine (Alexander Dorokhine) wrote…</i></summary><blockquote>

What does it print in the correct and incorrect case? Anything we can key off of? I really want to move away from blanket catching all errors and doing something else. In my experience, especially when it comes to Android, the thing you "expect" went wrong is actually totally unrelated to what actually went wrong. :) 
</blockquote></details>

It prints the help menu, which we shouldn't really rely on.

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

adorokhine: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-KjA1vWp7SbQlXNZHUPd:basxykf) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, xpconanfan (Ang Li) wrote…</i></summary><blockquote>

It prints the help menu, which we shouldn't really rely on.
</blockquote></details>

And what does it print if it does work correctly?

My concern with this approach is twofold:
a) 100ms is not necessarily enough time to make sure logcat started on an arbitrarily slow system and phone; recall our unit test flake
b) we shouldn't blanket catching all errors and assuming the cause was anything in particular without some type of validation. I've seen cases already where our blanket catch was squashing exceptions for the wrong reason.

So I would like to find something we can do to make sure the issue is what we think it is. I would much rather have a solution that works 100% of the time on 90% of the phones (because we can always improve the check) than a solution that works 90% of the time on 100% of the phones (because people will abandon our framework).

If there's absolutely no way to do this automatically we could just use `-b all` by default and expose a config param to completely override it; let people manage it manually in case they have a non-compliant phone.

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

xpconanfan: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-KjA36Jgtf8-r1sqc9C5:b-w4xiel) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, adorokhine (Alexander Dorokhine) wrote…</i></summary><blockquote>

And what does it print if it does work correctly?

My concern with this approach is twofold:
a) 100ms is not necessarily enough time to make sure logcat started on an arbitrarily slow system and phone; recall our unit test flake
b) we shouldn't blanket catching all errors and assuming the cause was anything in particular without some type of validation. I've seen cases already where our blanket catch was squashing exceptions for the wrong reason.

So I would like to find something we can do to make sure the issue is what we think it is. I would much rather have a solution that works 100% of the time on 90% of the phones (because we can always improve the check) than a solution that works 90% of the time on 100% of the phones (because people will abandon our framework).

If there's absolutely no way to do this automatically we could just use `-b all` by default and expose a config param to completely override it; let people manage it manually in case they have a non-compliant phone.
</blockquote></details>

It doesn't print anything on my phone if it works fine, but this is no guarantee that it won't print on other NBU devices.

Maybe we should not use '-b all' as a default in the first place.
If somebody has a special need for extra buffer like 'radio', they should use the param option to enable radio buffer collection.
For the default behavior, the default logcat option should be used, which is to not pass '-b' at all.

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->

adorokhine: 



Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.

---

*[mobly/controllers/android_device.py, line 769 at r2](https://reviewable.io:443/reviews/google/mobly/194#-Kj5Th6VbQv3k2tRBlhw:-KjA4yUN5r_m01yPfUdZ:b9lhgqa) ([raw file](https://github.com/google/mobly/blob/f348704d60b0f72ce656b0376e3feaceaa03284a/mobly/controllers/android_device.py#L769)):*
<details><summary><i>Previously, xpconanfan (Ang Li) wrote…</i></summary><blockquote>

It doesn't print anything on my phone if it works fine, but this is no guarantee that it won't print on other NBU devices.

Maybe we should not use '-b all' as a default in the first place.
If somebody has a special need for extra buffer like 'radio', they should use the param option to enable radio buffer collection.
For the default behavior, the default logcat option should be used, which is to not pass '-b' at all.
</blockquote></details>

Sure, default logcat settings unless manually overridden sgtm as long as it's ok by David.

---


*Comments from [Reviewable](https://reviewable.io:443/reviews/google/mobly/194)*
<!-- Sent from Reviewable.io -->


Patch:
diff --git a/docs/tutorial.md b/docs/tutorial.md
index 67f66b0..2c64dae 100644
--- a/docs/tutorial.md
+++ b/docs/tutorial.md
@@ -9,18 +9,13 @@ various devices and you can also use your own custom hardware/equipment.
 
 *   A computer with at least 2 USB ports.
 *   Mobly package and its system dependencies installed on the computer.
-*   One or two Android devices with the app SL4A* installed.
+*   One or two Android devices with the [Mobly Bundled Snippets]
+    (https://github.com/google/mobly-bundled-snippets) (MBS) installed. We will
+    use MBS to trigger actions on the Android devices.
 *   A working adb setup. To check, connect one Android device to the computer
     and make sure it has "USB debugging" enabled. Make sure the device shows up
     in the list printed by `adb devices`.
 
-\* You can get SL4A from the
-[Android repo](https://source.android.com/source/downloading.html), under
-project `<aosp>/external/sl4a`
-
-It can be built like a regular system app with `mm` commands. It needs to be
-signed with the build you use on your Android devices.
-
 # Example 1: Hello World!
  
 Let's start with the simple example of posting "Hello World" on the Android
@@ -51,10 +46,11 @@ class HelloWorldTest(base_test.BaseTestClass):
     # object is created from this.
     self.ads = self.register_controller(android_device)
     self.dut = self.ads[0]
-    self.dut.load_sl4a() # starts sl4a.
+    # Start Mobly Bundled Snippets (MBS).
+    self.dut.load_snippet('mbs', 'com.google.android.mobly.snippet.bundled')
  
   def test_hello(self):
-    self.dut.sl4a.makeToast('Hello World!')
+    self.dut.mbs.makeToast('Hello World!')
  
 if __name__ == '__main__':
   test_runner.main()
@@ -97,13 +93,13 @@ class HelloWorldTest(base_test.BaseTestClass):
   def setup_class(self):
     self.ads = self.register_controller(android_device)
     self.dut = self.ads[0]
-    self.dut.load_sl4a()
+    self.dut.load_snippet('mbs', 'com.google.android.mobly.snippet.bundled')
  
   def test_hello(self):
-    self.dut.sl4a.makeToast('Hello World!')
+    self.dut.mbs.makeToast('Hello World!')
  
   def test_bye(self):
-    self.dut.sl4a.makeToast('Goodbye!')
+    self.dut.mbs.makeToast('Goodbye!')
  
 if __name__ == '__main__':
   test_runner.main()
@@ -152,9 +148,9 @@ In the test script, you could access the user parameter:
   def test_favorite_food(self):
     food = self.user_params.get('favorite_food')
     if food:
-      self.dut.sl4a.makeToast("I'd like to eat %s." % food)
+      self.dut.mbs.makeToast("I'd like to eat %s." % food)
     else:
-      self.dut.sl4a.makeToast("I'm not hungry.")
+      self.dut.mbs.makeToast("I'm not hungry.")
 ```
  
 # Example 4: Multiple Test Beds and Default Test Parameters
@@ -201,7 +197,7 @@ screen.
  
 In this example, we use one Android device to discover another Android device
 via bluetooth. This test demonstrates several essential elements in test
-writing, like logging and asserts.
+writing, like asserts, device debug tag, and general logging vs logging with device tag.
  
 **sample_config.yml**
  
@@ -211,111 +207,90 @@ TestBeds:
     Controllers:
         AndroidDevice:
           - serial: xyz,
-            label: dut
+            label: target
           - serial: abc,
             label: discoverer
     TestParams:
         bluetooth_name: MagicBluetooth,
         bluetooth_timeout: 5
- 
- 
+
 ```
  
 **sample_test.py**
  
  
 ```python
+import logging
+import pprint
+
+from mobly import asserts
 from mobly import base_test
 from mobly import test_runner
-from mobly.controllerse import android_device
- 
+from mobly.controllers import android_device
+
+# Number of seconds for the target to stay discoverable on Bluetooth.
+DISCOVERABLE_TIME = 60
+
+
 class HelloWorldTest(base_test.BaseTestClass):
- 
- 
-  def setup_class(self):
-    # Registering android_device controller module, and declaring that the test
-    # requires at least two Android devices.
-    self.ads = self.register_controller(android_device, min_number=2)
-    self.dut = android_device.get_device(self.ads, label='dut')
-    self.dut.load_sl4a()
-    self.discoverer = android_device.get_device(self.ads, label='discoverer')
-    self.discoverer.load_sl4a()
-    self.dut.ed.clear_all_events()
-    self.discoverer.ed.clear_all_events()
- 
-  def setup_test(self):
-    # Make sure bluetooth is on
-    self.dut.sl4a.bluetoothToggleState(True)
-    self.discoverer.sl4a.bluetoothToggleState(True)
-    self.dut.ed.pop_event(event_name='BluetoothStateChangedOn',
-                          timeout=10)
-    self.discoverer.ed.pop_event(event_name='BluetoothStateChangedOn',
-                                 timeout=10)
-    if (not self.dut.sl4a.bluetoothCheckState() or
-           not self.discoverer.sl4a.bluetoothCheckState()):
-      asserts.abort_class('Could not turn on Bluetooth on both devices.')
- 
-    # Set the name of device #1 and verify the name properly registered.
-    self.dut.sl4a.bluetoothSetLocalName(self.bluetooth_name)
-    asserts.assert_equal(self.dut.sl4a.bluetoothGetLocalName(),
-                         self.bluetooth_name,
-                         'Failed to set bluetooth name to %s on %s' %
-                         (self.bluetooth_name, self.dut.serial))
- 
-  def test_bluetooth_discovery(self):
-    # Make dut discoverable.
-    self.dut.sl4a.bluetoothMakeDiscoverable()
-    scan_mode = self.dut.sl4a.bluetoothGetScanMode()
-    asserts.assert_equal(
-        scan_mode, 3,  # 3 signifies CONNECTABLE and DISCOVERABLE
-        'Android device %s failed to make blueooth discoverable.' %
-            self.dut.serial)
- 
-    # Start the discovery process on #discoverer.
-    self.discoverer.ed.clear_all_events()
-    self.discoverer.sl4a.bluetoothStartDiscovery()
-    self.discoverer.ed.pop_event(
-        event_name='BluetoothDiscoveryFinished',
-        timeout=self.bluetooth_timeout)
- 
-    # The following log entry demonstrates AndroidDevice log object, which
-    # prefixes log entries with "[AndroidDevice|<serial>] "
-    self.discoverer.log.info('Discovering other bluetooth devices.')
- 
-    # Get a list of discovered devices
-    discovered_devices = self.discoverer.sl4a.bluetoothGetDiscoveredDevices()
-    self.discoverer.log.info('Found devices: %s', discovered_devices)
-    matching_devices = [d for d in discovered_devices
-                        if d.get('name') == self.bluetooth_name]
-    if not matching_devices:
-      asserts.fail('Android device %s did not discover %s.' %
-                   (self.discoverer.serial, self.dut.serial))
-    self.discoverer.log.info('Discovered at least 1 device named '
-                             '%s: %s', self.bluetooth_name, matching_devices)
- 
+    def setup_class(self):
+        # Registering android_device controller module, and declaring that the test
+        # requires at least two Android devices.
+        self.ads = self.register_controller(android_device, min_number=2)
+        # The device used to discover Bluetooth devices.
+        self.discoverer = android_device.get_device(
+            self.ads, label='discoverer')
+        # Sets the tag that represents this device in logs.
+        self.discoverer.debug_tag = 'discoverer'
+        # The device that is expected to be discovered
+        self.target = android_device.get_device(self.ads, label='target')
+        self.target.debug_tag = 'target'
+        self.target.load_snippet('mbs',
+                                 'com.google.android.mobly.snippet.bundled')
+        self.discoverer.load_snippet(
+            'mbs', 'com.google.android.mobly.snippet.bundled')
+
+    def setup_test(self):
+        # Make sure bluetooth is on.
+        self.target.mbs.btEnable()
+        self.discoverer.mbs.btEnable()
+        # Set Bluetooth name on target device.
+        self.target.mbs.btSetName('LookForMe!')
+
+    def test_bluetooth_discovery(self):
+        target_name = self.target.mbs.btGetName()
+        self.target.log.info('Become discoverable with name "%s" for %ds.',
+                             target_name, DISCOVERABLE_TIME)
+        self.target.mbs.btBecomeDiscoverable(DISCOVERABLE_TIME)
+        self.discoverer.log.info('Looking for Bluetooth devices.')
+        discovered_devices = self.discoverer.mbs.btDiscoverAndGetResults()
+        self.discoverer.log.debug('Found Bluetooth devices: %s',
+                                  pprint.pformat(discovered_devices, indent=2))
+        discovered_names = [device['Name'] for device in discovered_devices]
+        logging.info('Verifying the target is discovered by the discoverer.')
+        asserts.assert_true(
+            target_name in discovered_names,
+            'Failed to discover the target device %s over Bluetooth.' %
+            target_name)
+
+    def teardown_test(self):
+        # Turn Bluetooth off on both devices after test finishes.
+        self.target.mbs.btDisable()
+        self.discoverer.mbs.btDisable()
+
+
 if __name__ == '__main__':
-  test_runner.main()
+    test_runner.main()
+
 ```
- 
-One will notice that this is not the most robust test (another nearby device
-could be using the same name), but in the interest of simplicity, we've limited
-the number of RPCs sent to each Android device to just two:
- 
-*   For `self.dut`, we asked it to make itself discoverable and checked that it
-    did it.
-*   For `self.discoverer`, we asked it to start scanning for nearby bluetooth
-    devices, and then we pulled the list of devices seen.
- 
-There's potentially a lot more we could do to write a thorough test (e.g., check
-the hardware address, see whether we can pair devices, transfer files, etc.).
- 
-# Event Dispatcher
- 
-You'll notice above that we've used `self.{device_alias}.ed.pop_event()`. The
-`ed` attribute of an Android device object is an EventDispatcher, which provides
-APIs to interact with async events.
- 
-For example, `pop_event` is a function which will block until either a
-specified event is seen or the call times out, and by using it we avoid the use
-of busy loops that constantly check the device state. For more, see the APIs in
-`mobly.controllers.android_device_lib.event_dispatcher`.
+
+There's potentially a lot more we could do in this test, e.g. check
+the hardware address, see whether we can pair devices, transfer files, etc.
+
+To learn more about the features included in MBS, go to [MBS repo]
+(https://github.com/google/mobly-bundled-snippets) to see how to check its help
+menu.
+
+To learn more about Mobly Snippet Lib, including features like Espresso support
+and asynchronous calls, see the [snippet lib examples]
+(https://github.com/google/mobly-snippet-lib/tree/master/examples).
diff --git a/mobly/controllers/android_device.py b/mobly/controllers/android_device.py
index 159f587..a77e787 100644
--- a/mobly/controllers/android_device.py
+++ b/mobly/controllers/android_device.py
@@ -350,7 +350,7 @@ class AndroidDevice(object):
                   android device should be stored.
         log: A logger adapted from root logger with an added prefix specific
              to an AndroidDevice instance. The default prefix is
-             [AndroidDevice|<serial>]. Use self.set_debug_tag to use a
+             [AndroidDevice|<serial>]. Use self.debug_tag = 'tag' to use a
              different tag in the prefix.
         adb_logcat_file_path: A string that's the full path to the adb logcat
                               file collected, if any.
@@ -408,6 +408,7 @@ class AndroidDevice(object):
             The tag can be customized with `ad.debug_tag = 'Caller'`:
                 'INFO [AndroidDevice|Caller] One pending call ringing.'
         """
+        self.log.info('Logging debug tag set to "%s"', tag)
         self._debug_tag = tag
         self.log.extra['tag'] = tag
 
@@ -759,11 +760,11 @@ class AndroidDevice(object):
         try:
             extra_params = self.adb_logcat_param
         except AttributeError:
-            extra_params = '-b all'
+            extra_params = ''
         cmd = 'adb -s %s logcat -v threadtime %s >> %s' % (
             self.serial, extra_params, logcat_file_path)
-        self._adb_logcat_process = utils.start_standing_subprocess(
-            cmd, shell=True)
+        process = utils.start_standing_subprocess(cmd, shell=True)
+        self._adb_logcat_process = process
         self.adb_logcat_file_path = logcat_file_path
 
     def stop_adb_logcat(self):


Test patch:
diff --git a/tests/mobly/controllers/android_device_test.py b/tests/mobly/controllers/android_device_test.py
index 136bbba..b1cd7fe 100755
--- a/tests/mobly/controllers/android_device_test.py
+++ b/tests/mobly/controllers/android_device_test.py
@@ -280,7 +280,7 @@ class AndroidDeviceTest(unittest.TestCase):
                                          "AndroidDevice%s" % ad.serial,
                                          "adblog,fakemodel,%s.txt" % ad.serial)
         creat_dir_mock.assert_called_with(os.path.dirname(expected_log_path))
-        adb_cmd = 'adb -s %s logcat -v threadtime -b all >> %s'
+        adb_cmd = 'adb -s %s logcat -v threadtime  >> %s'
         start_proc_mock.assert_called_with(
               adb_cmd % (ad.serial, expected_log_path), shell=True)
         self.assertEqual(ad.adb_logcat_file_path, expected_log_path)