面向 React Native 开发的 VS Code 工具集,目前提供 Logcat Grep。
激活条件
仅当工作区包含以下文件之一时激活:
metro.config.js / metro.config.cjs / metro.config.mjs / metro.config.json
react-native.config.js / react-native.config.cjs / react-native.config.mjs
功能:Logcat Grep
在侧边栏 React Native Toolkit 面板中提供 Logcat Grep 视图,用于从 adb logcat 中筛选 React Native 相关日志。
服务控制
- 启动日志服务:运行
adb logcat *:S ReactNativeJS:V ReactNative:V
- 启动成功后开始监听输出
- 停止服务后自动清空所有输出项
输出项(Output)
- 点击右上角 New Output 新建输出项
- 默认名称为
Output 1、Output 2…(服务启动时编号从 1 重新开始)
- 新建后自动展开
- 双击输出项可重命名
- 右键菜单支持:Rename / Clear / Delete
- Fork:在当前输出项下创建子输出项
过滤项(Filter)
每个输出项下可添加多个过滤项:
- 过滤内容为空时视为满足
- 仅对日志前 100 个字符进行匹配以优化性能
- Regex / Exclude 支持开关
- 启用后在描述中显示
[Regex] / [Exclude]
- 单击过滤项:展示对应输出通道
- 双击过滤项:编辑过滤内容
过滤逻辑
对每一行日志进行深度优先遍历:
- 当前输出项的所有过滤项全部满足 → 输出到该 OutputChannel
- 若满足当前输出项,则继续遍历子输出项
- 任意过滤项不满足则跳过该输出项及其子项
需求
- 本地已安装
adb
- 已连接 Android 设备或模拟器
已知限制
命令(内部使用)
react-native-toolkit.logcat.launchService
react-native-toolkit.logcat.stopService
react-native-toolkit.logcat.newOutput
react-native-toolkit.logcat.renameOutput
react-native-toolkit.logcat.addFilter
react-native-toolkit.logcat.forkOutput
react-native-toolkit.logcat.clearOutput
react-native-toolkit.logcat.deleteOutput
react-native-toolkit.logcat.enableFilterRegex
react-native-toolkit.logcat.disableFilterRegex
react-native-toolkit.logcat.enableFilterExclude
react-native-toolkit.logcat.disableFilterExclude
react-native-toolkit.logcat.deleteFilter
react-native-toolkit.logcat.editFilter
| |