def _LogDevicesOnFailure(msg):
  try:
    yield
  except base_error.BaseError:
    logging.exception(msg)
    logging.error('Devices visible to adb:')
    for entry in adb_wrapper.AdbWrapper.Devices(desired_state=None,
                                                long_list=True):
      logging.error('  %s: %s',
                    entry[0].GetDeviceSerial(),
                    ' '.join(entry[1:]))
    raise