How to run logcat on multiple devices?

后端 未结 3 1662
夕颜
夕颜 2020-12-23 16:31

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
3条回答
  •  囚心锁ツ
    2020-12-23 16:56

    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
    

提交回复
热议问题