mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
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:
@@ -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。
|
||||
|
||||
Reference in New Issue
Block a user