Primiano Tucci | a662485 | 2020-05-21 19:12:50 +0100 | [diff] [blame] | 1 | # Android Log |
| 2 | |
| 3 | _This data source is supported only on Android userdebug builds._ |
| 4 | |
| 5 | The "android.log" data source records log events from the Android log |
| 6 | daemon (`logd`). These are the same log messages that are available via |
| 7 | `adb logcat`. |
| 8 | |
| 9 | Both textual events and binary-formatted events from the [EventLog] are |
| 10 | supported. |
| 11 | |
| 12 | This allows you to see log events time-synced with the rest of the trace. When recording |
| 13 | [long traces](/docs/concepts/config#long-traces), it allows you to record event |
| 14 | logs indefinitely, regardless of the Android log daemon buffer size |
| 15 | (i.e. log events are periodically fetched and copied into the trace buffer). |
| 16 | |
| 17 | The data source can be configured to filter event from specific log buffers and |
| 18 | keep only the events matching specific tags or priority. |
| 19 | |
| 20 | [EventLog]: https://developer.android.com/reference/android/util/EventLog |
| 21 | |
| 22 | ### UI |
| 23 | |
| 24 | At the UI level, log events are showed in two widgets: |
| 25 | |
| 26 | 1. A summary track that allows to quickly glance at the distribution of events |
| 27 | and their severity on the timeline. |
| 28 | |
| 29 | 2. A table, time-synced with the viewport, that allows to see events within the |
| 30 | selected time range. |
| 31 | |
| 32 |  |
| 33 | |
| 34 | ### SQL |
| 35 | |
| 36 | ```sql |
| 37 | select l.ts, t.tid, p.pid, p.name as process, l.prio, l.tag, l.msg |
| 38 | from android_logs as l left join thread as t using(utid) left join process as p using(upid) |
| 39 | ``` |
| 40 | ts | tid | pid | process | prio | tag | msg |
| 41 | ---|-----|-----|---------|------|-----|---- |
| 42 | 291474737298264 | 29128 | 29128 | traced_probes | 4 | perfetto | probes_producer.cc:231 Ftrace setup (target_buf=1) |
| 43 | 291474852699265 | 625 | 625 | surfaceflinger | 3 | SurfaceFlinger | Finished setting power mode 1 on display 0 |
| 44 | 291474853274109 | 1818 | 1228 | system_server | 3 | SurfaceControl | Excessive delay in setPowerMode() |
| 45 | 291474882474841 | 1292 | 1228 | system_server | 4 | DisplayPowerController | Unblocked screen on after 242 ms |
| 46 | 291474918246615 | 1279 | 1228 | system_server | 4 | am_pss | Pid=28568 UID=10194 Process Name="com.google.android.apps.fitness" Pss=12077056 Uss=10723328 SwapPss=183296 Rss=55021568 StatType=0 ProcState=18 TimeToCollect=51 |
| 47 | |
| 48 | ### TraceConfig |
| 49 | |
| 50 | Trace proto: |
Christopher Phlipot | 855adf7 | 2023-03-17 10:26:14 -0700 | [diff] [blame] | 51 | [AndroidLogPacket](/docs/reference/trace-packet-proto.autogen#AndroidLogPacket) |
Primiano Tucci | a662485 | 2020-05-21 19:12:50 +0100 | [diff] [blame] | 52 | |
| 53 | Config proto: |
Christopher Phlipot | 855adf7 | 2023-03-17 10:26:14 -0700 | [diff] [blame] | 54 | [AndroidLogConfig](/docs/reference/trace-config-proto.autogen#AndroidLogConfig) |
Primiano Tucci | a662485 | 2020-05-21 19:12:50 +0100 | [diff] [blame] | 55 | |
| 56 | Sample config: |
| 57 | |
| 58 | ```protobuf |
| 59 | data_sources: { |
| 60 | config { |
| 61 | name: "android.log" |
| 62 | android_log_config { |
| 63 | min_prio: PRIO_VERBOSE |
| 64 | filter_tags: "perfetto" |
| 65 | filter_tags: "my_tag_2" |
| 66 | log_ids: LID_DEFAULT |
| 67 | log_ids: LID_RADIO |
| 68 | log_ids: LID_EVENTS |
| 69 | log_ids: LID_SYSTEM |
| 70 | log_ids: LID_CRASH |
| 71 | log_ids: LID_KERNEL |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | ``` |