如何在多个设备上运行logcat?

发布于 2024-11-10 14:41:35 字数 113 浏览 3 评论 0原文

如何同时在多个设备上运行logcat? “adb logcat”命令给出错误:

error: more than one device and emulator

How can I run logcat on multiple devices at the same time? "adb logcat" command gives an error:

error: more than one device and emulator

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

毁梦 2024-11-17 14:41:35

使用adb-s选项:

adb -s <serialnumber>

示例

C:\Users\lel>adb devices
List of devices attached
192.168.198.101:5555    device
0123456789ABCDEF        device

adb -s 0123456789ABCDEF logcat
adb -s 192.168.198.101:5555 logcat

您可以将grep与此结合起来,以获取包含以下内容的所有行它。
一个例子是 System.out

示例:

 adb -s 192.168.198.101:5555 logcat | grep "System.out"

Use the -s option of adb:

adb -s <serialnumber>

Example

C:\Users\lel>adb devices
List of devices attached
192.168.198.101:5555    device
0123456789ABCDEF        device

adb -s 0123456789ABCDEF logcat
adb -s 192.168.198.101:5555 logcat

You can combine grep whit this, to get all lines that contain it.
an example is with System.out

Example:

 adb -s 192.168.198.101:5555 logcat | grep "System.out"
允世 2024-11-17 14:41:35

我认为这可能有用。我有这个脚本对我帮助很大。它将每个设备记录到不同的文件中。要停止记录,只需按 CTRL+C。

#! /bin/bash

devices=`adb devices | grep 'device
 | cut -f1`
pids=""

for device in $devices
do
    log_file="$device-`date +%d-%m-%H:%M:%S`.log"
    echo "Logging device $device to \"$log_file\""
    adb -s $device logcat -v threadtime > $log_file &
    pids="$pids $!"
done

echo "Children PIDs: $pids"

killemall()
{
    echo "Killing children (what a shame...)"

    for pid in $pids
    do
        echo "Killing $pid"
        kill -TERM $pid
    done
}

trap killemall INT

wait

I thought it might be useful. I have this script that helps me a lot. It logcats each device to a different file. To stop logging just press CTRL+C.

#! /bin/bash

devices=`adb devices | grep 'device
 | cut -f1`
pids=""

for device in $devices
do
    log_file="$device-`date +%d-%m-%H:%M:%S`.log"
    echo "Logging device $device to \"$log_file\""
    adb -s $device logcat -v threadtime > $log_file &
    pids="$pids $!"
done

echo "Children PIDs: $pids"

killemall()
{
    echo "Killing children (what a shame...)"

    for pid in $pids
    do
        echo "Killing $pid"
        kill -TERM $pid
    done
}

trap killemall INT

wait
无可置疑 2024-11-17 14:41:35

使用您的设备 IP:
adb -s device_ip:5555

Use your device ip:
adb -s device_ip:5555

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文