Android studio 过滤log中指定字符(不显示包含指定字符的log)
^(?!.*(你要过滤掉的字符)).*$
*log中包含got 或Activity 的log将不显示在控制台。
^(?!.*(got|Activity)).*$
只显示指定字符的log
^(.*(10:30|10:33)).*$
Logcat
採用grep正則表示式過濾
adb logcat | grep -iE "Audio3DSettings|setParameters|setAudio3DState"
在同時輸出到螢幕和檔案 tee
adb logcat | grep -E '^[VDE]/(TAG1|TAG2)' | tee my.log
可以看出 tag 是一行開頭的第三個字元開始
adb logcat | grep "^..MyApp"
僅顯示 Error 級別 tag 為 MyApp 的輸出
adb logcat | grep "^E.MyApp"
要匹配 tag 為 MyApp 和 MyActivity 的輸出
adb logcat | grep "^..MyApp\|^..MyActivity"
adb logcat | grep -E "^..MyApp|^..MyActivity" #使用 egrep 無須轉義符
過濾 tag 為 MyApp 和 MyActivity 的輸出
adb logcat | grep -v "^..MyApp\|^..MyActivity"
adb logcat | grep -vE "^..MyApp|^..MyActivity" #使用 egrep 無須轉義符
logcat | grep -vE "BluetoothAdapter|chatty| BluetoothManagerService| *bluetooth* | *Bluetooth*|bluetoot|bt_*"
顯示同一個程序的所有輸出
#!/bin/bash
packageName=$1
pid=`adb shell ps | grep $packageName | awk ‘{print $2}’`
adb logcat | grep –color=auto $pid
從當前開始顯示
adb logcat -c && adb logcat
logcat | grep -e Controller -e StateDvrPlayback
No comments:
Post a Comment