日志抓取并保存为文件方便查看调试
#!/bin/sh
send=$(date "+%Y-%m-%d %H-%M-%S")
file="/Users/lili/Desktop/logall$send.txt"
echo $file
adb shell logcat -c
adb shell logcat -v time >"$file"
根据时间保存日志名称,adb shell logcat
-c 清理之前的日志
-v time 以时间为顺序显示
>"$file" 保存的位置
用法:在调试你的代码之前,打开终端跑shell命令。跑命令后他会阻塞着,这时候桌面应该创建以当前时间结尾的日志文件。它一直在变大,直到你 按下 control+c停止记录。