示例工程 06-dev-debug-logging
06-dev-debug-logging/demo-02-debug-env/README.md
# demo-02-debug-env
打印 `process.execArgv`、`ELECTRON_ENABLE_LOGGING`、`app.getPath("logs")` 与 `app.isPackaged`。
它不创建窗口,用来确认「调试开关到底有没有传给 Electron」。
## 运行
```bash
pnpm --filter @tutorial/06-dev-debug-logging-demo-02-debug-env start
ELECTRON_ENABLE_LOGGING=1 pnpm --filter @tutorial/06-dev-debug-logging-demo-02-debug-env start
```
主进程断点(直接调用 Electron 二进制,`--inspect` 必须在入口之前):
```bash
pnpm --filter @tutorial/06-dev-debug-logging-demo-02-debug-env build
pnpm --filter @tutorial/06-dev-debug-logging-demo-02-debug-env exec electron --inspect=9229 dist/main/index.js
```
## 验证
```bash
pnpm --filter @tutorial/06-dev-debug-logging-demo-02-debug-env smoke
# {"evt":"smoke","ok":true,"execArgv":[],"enableLogging":false,"logsPath":"...","isPackaged":false}
```
## 说明
`--inspect=9229` 打开主进程的 Node inspector;Chrome `chrome://inspect` 可以连上打断点。
`ELECTRON_ENABLE_LOGGING=1` 打开 Chromium 的日志输出(渲染进程的 console 与网络错误)。
## 已知限制
- 只在 macOS arm64 验证;`app.getPath("logs")` 在不同平台返回不同目录。