Skip to content

Commit

Permalink
add getAppCrash.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
gb112211 committed Jun 2, 2015
1 parent 0268d1d commit 8ba5177
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Android测试中常用到的脚本
批量安装应用(支持以中文命名的 apk)、批量卸载、截屏、录制视频、获取当前应用的 apk 文件、包名、Activity 名等。<br>

###2015.06.02
增加 `get_app_crash_log`, 应用发生 crash ,未及时从 logcat 获取到有效 log 时,可通过该脚本获取 log
增加 `get_app_crash_log.py``getAppCrash.sh`, 应用发生 crash ,未及时从 logcat 获取到有效 log 时,可通过该脚本获取 log

###2015.05.30
增加 `get_app_permission.py`,获取设备当前应用的权限详情,windows 下会将结果写入 `permission.txt` 文件中,其他系统打印在控制台:
Expand Down
2 changes: 1 addition & 1 deletion python/get_app_crash_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from scriptUtils import utils

# app发生crash,未及时在logcat中抓取到有效log时,可通过该脚本获取到log
# app发生crash,未及时在logcat中抓取到有效log时,可通过该脚本获取到log,日志存放至crash_log目录

PATH = lambda p : os.path.abspath(p)

Expand Down
34 changes: 34 additions & 0 deletions shell/getAppCrashLog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# 获取crash日志,存放至crash_log目录下

timestamp=`adb shell date +%F_%H-%M-%S | tr -d "\r"`
adb shell dumpsys dropbox | grep data_app_crash > temp.txt
log_dir="./crash_log"

if [ ! -d "$log_dir" ]
then
mkdir $log_dir
fi

get_crash_log()
{
time_list=[]
index=0
for result in `cat temp.txt | cut -d " " -f 2`
do
time_list[$index]=$result
let "index+=1"

done

for time in ${time_list[@]}
do
adb shell dumpsys dropbox --print $time >> $log_dir/$timestamp.log
done
}

get_crash_log
rm -f temp.txt
echo "Completed..."

0 comments on commit 8ba5177

Please sign in to comment.