feat(logging): add safe hot-reloadable rotating file sink (#116)

This commit is contained in:
Jason Xu committed 2026-11-30 04:40:43 +08:00
1 parent 9b44a031ca
commit 30d6c08a9c
15 files changed
+338 -19

No files matched your search

+5
View File
@@ -76,10 +76,15 @@ Common management defaults:
| `webui.listen` | `0.0.0.0:8081`. |
| `logging.level` | `info`; supports `debug`, `info`, `warn`, and `error`. |
| `logging.ring_size` | `2000`; range 100–50,000. |
| `logging.file_path` | Empty disables file logging; relative paths resolve beside the configuration file. Hot-applied. |
| `logging.dump_request_bodies` | `false`; also requires debug logging, capped at 64 KiB per prepared body. |
| `models.active_probes` | `false`; real traffic supplies default availability observations. |
| `keys_direct` | `false`; pins unbound manual Zen/Go keys to dual-stack direct egress; explicit bindings win. Anonymous/OAuth routing is unchanged. |
File logging mirrors the same redacted JSON records sent to stdout. The UI accepts a file path; clearing it disables the sink. Older API clients that omit `logging.file_path` retain the current value, while an explicit empty string disables it. Saving and disk reload apply path changes without restarting. A failed open or retarget reports `log_file_open_failed` and keeps the previous sink; write/rotation failures report `log_file_error` through the independent console/in-memory handler, not recursively through the file sink.
Rotation occurs at record boundaries around 32 MiB, retaining `<path>.1` only; an oversized record is not split. Parent directories are created with mode `0700` and files use `0600` where supported. Configure Windows ACLs separately. File/backup targets cannot overwrite the configuration, its backup, configured proxy file, or known runtime data files. Symlink/non-regular file targets are rejected. Request-body dumps still contain conversation content; treat disk logs as private. Writes are not individually synced, so operating-system/power failure durability is not guaranteed.
## Go OAuth and Zen PAYG OAuth
Models and quota contains two separate panels. Go uses subscription routes; Zen uses Console workspace pay-as-you-go billing (PAYG), and **inference consumes that workspace's credits**. Signing in to Go does not establish Zen permissions or balance, or automatically connect PAYG.
+5
View File
@@ -76,9 +76,14 @@ Key、代理、上游、超时、模型、偏好、reasoning 和日志设置热
| `webui.listen` | `0.0.0.0:8081`。 |
| `logging.level` | `info`;支持 `debug`、`info`、`warn`、`error`。 |
| `logging.ring_size` | `2000`;范围 100–50,000。 |
| `logging.file_path` | 留空关闭落盘;相对路径以配置文件所在目录为基准,支持热更新。 |
| `logging.dump_request_bodies` | `false`;还需 debug 才输出,每个准备好的请求体最多 64 KiB。 |
| `models.active_probes` | `false`;真实流量提供默认可用性观察。 |
日志文件接收与 stdout 相同的已脱敏 JSON 记录。页面可填写路径,清空即关闭;旧 API 客户端省略 `logging.file_path` 时保留当前值,明确传空字符串则关闭。保存与磁盘重载无需重启。打开或切换失败报告 `log_file_open_failed` 并保留原有 sink;写入或轮转失败通过独立的控制台/内存 handler 报告 `log_file_error`,不会递归写入故障文件。
在约 32 MiB 的记录边界轮转,只保留 `<路径>.1`,不会拆开单条超大记录。新目录使用 `0700`、文件使用 `0600`(限平台支持),Windows 需单独配置 ACL。活动文件及备份不能覆盖配置、配置备份、已配置的代理文件与已知运行数据文件;拒绝符号链接和非普通文件目标。请求体转储仍含对话内容,磁盘日志应视为私密数据。每次追加不单独执行同步,不保证系统或断电故障下的持久性。
## Go OAuth 与 Zen PAYG OAuth
「模型与额度」有两个独立面板。Go 使用订阅路由;Zen 使用 Console 工作区按量计费(PAYG),**推理会消耗该工作区 credits**。Go 登录不代表获得 Zen 权限或余额,不会自动连接 PAYG。