-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.sh
More file actions
executable file
·65 lines (52 loc) · 1.04 KB
/
log.sh
File metadata and controls
executable file
·65 lines (52 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
set -e
# set -x
key="$1"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-c|--clean)
CLEAN="$1"
shift # past argument
;;
-p|--pkg)
PKG="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
if [[ ! -z "$CLEAN" ]] ; then
adb logcat -c
fi
if [[ -z "$PKG" ]] ; then
PKG=$(cat app/build.gradle | grep applicationId | awk '{print $2}' | sed -e 's/^"//' -e 's/"$//')
else
sleep 1
fi
# adb shell ps -o USER,UID,PID,NAME
# adb logcat -v color --pid=$(adb shell pidof $PKG)
PSLIST=$(adb shell ps -A -o PID,NAME | grep $PKG)
echo "$PSLIST"
PIDS=$(echo $(echo $"$PSLIST" | awk '{print $1}'))
echo PIDS: $PIDS
# GREP_ARGS=$(echo ${PIDS// /\\|})
# adb logcat -v color | grep $GREP_ARGS
logcat_pids=
PID_ARR=(${PIDS})
for i in "${PID_ARR[@]}"
do
adb logcat -v color --pid="$i" &
logcat_pids+=" $!"
done
_term() {
kill -TERM $logcat_pids
}
trap _term SIGINT
trap _term SIGTERM
wait $logcat_pids