android 常规log的查看与抓取

ProtoLog开关

在代码中我们经常看见ProtoLog打印的log,如下:

ProtoLog.i(WM_DEBUG_ANIM, "Animation start delayed for %s", mAnimatable);

这种log正常情况不会显示,因此我们需要打开开关,其格式为:
adb shell wm logging enable-text [代码中对应的TAG]
我们这段代码的TAG是WM_DEBUG_ANIM,因此通过命令adb shell wm logging enable-text WM_DEBUG_ANIM打开log开关

logcat抓取log

# 抓取普通的andorid log
adb shell logcat > log.txt
# 仅抓取events log
adb shell logcat -b events > log.txt
# 抓取所有类型log
adb shell logcat -b all > log.txt

# 根据关键字抓取log,-i可以忽略大小,-e可以添加多条关键字,如下:
adb shell logcat -b events | grep -ie "关键log1" -ie "关键log2"> log.txt

events.log中对应代码查找

events log对应代码的规律是:
events log开头的字段,比如wm_xxx
则对应的代码可以通过 grep 抓取 writeWmxxx 找出是在哪里打印的该events log

例如:
应用走到onresume生命周期的log
wm_on_resume_called: [223605563,com.tencent.mm.ui.LauncherUI,RESUME_ACTIVITY,10]

EventLogTags.writeWmOnResumeCalled(mIdent, getComponentName().getClassName(), reason);

通知cancel的log
notification_canceled: [0|com.tencent.mm|40|null|10218,8,19980,19980,7720,-1,-1,NULL]

EventLogTags.writeNotificationCanceled(canceledKey, reason,
                r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now),
                rank, count, listenerName);

相关推荐

  1. android 常规log查看抓取

    2024-01-19 15:18:02       30 阅读
  2. Android基础-Log管理

    2024-01-19 15:18:02       7 阅读
  3. Android查看SO库依赖

    2024-01-19 15:18:02       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-19 15:18:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-19 15:18:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-19 15:18:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-19 15:18:02       20 阅读

热门阅读

  1. 基于Jackson的Json工具类

    2024-01-19 15:18:02       30 阅读
  2. Kotlin 协程 asyn和launch简单使用

    2024-01-19 15:18:02       36 阅读
  3. Kotlin学习第1篇——data class

    2024-01-19 15:18:02       36 阅读
  4. React16源码: React中的FunctionComponent的源码实现

    2024-01-19 15:18:02       31 阅读
  5. Kotlin协程的JVM实现源码分析(上)

    2024-01-19 15:18:02       33 阅读
  6. C生万物呀

    2024-01-19 15:18:02       34 阅读
  7. BAPI_ALM_ORDER_MAINTAIN -- 创建维修工单

    2024-01-19 15:18:02       28 阅读
  8. c++位运算

    2024-01-19 15:18:02       33 阅读