21 个版本
0.4.7 | 2024年8月1日 |
---|---|
0.4.6 | 2023年2月13日 |
0.4.5 | 2022年5月4日 |
0.4.3 | 2022年1月13日 |
0.2.7 | 2017年7月8日 |
在 开发工具 中排名 164
每月下载量 115
380KB
3K SLoC
rogcat
...是一个 adb logcat
包装器。Android 调试桥接器(adb
)是开发期间与Android设备交互的默认方式。在 adb
的 logcat
子命令允许访问Android的内部日志缓冲区。rogcat
尝试以方便的方式提供这些日志的访问,包括后处理功能。主要功能可能是绘制和重新格式化的视图。 rogcat
可以从以下内容读取日志:
- 正在运行的
adb logcat
(默认) - 自定义命令(
stdout
,stderr
) - 一个或多个文件
stdin
- 连接到TCP端口
- SocketCAN CAN设备(仅限Linux)
rogcat
运行过程中的处理步骤包括解析输入流并应用过滤器(如果提供)。rogcat
随带一套实现输入和输出格式
csv
: 逗号分隔值raw
: 记录(行)按捕获方式html
: 一个静态的单页HTML,带有静态表格。此选项不能用作输入格式。页面布局需要一些爱...human
: 一个友好的彩色列格式。请参阅截图json
: 单行JSON
除了 human
和 html
格式之外,rogcat
的输出可以被 rogcat
解析。
示例
以下示例显示了 rogcat
的功能子集。 请阅读 --help
!
实时
从连接的设备捕获日志并无条件显示。除非另外配置,否则 Rogcat
运行 adb logcat
-b main -b events -b crash -b kernel
rogcat
将捕获的日志写入 testrun.log
rogcat-o testrun.log
通过启动新文件每1000行来将捕获的日志写入文件 ./trace/testrun-XXX.log
。如果 ./trace
不存在,则创建它
rogcat
-o ./trace/testrun.log -n 1000 或 rogcat
-o ./trace/testrun.log -n 1k
stdin
处理 command
的 stdout
和 stderr
rogcat command
或 command | rogcat -
过滤器
显示来自 adb logcat
的日志,并在标签匹配 ^ABC.*
、不匹配 X
以及消息包含 pattern
的记录上进行过滤
rogcat-t"^ADB.*" -t \!X-m pattern
按字母数字顺序读取所有匹配 trace*
的文件,并将匹配 hmmm
的行转储到 /tmp/filtered
rogcat-i trace* -m hmmm-o/tmp/filtered
在帮助文本中检查 --message
和 --highlight
选项。
TCP
要使用 TCP 连接到某个主机,运行类似以下命令
rogcat tcp://traceserver:1234
SocketCAN
要打开 SocketCAN 设备并读取帧,运行
rogcat can://can0
SocketCAN 是 Linux 独有的。
错误报告
捕获 Android
错误报告。此功能仅适用于 7 版本之前的 Android
rogcat bugreport
捕获 Android
错误报告并将其(压缩后)写入 bugreport.zip
rogcat bugreport-z bugreport.zip
日志
将消息 "some text" 写入设备日志缓冲区(例如,手动测试期间的注释)
rogcat log"some text"
设置级别和标签或从 stdin
读取
rogcat-log
Add log message(s) log buffer
USAGE:
rogcat log [OPTIONS] [MESSAGE]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-l, --level <LEVEL> Log on level [values: trace, debug, info, warn, error, fatal, assert, T, D, I, W, E, F, A]
-t, --tag <TAG> Log tag
ARGS:
<MESSAGE> Log message. Pass "-" to capture from stdin'
Fuchsia
rogcat
可用于读取 Fuchsia
设备的日志。使用 --fx
开关来运行 ffx
而不是 adb logcat
。默认的 ffx
命令是 ffx log
--no-color --severity debug。
当然,您可以使用类似 ffx log
--no-color | rogcat - 或 rogcat
"ffx log --no-color" 的方式手动调用 ffx
。
安装
构建 rogcat
需要 Rust 2018 版本
cargo install --path .
或从 GitHub 页面获取 二进制发布版 之一。
在基于 Debian 的系统上,构建需要 libudev-dev
(及其依赖项)。
配置
当 rogcat
没有提供任何命令时,它默认运行 adb logcat -b all
。以下选项可以在 rogcat
的配置文件 config.toml
中覆盖。配置文件的存储位置取决于平台。
- MacOS:
$HOME/Library/Preferences/rogcat/config.toml
- Linux:
$HOME/.config/rogcat/config.toml
- Windows:
%HOME%/AppData/Roaming/rogcat/config.toml
重启
默认情况下,rogcat
在 adb logcat
退出时会重启。这种行为是故意的,以便在设备电源循环或断开/重新连接时使 rogcat
重新连接。由于 Windows 7
的一个错误,rogcat
无法重启 adb
。将 restart = false
放入上述配置文件中,使 rogcat
在 adb
退出时退出。
缓冲区
rogcat
的默认行为是转储所有 logcat
缓冲区。这可以通过在 rogcat
配置文件中选择特定缓冲区来覆盖。例如
buffer = ["main", "events"]
终端设置
可以通过配置文件调整 human
格式的某些参数
terminal_bright_colors = false
terminal_color = never
terminal_hide_timestamp = true
terminal_process_width_max = 16
terminal_thread_width_max = 16
terminal_no_dimm = true
terminal_show_date = false
terminal_tag_width = 20
配置文件
如果存在,rogcat
可选地读取一个(toml
格式)配置文件。此配置可能包括跟踪配置文件('-p')和设置。配置文件中的可能选项是命令行选项的子集。配置文件从环境变量 ROGCAT_PROFILES
或根据您的操作系统设置的固定路径读取。
- MacOS:
$HOME/Library/Preferences/rogcat/profiles.toml
- Linux:
$HOME/.config/rogcat/profiles.toml
- Windows:
%HOME%/AppData/Roaming/rogcat/profiles.toml
环境变量覆盖默认路径。请参阅 rogcat profiles --help
或 rogcat profiles --examples
。
示例
[profile.a]
comment = "Messages starting with A or a"
message_ignore_case = ["^A.*"]
[profile.B]
comment = "Messages starting with B"
message = ["^B.*"]
[profile.ABC]
extends = ["A", "B"]
comment = "Profiles A, B plus the following filter (^C.*)"
message = ["^C.*"]
[profile."Comments are optional"]
tag = ["rogcat"]
[profile.complex]
comment = "Profiles can be complex. This one is probably very useless."
highlight = ["blah"]
message = ["^R.*", "!^A.*", "!^A.*"]
tag = ["b*", "!adb"]
[profile."W hitespace"]
comment = "Profile names can contain whitespaces. Quote on command line..."
[profile.rogcat]
comment = "Only tag \"rogcat\""
tag = ["^rogcat$"]
[profile.default]
comment = "Default profile"
要检查您的设置,请运行 rogcat profiles --list
并通过传递 -p/--profile
选项来选择一个配置文件进行运行。
您可以创建一个名为 default
的特殊配置文件,如果没有在命令行上选择其他配置文件,将使用此配置文件。
用法
rogcat 0.4.3-alpha.0
Felix Obenhuber <[email protected]>
A 'adb logcat' wrapper and log processor. Your config directory is "/Users/felix/Library/Preferences/rogcat".
USAGE:
rogcat [FLAGS] [OPTIONS] [COMMAND] [SUBCOMMAND]
FLAGS:
-d, --dump Dump the log and then exit (don't block)
--help Prints help information
--hide-timestamp Hide timestamp in terminal output
--no-dimm Use white as dimm color
--overwrite Overwrite output file if present
--restart Restart command on exit
--show-date Show month and day in terminal output
-s, --skip Skip records on a command restart until the last received last record is received again. Use
with caution!
-V, --version Prints version information
OPTIONS:
-b, --buffer <buffer>...
Select specific logd buffers. Defaults to main, events, kernel and crash
--color <color> Terminal coloring option [possible values: auto, always, never]
-a, --filename-format <filename_format>
Select a format for output file names. By passing 'single' the filename provided with the '-o' option is
used (default).'enumerate' appends a file sequence number after the filename passed with '-o' option
whenever a new file is created (see 'records-per-file' option). 'date' will prefix the output filename with
the current local date when a new file is created [possible values: single, enumerate, date]
-f, --format <format>
Output format. Defaults to human on stdout and raw on file output [possible values: csv, html, human, json,
raw]
-H, --head <head> Read n records and exit
-h, --highlight <highlight>...
Highlight messages that match this pattern in RE2. The prefix '!' inverts the match
-i, --input <input>...
Read from file instead of command. Use 'serial://COM0@115200,8N1 or similiar for reading a serial port
-l, --level <level>
Minimum level [possible values: trace, debug, info, warn, error, fatal, assert, T, D, I, W, E, F, A]
-m, --message <message>... Message filters in RE2. The prefix '!' inverts the match
-M, --Message <message-ignore-case>... Same as -m/--message but case insensitive
-o, --output <output> Write output to file
-p, --profile <profile> Select profile
-P, --profiles-path <profiles_path> Manually specify profile file (overrules ROGCAT_PROFILES)
-n, --records-per-file <records_per_file> Write n records per file. Use k, M, G suffixes or a plain number
-r, --regex <regex_filter>... Regex filter on tag, pid, thread and message.
-t, --tag <tag>... Tag filters in RE2. The prefix '!' inverts the match
-T, --Tag <tag-ignore-case>... Same as -t/--tag but case insensitive
--tail <tail> Dump only the most recent <COUNT> lines (implies --dump)
ARGS:
<COMMAND> Optional command to run and capture stdout and stdderr from. Pass "-" to d capture stdin'. If
omitted, rogcat will run "adb logcat -b all" and restarts this commmand if 'adb' terminates
SUBCOMMANDS:
bugreport Capture bugreport. This is only works for Android versions < 7.
clear Clear logd buffers
completions Generates completion scripts
devices List available devices
help Prints this message or the help of the given subcommand(s)
log Add log message(s) log buffer
许可
有关详细信息,请参阅 LICENSE
。
依赖关系
~21–32MB
~508K SLoC