# logcat

`logcat` 是一个用于读取和显示系统日志的工具，支持多种日志缓冲区（如 log_main、 log_system、 log_radio 等），并可以根据用户指定的过滤规则筛选日志输出。

## 语法说明

以下是执行 `logcat` 的帮助信息：

```bash
Usage: logcat [options] [filterspecs]
options include:
  -s              Set default filter to silent. Like specifying filterspec '*:s'
  -f <filename>   Log to file. Default to stdout
  -r [<kbytes>]   Rotate log every kbytes. (16 if unspecified). Requires -f
  -n <count>      Sets max number of rotated logs to <count>, default 4
  -v <format>     Sets the log print format, where <format> is one of:
                  brief process tag thread raw time threadtime long
  -c              clear (flush) the entire log and exit
  -d              dump the log and then exit (don't block)
  -t <count>      print only the most recent <count> lines (implies -d)
  -g              get the size of the log's ring buffer and exit
  -b <buffer>     Request alternate ring buffer, 'main', 'system', 'radio'
                  or 'events'. Multiple -b parameters are allowed and the
                  results are interleaved. The default is -b main -b system.
  -B              output the log in binary
filterspecs are a series of <tag>[:priority]
where <tag> is a log component tag (or * for all) and priority is:
  V    Verbose
  D    Debug
  I    Info
  W    Warn
  E    Error
  F    Fatal
  S    Silent (suppress all output)
'*' means '*:d' and <tag> by itself means <tag>:v
If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.
If no filterspec is found, filter defaults to '*:I'
If not specified with -v, format is set from ANDROID_PRINTF_LOG or defaults to "brief"
```

## 参数选项说明

- -s：设置默认过滤规则为静默模式（*:s），即不显示任何日志。
- -f <filename>：将日志输出到指定文件，而不是标准输出。
- -r [<kbytes>]：每隔指定的千字节数（默认为 16KB）自动轮转日志文件。需要与 -f 参数一起使。
- -n <count>：设置最大轮转日志文件数量，默认为 4 。
- -v <format>：设置日志输出格式，可选值包括：
  - brief：简短格式，显示时间戳、优先级和标签。
  - process：显示进程信息。
  - tag：仅显示标签。
  - thread：显示线程信息。
  - raw：原始日志格式。
  - time：显示时间戳。
  - threadtime：显示线程时间戳。
  - long：长格式，显示详细信息。
- -c：清空（刷新）整个日志缓冲区并退出。
- -d：将日志转储到标准输出后退出（不阻塞）。
- -t：<count>：仅打印最近的 <count> 行日志（隐含 -d 参数）。
- -g：获取日志缓冲区的大小并退出。
- -b <buffer>：请求备用日志缓冲区，可选值包括 main、 radio 。可以多次使用 -b 参数，结果将交错显示。默认值为 -b log_main - -b log_radio。
  - log 系统支持 1 个 2MB 的 log_main 缓冲区， 1 个 256KB 的 log_radio 缓冲区，建议使用 log_main 缓冲区。
  - 当 LOG_TAG 是 \"HTC_RIL\"、\"RIL\"、\"IMS\"、\"AT\"、\"GSM\"、\"STK\"、\"CDMA\"、\"PHONE\"、\"SMS\" 时，日志保存到 log_radio 缓冲区，其他的都保存到 log_main 缓冲区。
- -B：以二进制格式输出日志。
- filterspecs：过滤规则，格式为 <tag>[:priority]。其中 <tag> 是日志组件标签（或使用 * 表示所有标签）， priority 是日志优先级：
  - V：详细
  - D：调试
  - I：信息
  - W：警告
  - E：错误
  - F：致命
  - S：静默（不显示任何输出）
  - 如果未指定过滤规则，将从环境变量 ANDROID_LOG_TAGS 中读取，如果没有找到过滤规则，默认为 *:I。

## 各项命令选项及其功能说明

### 默认使用方式

命令：

```bash
root@buildroot:~# logcat
```

功能：

以默认格式（ brief）显示所有日志信息。

打印输出：

```bash
logcat test start !!!
--------- beginning of /dev/log_main
I/        ( 1053): [29.023584][hbn_vpf_interface.c]:[hbn_vnode_get_attr][532]vin0 ctx0 done
D/        ( 1053): [29.023600][camera_vpf]:[camera_vpf_vin_attr_show][982] vin_attr : flow0 disable rx with vcon
W/        ( 1053): [29.023611][camera_vpf]:[camera_vpf_vin_attr_show][994]     mipi : rx0 vc0(0) not enable
D/        ( 1053): [29.023621][camera_vpf]:[camera_vpf_vin_attr_show][997]     vcon : valid 0x5a1
D/        ( 1053): [29.023632][camera_vpf]:[camera_vpf_vin_attr_show][1007]     bus_main : 4
D/        ( 1053): [29.023642][camera_vpf]:[camera_vpf_vin_attr_show][1007]        oth_0 : 498
D/        ( 1053): [29.023651][camera_vpf]:[camera_vpf_vin_attr_show][1007]    lpwm_chn0 : 0
D/        ( 1053): [29.023664][camera_vpf]:[camera_vpf_vin_attr_show][1007]  rx_phy_mode : 1
D/        ( 1053): [29.023676][camera_vpf]:[camera_vpf_vin_attr_show][1007] rx_phy_index : 0
D/        ( 1053): [29.023684][camera_vpf]:[camera_vpf_vin_attr_show][1007]    vcon_type : 0
D/        ( 1053): [29.023697][camera_vpf]:[camera_vpf_vin_attr_show][1007]    vcon_link : 0
D/        ( 1053): [29.023727][sensor_lib]:[camera_sensor_ops_bind][524] sensor sc230ai ops bind
W/        ( 1053): [29.023745][sensor_lib]:[camera_sensor_set_cali_name][585] calib_lname is null, we will try sensor_name_tuning.json.
I/        ( 1053): [29.023792][sensor_lib]:[camera_sensor_set_cali_name][614] camera_sensor_set_cali_name port:0, calib_lname:sc230ai_tuning.json
D/        ( 1053): [29.023808][sensor_lib]:[camera_sensor_config_parse][653] sensor sc230ai 0x30 config parse
D/        ( 1053): [29.023821][sensor_lib]:[camera_sensor_config_parse][717] sensor sc230ai auto disable all diag
D/        ( 1053): [29.023869][sensor_dev]:[camera_sensor_dev_open][95] open /dev/port_0 v1.0 sc230ai as 36
D/        ( 1053): [29.024015][camera_i2c]:[camera_i2c_init][177] i2c4 mutex lock 0xffffaf591000 shmid 0
I/        ( 1053): [29.024033][camera_i2c]:[camera_i2c_init][191] i2c4 init as fd 37
D/        ( 1053): [29.024059][sensor_lib]:[camera_sensor_init][1438] sensor0 sc230ai init real doing
D/        ( 1053): [29.024097][sc230ai]:sc230ai gpio_num = 1
D/        ( 1053): [29.024111][sc230ai]:sc230ai gpio_pin[0] = 498
I/        ( 1053): [29.236275][sc230ai]:sc230ai in normal linear mode
I/        ( 1053): [29.236340][sc230ai]:bus_num = 4, sensor_addr = 0x30
I/        ( 1053): [29.325516][sc230ai]:sc230ai config success under 1 mode
I/        ( 1053): [29.425695][sc230ai]:sensor_dynamic_switch_fps sc230ai 10fps
I/        ( 1053): [29.427839][sc230ai]:sc230ai dynamic switch to 10fps success
I/        ( 1053): [29.427900][sc230ai]:enable userspace gain control and line control
D/        ( 1053): [29.428026][sensor_dev]:[camera_sensor_cdev_open][832] open /dev/sensor_ctrl v1.0 for sensor0 sc230ai as 38
I/        ( 1053): [29.428480][sc230ai]:enable userspace gain control and line control
I/        ( 1053): [29.428518][sensor_lib]:[camera_sensor_ctrl_func][1057] thread sen0_ctrl:sc230ai work en 0x3
I/        ( 1053): [29.428635][sensor_lib]:[camera_sensor_init][1534] sensor0 sc230ai init real done
I/        ( 1053): [29.428663][sensor_lib]:[camera_sensor_devop_func][1258] thread sen0:sc230ai work
W/        ( 1053): [29.428679][sensor_lib]:[camera_sensor_get_iparam][2266] sensor0 sc230ai 0x0@0.0ps state 4-NOT_SUPPORT
D/        ( 1053): [29.428711][sensor_lib]:[camera_sensor_set_sensor_info_to_driver][2316] sensor0 sc230ai set_intrinsic_param state 4-NOT_SUPPORT
W/        ( 1053): [29.428732][sensor_comm]:[camera_sensor_emode_parse][149] sensor sc230ai extra_mode 0 emode name is NULL
D/        ( 1053): [29.428747][camera_vpf]:[camera_vpf_mipi_config_parse][587] parse mipi config form user config add csi runtime
D/        ( 1053): [29.428764][camera_vpf]:[camera_vpf_mipi_config_parse][627] mipi config parse from user add csi runtime done:
D/        ( 1053): [29.428776][camera_vpf]:[camera_vpf_mipi_config_show][515] rx cfg:
D/        ( 1053): [29.428785][camera_vpf]:[camera_vpf_mipi_config_show][520]          lane: 1
D/        ( 1053): [29.428801][camera_vpf]:[camera_vpf_mipi_config_show][520]      datatype: 43
D/        ( 1053): [29.428808][camera_vpf]:[camera_vpf_mipi_config_show][520]           fps: 10
D/        ( 1053): [29.428820][camera_vpf]:[camera_vpf_mipi_config_show][520]          mclk: 24
D/        ( 1053): [29.428827][camera_vpf]:[camera_vpf_mipi_config_show][520]       mipiclk: 810
D/        ( 1053): [29.428837][camera_vpf]:[camera_vpf_mipi_config_show][520]         width: 1920
D/        ( 1053): [29.428844][camera_vpf]:[camera_vpf_mipi_config_show][520]        height: 1080
D/        ( 1053): [29.428852][camera_vpf]:[camera_vpf_mipi_config_show][520]     linelenth: 2348
D/        ( 1053): [29.428862][camera_vpf]:[camera_vpf_mipi_config_show][520]    framelenth: 3375
D/        ( 1053): [29.428871][camera_vpf]:[camera_vpf_mipi_config_show][520]        settle: 22
D/        ( 1053): [29.428881][camera_vpf]:[camera_vpf_mipi_config_show][520]   channel_num: 1
D/        ( 1053): [29.428892][sensor_lib]:[camera_sensor_csi_attr_parse][787] camera0 sc230ai csi attr rx parse: 1lane 810Mbps 0x2b
I/        ( 1053): [29.465132][hbn_vpf_interface.c]:[hbn_vnode_set_inter_attr][1191]vin0 ctx0 vnode done
D/        ( 1053): [29.630058][sensor_dev]:[camera_sensor_cdev_ioctl][933] sensor0 sc230ai ctrl ioctl SENSOR_CTRL_INFO_SYNC 0xffffadd6e730 ret -1: Operation not permitted
E/TRACE   (  589): [29.810429]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingWbIsEnabled: wrong HDR port ID 4
E/TRACE   (  589): [29.811752]LSCV3: ALscSetCurrentConfigure: index:0 lsc xSize value incorrect
E/TRACE   (  589): [29.818581]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingWbIsEnabled: wrong HDR port ID 4
I/        ( 1053): [29.819128][camera_vpf]:[camera_vpf_vin_attach_camera][1375] attach camera0 to vin 0x8765 done
D/        ( 1053): [29.819160][camera_run]:[camera_attach_to_vin][2406] camera0 sc230ai attach to vin 0x8765 done 795.616ms
I/        ( 1053): [29.819172][camera_if]:[hbn_camera_attach_to_vin][315] camera0 sc230ai attach to vin 0x8765 as vin done
I/        ( 1053): [29.819599][hbn_vpf_interface.c]:[hbn_vnode_start][1386]vs-vse0 ctx0 vnode done
E/TRACE   (  589): [29.821016]VIDEOIN-ISP-DRV: defined HORIZON_HACK_ISP test
I/        ( 1053): [29.822292][hbn_vpf_interface.c]:[hbn_vnode_start][1386]vs-isp0 ctx0 vnode done
I/        ( 1053): [29.822405][sc230ai]:sc230ai start normal / slave linear mode
D/        ( 1053): [29.822830][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 4@0x30: 0x0100 = 0x01
I/        ( 1053): [29.822851][sensor_lib]:[camera_sensor_start][1699] sensor0 sc230ai start done 0.447ms
I/        ( 1053): [29.832952][hbn_vpf_interface.c]:[hbn_vnode_start][1386]vin0 ctx0 vnode done
I/        ( 1053): [29.832968][hbn_vpf_interface.c]:[hbn_vflow_start][2610]flow 0 done
I/        ( 1053): [29.833002][hbn_vpf_interface.c]:[hbn_vnode_get_ochn_attr][929]vs-vse0 ctx0 vnode done
D/        ( 1053): [29.840048][sensor_dev]:[camera_sensor_cdev_ioctl][933] sensor0 sc230ai ctrl ioctl SENSOR_CTRL_INFO_SYNC 0xffffadd6e730 ret -1: Operation not permitted
I/        ( 1053): [29.873983][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1053): [29.874023][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 0 done
I/        ( 1053): [29.883240][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 0 done
I/        ( 1053): [29.973503][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1053): [29.973536][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 1 done
I/        ( 1053): [29.983711][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 1 done
I/        ( 1053): [30.073877][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1053): [30.073931][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 2 done
I/        ( 1053): [30.085339][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 2 done
I/        ( 1053): [30.174072][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
```

字段解析：

- 日志级别：
  - I：信息（ Info）：表示正常的操作信息或状态更新。例如：
    - I/ ( 1053): [29.023584][hbn_vpf_interface.c]:[hbn_vnode_get_attr][532]vin0 ctx0 done。
  - D：调试（ Debug）：表示调试信息，通常用于开发和问题排查。例如：
    - D/ ( 1053): [29.023600][camera_vpf]:[camera_vpf_vin_attr_show][982] vin_attr : flow0 disable rx with vcon。
  - W：警告（ Warn）：表示可能的问题或需要注意的事项。例如：
    - W/ （ 1053): [29.023611][camera_vpf]:[camera_vpf_vin_attr_show][994] mipi : rx0 vc0(0) not enable。
  - E：错误（ Error）：表示严重的错误或异常情况。例如：
    - E/TRACE (589): [29.810429]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingWbIsEnabled: wrong HDR port ID 4 。
- 日志内容：
  - 时间戳 ：[29.023584]：表示日志记录的时间戳（单位为秒，小数点后为毫秒）。
  - 文件名和行号：[hbn_vpf_interface.c]:[hbn_vnode_get_attr][532]：表示日志来自文件 hbn_vpf_interface.c，函数 hbn_vnode_get_attr 的第 532 行。
  - 日志内容： vin0 ctx0 done：表示 vin0 的上下文 ctx0 已完成操作等，需要根据运行时代码来解析上下文。

### 显示特定优先级的日志

命令：

```bash
logcat *:W
```

功能：

仅显示优先级为警告（ W）及以上的日志。

打印输出：

```bash
root@buildroot:~# logcat *:W

  logcat test start !!!
--------- beginning of /dev/log_main
W/        ( 1053): [29.023611][camera_vpf]:[camera_vpf_vin_attr_show][994]     mipi : rx0 vc0(0) not enable
W/        ( 1053): [29.023745][sensor_lib]:[camera_sensor_set_cali_name][585] calib_lname is null, we will try sensor_name_tuning.json.
W/        ( 1053): [29.428679][sensor_lib]:[camera_sensor_get_iparam][2266] sensor0 sc230ai 0x0@0.0ps state 4-NOT_SUPPORT
W/        ( 1053): [29.428732][sensor_comm]:[camera_sensor_emode_parse][149] sensor sc230ai extra_mode 0 emode name is NULL
E/TRACE   (  589): [29.810429]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingWbIsEnabled: wrong HDR port ID 4
E/TRACE   (  589): [29.811752]LSCV3: ALscSetCurrentConfigure: index:0 lsc xSize value incorrect
E/TRACE   (  589): [29.818581]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingWbIsEnabled: wrong HDR port ID 4
E/TRACE   (  589): [29.821016]VIDEOIN-ISP-DRV: defined HORIZON_HACK_ISP test
E/TRACE   (  589): [33.564327]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingDisable: wrong HDR port ID 4
```

### 将日志输出到文件

命令：

```bash
logcat -f /userdata/logfile.log
```

功能：

将日志输出到指定路径文件，例如将 logcat 的日志保存在 `/userdata` 路径下，名为 `logfile.log`。

打印输出：

```bash
root@buildroot:/userdata# cat logfile.log
--------- beginning of /dev/log_main
I/        (  974): [OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[637d5378], newcrc[637d5378], offset[1352]
I/        (  974): [OTA_INFO][veeprom_flag.c:396] update part num: [0]
I/        (  974): [OTA_INFO][ota_boot_control.c:304] This slot has been marked success before, no need to mark it repeatedly
I/        (  974): [OTA_INFO][ota_boot_control.c:797] set slot:0 boot success
I/        (  974): [OTA_INFO][veeprom_flag.c:86] veeprom crc, oricrc[637d5378], newcrc[637d5378], offset[1352]
I/        (  974): [OTA_INFO][veeprom_flag.c:310] veeprom: flag [0], value [3]
D/        ( 1053): [28.980268][camera_if]:[hbn_camera_create][167] create camera sc230ai
D/        ( 1053): [28.985960][camera_run]:[camera_addition_pre][205] CAM_DIAG not enable
D/        ( 1053): [28.986010][camera_run]:[camera_handle_mgr_get_id][464] get id 0 count 0
D/        ( 1053): [28.986036][camera_run]:[camera_handle_mgr_set_id][510] set id 0 camera fd 0x4331 count 1
D/        ( 1053): [28.986048][camera_hdl]:[camera_handle_malloc][114] malloc id 0 fd 0x4331
D/        ( 1053): [28.988176][camera_mod]:[camera_module_lib_pre][214] sensor sc230ai: libsc230ai.so pre sucess
D/        ( 1053): [28.988256][sensor_lib]:[camera_sensor_config_check][252] sensor sc230ai config check
D/        ( 1053): [28.988276][sensor_lib]:[camera_sensor_ko_version_check][150] sensor sc230ai v1.0.0 ko v1.0
I/        ( 1053): [28.988295][camera_if]:[hbn_camera_create][245] create 0: camera sc230ai as fd 0x4331
I/        ( 1053): [28.989544][hbn_vpf_interface.c]:[vnode_alloc_magic_fd][224]cur_index 0
I/        ( 1053): [28.989571][hbn_vpf_interface.c]:[hbn_vnode_open][312]vnode create done !
I/        ( 1053): [28.989918][hbn_vpf_interface.c]:[hbn_vnode_open][319]vin0 ctx 0 vnode open
I/        ( 1053): [28.989941][hbn_vpf_interface.c]:[hbn_vnode_set_attr][438]start
I/        ( 1053): [28.989964][hbn_vpf_interface.c]:[vnode_size_check][407]vnode_size_check vin0 done, size(412-412) matched
I/        ( 1053): [28.990608][hbn_vpf_interface.c]:[vnode_size_check][407]vnode_size_check vin0 done, size(12-12) matched
I/        ( 1053): [28.991652][hbn_vpf_interface.c]:[hbn_vnode_set_ichn_attr][1023]vin0 ctx0 vnode done
I/        ( 1053): [28.991756][hbn_vpf_interface.c]:[vnode_size_check][407]vnode_size_check vin0 done, size(76-76) matched
I/        ( 1053): [28.992119][hbn_vpf_interface.c]:[hbn_vnode_set_ochn_attr][808]vin0 ctx0 vnode done
I/        ( 1053): [28.992220][hbn_vpf_interface.c]:[vnode_size_check][407]vnode_size_check vin0 done, size(368-368) matched
I/        ( 1053): [28.992512][hbn_vpf_interface.c]:[hbn_vnode_set_attr_ex][600]vin0 ctx0 vnode done
I/        ( 1053): [28.992577][hbn_vpf_interface.c]:[vnode_alloc_magic_fd][224]cur_index 1
I/        ( 1053): [28.992617][hbn_vpf_interface.c]:[hbn_vnode_open][312]vnode create done !
I/        ( 1053): [28.994740][hbn_vpf_interface.c]:[hbn_vnode_open][319]vs-isp0 ctx 0 vnode open
```

### 轮转日志文件

命令：

```bash
logcat -f /userdata/logfile.log -r 10 -n 5
```

功能：

将日志输出到指定路径文件，每隔 10KB 自动轮转日志文件，最多保留 5 个轮转文件。

打印输出：

```bash
root@buildroot:/userdata# cat logfile.log
I/        ( 1172): [982.596863][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx1 chn 0 bufferindex 1 done
I/        ( 1172): [982.607788][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx1 bufferindex 1 done
I/        ( 1172): [982.678711][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [982.678833][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 0 done
I/        ( 1172): [982.689087][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 0 done
I/        ( 1172): [982.696716][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [982.696838][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx1 chn 0 bufferindex 2 done
I/        ( 1172): [982.706726][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx1 bufferindex 2 done
I/        ( 1172): [982.778625][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [982.778687][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 1 done
I/        ( 1172): [982.788818][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 1 done
I/        ( 1172): [982.796631][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [982.796753][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx1 chn 0 bufferindex 0 done
I/        ( 1172): [982.807495][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx1 bufferindex 0 done
I/        ( 1172): [982.878235][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [982.878296][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 2 done
I/        ( 1172): [982.888489][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 2 done
I/        ( 1172): [982.896667][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [982.896729][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx1 chn 0 bufferindex 1 done
I/        ( 1172): [982.907349][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx1 bufferindex 1 done
E/TRACE   (  589): [982.973877]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingDisable: wrong HDR port ID 3
E/TRACE   (  589): [983.014832]CAMERIC-ISP-STITCHING-DRV: CamerIcIspStitchingDisable: wrong HDR port ID 4

root@buildroot:/userdata# cat logfile.log.1
D/        ( 1172): [980.151611][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae2 = 0x3f
D/        ( 1172): [980.152100][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae3 = 0x38
D/        ( 1172): [980.152588][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae4 = 0x28
D/        ( 1172): [980.153076][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae5 = 0x3f
D/        ( 1172): [980.153625][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae6 = 0x38
D/        ( 1172): [980.154114][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae7 = 0x28
D/        ( 1172): [980.154602][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae8 = 0x3f
D/        ( 1172): [980.155212][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5ae9 = 0x3c
D/        ( 1172): [980.155701][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5aea = 0x2c
D/        ( 1172): [980.156250][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5aeb = 0x3f
D/        ( 1172): [980.156738][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5aec = 0x3c
D/        ( 1172): [980.157227][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5aed = 0x2c
D/        ( 1172): [980.157715][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5af4 = 0x3f
D/        ( 1172): [980.158264][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5af5 = 0x38
D/        ( 1172): [980.158691][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5af6 = 0x28
D/        ( 1172): [980.159241][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5af7 = 0x3f
D/        ( 1172): [980.159729][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5af8 = 0x38
D/        ( 1172): [980.160339][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5af9 = 0x28
D/        ( 1172): [980.160767][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5afa = 0x3f
D/        ( 1172): [980.161255][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5afb = 0x3c
D/        ( 1172): [980.161804][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5afc = 0x2c
D/        ( 1172): [980.162292][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5afd = 0x3f
D/        ( 1172): [980.162842][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5afe = 0x3c
D/        ( 1172): [980.163330][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x5aff = 0x2c
D/        ( 1172): [980.163818][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x36e9 = 0x53
D/        ( 1172): [980.164368][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x37f9 = 0x53
I/        ( 1172): [980.165649][sc230ai]:sc230ai config success under 1 mode
I/        ( 1172): [980.265808][sc230ai]:sensor_dynamic_switch_fps sc230ai 10fps
I/        ( 1172): [980.267944][sc230ai]:sc230ai dynamic switch to 10fps success
I/        ( 1172): [980.268005][sc230ai]:enable userspace gain control and line control
D/        ( 1172): [980.268188][sensor_dev]:[camera_sensor_cdev_open][832] open /dev/sensor_ctrl v1.0 for sensor4 sc230ai as 100
I/        ( 1172): [980.268616][sc230ai]:enable userspace gain control and line control
I/        ( 1172): [980.268677][sensor_lib]:[camera_sensor_ctrl_func][1057] thread sen4_ctrl:sc230ai work en 0x3
I/        ( 1172): [980.268738][sensor_lib]:[camera_sensor_init][1534] sensor4 sc230ai init real done
I/        ( 1172): [980.268799][sensor_lib]:[camera_sensor_devop_func][1258] thread sen4:sc230ai work
W/        ( 1172): [980.268799][sensor_lib]:[camera_sensor_get_iparam][2266] sensor4 sc230ai 0x0@0.0ps state 4-NOT_SUPPORT
D/        ( 1172): [980.268799][sensor_lib]:[camera_sensor_set_sensor_info_to_driver][2316] sensor4 sc230ai set_intrinsic_param state 4-NOT_SUPPORT

I/        ( 1172): [981.779480][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 0 done
I/        ( 1172): [981.789795][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 0 done
I/        ( 1172): [981.797241][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [981.797302][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx1 chn 0 bufferindex 2 done
I/        ( 1172): [981.807739][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx1 bufferindex 2 done
I/        ( 1172): [981.878845][hbn_vpf_interface.c]:[hbn_vnode_getframe][1537]invalidate buf cnt 2
I/        ( 1172): [981.878906][hbn_vpf_interface.c]:[hbn_vnode_getframe][1540]vs-vse0 ctx0 chn 0 bufferindex 1 done
I/        ( 1172): [981.889343][hbn_vpf_interface.c]:[hbn_vnode_releaseframe][2106]vs-vse0 ctx0 bufferindex 1 done

root@buildroot:/userdata# cat logfile.log.2
D/        ( 1172): [979.865479][camera_i2c]:[camera_i2c_init][177] i2c2 mutex lock 0xffff90abb000 shmid 1
I/        ( 1172): [979.865479][camera_i2c]:[camera_i2c_init][191] i2c2 init as fd 99
D/        ( 1172): [979.865479][sensor_lib]:[camera_sensor_init][1438] sensor4 sc230ai init real doing
D/        ( 1172): [979.865540][sc230ai]:sc230ai gpio_num = 1
D/        ( 1172): [979.865540][sc230ai]:sc230ai gpio_pin[0] = 502
I/        ( 1172): [980.076843][sc230ai]:sc230ai in normal linear mode
I/        ( 1172): [980.076904][sc230ai]:bus_num = 2, sensor_addr = 0x30
D/        ( 1172): [980.077393][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x0103 = 0x01
D/        ( 1172): [980.077820][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x0100 = 0x00
D/        ( 1172): [980.078247][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x36e9 = 0x80
D/        ( 1172): [980.078735][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x37f9 = 0x80
D/        ( 1172): [980.079102][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x300a = 0x24
D/        ( 1172): [980.079529][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x3018 = 0x12
D/        ( 1172): [980.080017][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x3019 = 0x0e
D/        ( 1172): [980.080505][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x301f = 0x62
D/        ( 1172): [980.080872][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x3032 = 0xa0
D/        ( 1172): [980.081360][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x320c = 0x09
D/        ( 1172): [980.081848][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x320d = 0x60
D/        ( 1172): [980.082397][camera_reg]:[camera_reg_i2c_write_array][337] rega W16 2@0x30: 0x3225 = 0x30
....
```

### 清空日志缓冲区

命令：

```bash
logcat -c
```

功能：

清空整个日志缓冲区并退出。

打印输出：

```bash
root@buildroot:/userdata# logcat -c

  logcat test start !!!
root@buildroot:/userdata# logcat

  logcat test start !!!
--------- beginning of /dev/log_main
```

### 获取日志缓冲区大小

命令：

```bash
logcat -g
```

功能：

获取日志缓冲区的大小并退出。

打印输出：

```bash
root@buildroot:/userdata# logcat -g

  logcat test start !!!
/dev/log_main: ring buffer is 2048Kb (0Kb consumed), max entry is 5120b, max payload is 4076b
```

### 显示特定缓冲区的日志

有关 logcat 显示特定缓冲区 的示例说明，请参阅 **[logcat 接口](../system_component_development/Log_System_Introduction.html#span-id-use-by-logcat-log)** 章节。

命令：

```bash
logcat -b log_radio
```

功能：

显示 log_radio 缓冲区的日志。

```bash
logcat -b log_system
```

功能：

显示 log_system 缓冲区的日志。
