Refactor logging to use slog package across the application

- Replaced standard log package with log/slog in httpclient, nginx manager, sync service, updater, and other components for structured logging.
- Introduced environment variable `LOG_LEVEL` to control logging levels (debug, info, warn, error).
- Updated documentation to reflect changes in logging configuration and requirements.
- Added a new logging setup function in the ats_agent internal package to initialize the slog logger.
This commit is contained in:
ryan
2026-03-13 14:53:51 +08:00
parent 06d4831d55
commit aeb7118b30
17 changed files with 321 additions and 209 deletions
+16 -3
View File
@@ -188,9 +188,22 @@ Agent 当前支持两类启动配置:
1. 命令行参数
2. `agent.json` 配置文件
当前 Agent **没有额外环境变量作为正式配置入口**,启动行为主要由 `-config` 参数和配置文件字段决定。
### 2.1 Agent 命令行参数
当前 Agent 仅支持少量环境变量用于日志输出控制;核心启动行为仍由 `-config` 参数和配置文件字段决定。
### 2.1.1 Agent 环境变量
支持的环境变量:
| 环境变量 | 作用 | 默认值 | 示例 |
| --- | --- | --- | --- |
| `LOG_LEVEL` | 指定 Agent 的 `slog` 日志等级;支持 `debug`/`info`/`warn`/`error`(`warning` 兼容为 `warn`) | `info` | `LOG_LEVEL=debug` |
说明:
* `LOG_LEVEL` 只影响 Agent 本地日志输出,不改变心跳、同步或配置行为
* 未设置或设置为不支持的值时,将回退为 `info`
### 2.1 Agent 命令行参数
启动示例: