feat(logging): add configurable logging with file output support

Introduce --log-level and --log-file CLI arguments.
Add execution time tracking and detailed logs across all modules.
This commit is contained in:
2026-04-02 10:40:39 +08:00
parent eef3464257
commit 0bdebd5368
8 changed files with 248 additions and 15 deletions

View File

@@ -39,6 +39,8 @@ GEMINI_MODEL=gemini-2.5-flash
- `--model`: 临时覆盖 `.env` 里的模型名
- `--skip-analysis`: 只做复制、清理和剪枝,不调用 Gemini
- `--force`: 允许覆盖已有输出目录
- `--log-level`: 日志级别,支持 `DEBUG` / `INFO` / `WARNING` / `ERROR` / `CRITICAL`
- `--log-file`: 把完整日志同时写入文件,便于回溯扫描、剪枝和 Gemini 分析过程
## 输出内容
@@ -60,3 +62,24 @@ GEMINI_MODEL=gemini-2.5-flash
- 只解析能静态识别出来的 `Invoke Workflow` / `Invoke VBA` 文件路径。
- 对动态拼接路径会记录 warning但不会猜测。
- `Invoke VBA` 默认识别常见文本型 VBA 文件扩展名:`.txt``.bas``.vb``.vbs``.vba``.cls``.frm`
## 日志说明
运行时默认输出 `INFO` 级别日志,会记录:
- CLI 启动参数、配置加载结果、是否启用 Gemini
- 依赖扫描开始/结束、文件数量、warning 数量
- 复制、清理 Comment Out、二次扫描、剪枝、生成文档等阶段摘要
如果需要看更细的文件级排查信息,直接把日志级别调到 `DEBUG`
```bash
./.venv/bin/python -m uipath_explainator \
/path/to/uipath-project \
--output-dir workspace/project-bundle \
--log-level DEBUG \
--log-file workspace/project-bundle/run.log \
--force
```
`DEBUG` 会额外记录每个文件的复制、依赖解析、路径解析、剪枝、分析文档写出等细节。