adb logcat查看某个进程的输出日志

adb logcat 默认是没有这个功能的,我实现了一个小bash函数,添加到你$HOME/.bashrc 文件中:

# 作用:能够通过进程名显示log
# 用法:alogcat com.android.calendar or alogcat calendar
# 当监控的进程异常退出时,需要重新运行此命令
function alogcat() {
	OUT=$(adb shell ps | grep -i $1 | awk '{print $2}')
	OUT=$(echo $OUT | sed 's/[[:blank:]]\+/\|/g')
	# 当进程异常退出,log是通过 AndroidRuntime 输出的
	adb logcat -v time  |grep -E "$OUT|AndroidRuntime"
}

调用方法:

alogcat email

email 替换成你的packagename,全名或部分都可以

转自:http://www.yinqisen.cn/blog-515.html

posted @ 2016-09-08 10:21  鹤骨松姿  阅读(6911)  评论(0编辑  收藏  举报