feat: 添加配置加载和日志配置支持

- 新增 LogConfig 结构体,支持 9 个日志配置字段(level, encoding, output_stdout, file_path, max_size, max_backups, max_age, compress, gorm_level)

- Config 结构体新增 Log 字段,支持 YAML 解析

- output_stdout 使用 *bool 指针类型,nil 默认为 true

- 更新 config.example.yaml 添加完整 log 配置段

- 新增 TDD 测试:日志配置解析、向后兼容、字段完整性

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
dailz
2026-04-10 08:39:09 +08:00
parent 246c19c052
commit 7550e75945
3 changed files with 323 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
server_port: "8080"
slurm_api_url: "http://localhost:6820"
slurm_user_name: "root"
slurm_jwt_key_path: "/etc/slurm/jwt_hs256.key"
mysql_dsn: "root:@tcp(127.0.0.1:3306)/hpc_platform?parseTime=true"
log:
level: "info" # debug, info, warn, error
encoding: "json" # json, console
output_stdout: true # 是否输出日志到终端
file_path: "" # 日志文件路径,留空则不写文件
max_size: 100 # max MB per log file
max_backups: 5 # number of old log files to retain
max_age: 30 # days to retain old log files
compress: true # gzip rotated log files
gorm_level: "warn" # GORM SQL log level: silent, error, warn, info