示例工程 06-dev-debug-logging

06-dev-debug-logging/app/README.md

markdown · 1.3 KB

# 06-dev-debug-logging / app

一个「调试与日志」面板:展示 JSON 行日志、日志文件路径/大小/轮转上限,以及
`process.execArgv`、`ELECTRON_ENABLE_LOGGING`、DevTools 状态。

## 运行

```bash
pnpm --filter @tutorial/06-dev-debug-logging-app start
pnpm --filter @tutorial/06-dev-debug-logging-app inspect   # 主进程 --inspect=9229
```

## 验证

```bash
pnpm --filter @tutorial/06-dev-debug-logging-app smoke
# {"evt":"smoke","ok":true,"logs":...,"logFile":".../main.log",...}
```

## 结构

- `main/`:JSON 行日志、文件轮转、IPC、smoke/shots
- `preload/`:暴露 `info/log/clear/devtools`
- `shared/`:通道与类型
- `src/`:三个页签(日志流 / 日志文件 / 调试开关)

## testid

| testid | 用途 |
| --- | --- |
| `app-title` | 页面标题 |
| `tab-stream` / `tab-file` / `tab-debug` | 三个页签 |
| `log-table` | JSON 行日志表 |
| `log-button` / `clear-button` | 写日志 / 清空 |
| `file-table` / `info-log-file` / `info-log-size` | 日志文件 |
| `debug-table` / `info-exec-argv` / `info-enable-logging` / `info-devtools` | 调试开关 |
| `devtools-button` | 开关 DevTools |

## 已知限制

- 只在 macOS arm64 验证;日志目录随平台变化。
- 示例只做单文件轮转(`main.log` → `main.log.1`),生产应使用按天/按大小的滚动策略。