当前位置: 首页 > article >正文

android framework ams/wms常见系统日志(main\system\events\crash,protoLog使用)

重要性

  • wms和ams的一些系统原生日志能够帮助我们快速定位问题

日志分类

在日常framework工作中常见的日志类别如下:

-b , --buffer= Request alternate ring buffer, ‘main’,
‘system’, ‘radio’, ‘events’, ‘crash’, ‘default’ or ‘all’.

Additionally, ‘kernel’ for userdebug and eng builds, and
‘security’ for Device Owner installations.
Multiple -b parameters or comma separated list of buffers are
allowed. Buffers interleaved. Default -b main,system,crash.

  • main日志:日常使用的Log.e/Log.w/Log.i等等(andoird.util.log)
    抓取时,可以使用logcat -b main来指定抓取main日志

  • system日志:源码中使用Slog.e…等
    抓取时使用logcat -b system

  • events日志:源码中使用EventLog.writeEvent打印,可以观察到窗口的很多信息,比如onStart、onResume等等
    例如我将一个app切后台后,重新拉起,直接使用 adb logcat | grep 进程号得到如下的日志信息。在这里插入图片描述
    如果使用 adb logcat -b events:
    (切后台日志)
    在这里插入图片描述
    (后台重新拉起)
    在这里插入图片描述
    上面两个图是在aosp11环境中打印的,在AOSP13中tag会发生变化,我们如果想要找到源码中的这行日志打印的地方,可以通过如下的拼接方式找到对应的源码位置。
    在这里插入图片描述
    一般来说,带有on_wm、on_am等等,可以发现都是在应用进程进行打印的。
    如果不想单独看events的日志,可以使用 logcat -b all

  • crash日志 - kernel日志 - 其他

ProtoLog动态开关某一部分功能的日志

ProtoLog是google增加的动态打开某一个功能日志的开关能力,用于针对某一功能进行调试或者开发时,能够更加方便。
在android10里面,这部分功能还没有
在这里插入图片描述
在aosp11及以上,是存在的
在这里插入图片描述

这里面的logging就是ProtoLog的控制开关
在这里插入图片描述
这里存在一个差别:enable和enable-text是有啥差别?

  • enable对应proto logging抓取会把日志写入到data/misc/wmtrace/路径下wm_log.winscope
  • enable-text对应就是logcat可以直接看到的,平时使用这个就ok了;
wm logging enable-text xxxx
可以开启对应的关键字/功能的抓取

这里的xxx如何判断?

例如:想要看WM_SHOW_TRANSACTIONS这个tag,需要怎么控制
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
因此,想要看WM_SHOW_TRANSACTIONS这个tag,只需要

  1. wm logging enable-text WM_SHOW_TRANSACTIONS
  2. 而这个logcat日志的tag就是WindowManager,只需要logcat -s WindowManager | grep Surface Hide 就ok了。

adb logcat -h查看常见logcat指令

adb logcat -h 查看常见命令

adb logcat -h
Usage: logcat [options] [filterspecs]
options include:
  -s              Set default filter to silent. Equivalent to filterspec '*:S'
  -f <file>, --file=<file>               Log to file. Default is stdout
  -r <kbytes>, --rotate-kbytes=<kbytes>
                  Rotate log every kbytes. Requires -f option
  -n <count>, --rotate-count=<count>
                  Sets max number of rotated logs to <count>, default 4
  --id=<id>       If the signature id for logging to file changes, then clear
                  the fileset and continue
  -v <format>, --format=<format>
                  Sets log print format verb and adverbs, where <format> is:
                    brief help long process raw tag thread threadtime time
                  and individually flagged modifying adverbs can be added:
                    color descriptive epoch monotonic printable uid
                    usec UTC year zone
                  Multiple -v parameters or comma separated list of format and
                  format modifiers are allowed.
  -D, --dividers  Print dividers between each log buffer
  -c, --clear     Clear (flush) the entire log and exit
                  if Log to File specified, clear fileset instead
  -d              Dump the log and then exit (don't block)
  -e <expr>, --regex=<expr>
                  Only print lines where the log message matches <expr>
                  where <expr> is a Perl-compatible regular expression
  -m <count>, --max-count=<count>
                  Quit after printing <count> lines. This is meant to be
                  paired with --regex, but will work on its own.
  --print         Paired with --regex and --max-count to let content bypass
                  regex filter but still stop at number of matches.
  -t <count>      Print only the most recent <count> lines (implies -d)
  -t '<time>'     Print most recent lines since specified time (implies -d)
  -T <count>      Print only the most recent <count> lines (does not imply -d)
  -T '<time>'     Print most recent lines since specified time (not imply -d)
                  count is pure numerical, time is 'MM-DD hh:mm:ss.mmm...'
                  'YYYY-MM-DD hh:mm:ss.mmm...' or 'sssss.mmm...' format
  -g, --buffer-size                      Get the size of the ring buffer.
  -G <size>, --buffer-size=<size>
                  Set size of log ring buffer, may suffix with K or M.
  -L, --last      Dump logs from prior to last reboot
  -b <buffer>, --buffer=<buffer>         Request alternate ring buffer, 'main',
                  'system', 'radio', 'events', 'crash', 'default' or 'all'.
                  Additionally, 'kernel' for userdebug and eng builds, and
                  'security' for Device Owner installations.
                  Multiple -b parameters or comma separated list of buffers are
                  allowed. Buffers interleaved. Default -b main,system,crash.
  -B, --binary    Output the log in binary.
  -S, --statistics                       Output statistics.
  -p, --prune     Print prune white and ~black list. Service is specified as
                  UID, UID/PID or /PID. Weighed for quicker pruning if prefix
                  with ~, otherwise weighed for longevity if unadorned. All
                  other pruning activity is oldest first. Special case ~!
                  represents an automatic quicker pruning for the noisiest
                  UID as determined by the current statistics.
  -P '<list> ...', --prune='<list> ...'
                  Set prune white and ~black list, using same format as
                  listed above. Must be quoted.
  --pid=<pid>     Only prints logs from the given pid.
  --wrap          Sleep for 2 hours or when buffer about to wrap whichever
                  comes first. Improves efficiency of polling by providing
                  an about-to-wrap wakeup.

filterspecs are a series of
  <tag>[:priority]

where <tag> is a log component tag (or * for all) and priority is:
  V    Verbose (default for <tag>)
  D    Debug (default for '*')
  I    Info
  W    Warn
  E    Error
  F    Fatal
  S    Silent (suppress all output)

'*' by itself means '*:D' and <tag> by itself means <tag>:V.
If no '*' filterspec or -s on command line, all filter defaults to '*:V'.
eg: '*:S <tag>' prints only <tag>, '<tag>:S' suppresses all <tag> log messages.

If not specified on the command line, filterspec is set from ANDROID_LOG_TAGS.

If not specified with -v on command line, format is set from ANDROID_PRINTF_LOG
or defaults to "threadtime"

-v <format>, --format=<format> options:
  Sets log print format verb and adverbs, where <format> is:
    brief long process raw tag thread threadtime time
  and individually flagged modifying adverbs can be added:
    color descriptive epoch monotonic printable uid usec UTC year zone

Single format verbs:
  brief      — Display priority/tag and PID of the process issuing the message.
  long       — Display all metadata fields, separate messages with blank lines.
  process    — Display PID only.
  raw        — Display the raw log message, with no other metadata fields.
  tag        — Display the priority/tag only.
  thread     — Display priority, PID and TID of process issuing the message.
  threadtime — Display the date, invocation time, priority, tag, and the PID
               and TID of the thread issuing the message. (the default format).
  time       — Display the date, invocation time, priority/tag, and PID of the
             process issuing the message.

Adverb modifiers can be used in combination:
  color       — Display in highlighted color to match priority. i.e. VERBOSE
                DEBUG INFO WARNING ERROR FATAL
  descriptive — events logs only, descriptions from event-log-tags database.
  epoch       — Display time as seconds since Jan 1 1970.
  monotonic   — Display time as cpu seconds since last boot.
  printable   — Ensure that any binary logging content is escaped.
  uid         — If permitted, display the UID or Android ID of logged process.
  usec        — Display time down the microsecond precision.
  UTC         — Display time as UTC.
  year        — Add the year to the displayed time.
  zone        — Add the local timezone to the displayed time.
  "<zone>"    — Print using this public named timezone (experimental).

http://www.kler.cn/a/399295.html

相关文章:

  • Java爬虫(Jsoup)详解
  • 2024年09月CCF-GESP编程能力等级认证Python编程三级真题解析
  • 了解 Solon MVC 的参数注入规则
  • spring-cache concurrentHashMap 自定义过期时间
  • dpdk tm eth event驱动协同完成收发包流程
  • 【0x001C】HCI_Write_Page_Scan_Activity详解
  • springmvc通过使用map来进行数据的接收和使用
  • 【python系列】python数据类型之字符串
  • uniapp h5 实现扫扫二维码
  • 排序算法 -快速排序
  • 【 LLM论文日更|检索增强:大型语言模型是强大的零样本检索器 】
  • Java基础-组件及事件处理(中)
  • 深度学习的艺术:揭秘卷积神经网络(CNN)的神秘面纱
  • Linux-何为CentOS
  • Unity3D中管理Shader效果详解
  • 算法定制LiteAIServer摄像机实时接入分析平台玩手机打电话检测算法:智能监控的新篇章
  • 基础:用卷积神经网络(CNN)进行猫狗图像分类
  • (四)P2Link内置HTTP服务,分享本地文件
  • 力扣515:在每个树行中找最大值
  • 云原生周刊:Istio 1.24.0 正式发布
  • css:盒子模型
  • 【GAT】 代码详解 (1) 运行方法【pytorch】可运行版本
  • React Native 全栈开发实战班 -原生功能集成之相机与图片
  • 希尔排序(C语言)
  • 基于STM32设计的大棚育苗管理系统(4G+华为云IOT)_265
  • 易考八股文之Elasticsearch合集