refactor(log): migrate from zerolog to structured slog with bridge

- Replace direct zerolog usage with standard library `log/slog` in business code
- Add `internal/logging` package with zerolog bridge handler for structured output
- Create `internal/jsoncodec` package to centralize JSON encoding/decoding using Sonic
- Update all services and main entry point to use new logging interface
- Maintain backward compatibility with existing zerolog console output
- Remove custom logger setup in favor of structured logging bridge
This commit is contained in:
zenfun
2025-12-13 16:50:56 +08:00
parent 305f2ebf18
commit 89cb74ba6e
7 changed files with 248 additions and 48 deletions

View File

@@ -96,9 +96,14 @@ cd ez-api
## 日志
- 使用 [zerolog](https://github.com/rs/zerolog) 输出结构化日志,默认 ConsoleWriter
- 业务代码统一使用标准库 `log/slog``logger.Info("msg", "k", v)` 风格)
- 输出后端仍为 [zerolog](https://github.com/rs/zerolog)(通过 `internal/logging` 的 slog handler bridge默认 ConsoleWriter。
- 通过 `EZ_LOG_LEVEL` 控制控制平面的日志等级,配合异步 DB 写入LogWriter一起使用。
## JSON
- 项目内 JSON 编解码统一走 `ez-api/internal/jsoncodec`(内部使用 Sonic
## 设计决策
- **异步日志**: 日志不会立即写入 DB。它们被缓冲在内存中并分批刷新以减少 DB IOPS。