mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(log): replace standard logger with zerolog
- Integrate `rs/zerolog` for structured and leveled logging - Add `EZ_LOG_LEVEL` environment variable support (default: info) - Configure console output with timestamps and service fields - Migrate `main.go` and `LogWriter` to use the new logger instance - Update README with logging configuration and design details
This commit is contained in:
@@ -39,6 +39,7 @@ EZ-API 是"大脑"。它管理着事实的来源 (Source of Truth)。
|
||||
| `EZ_REDIS_ADDR` | `localhost:6379` | Redis 地址。 |
|
||||
| `EZ_LOG_QUEUE` | `10000` | 日志缓冲通道的容量。 |
|
||||
| `EZ_LOG_BATCH_SIZE` | `10` | 单次 DB 事务写入的日志数量。 |
|
||||
| `EZ_LOG_LEVEL` | `info` | 日志级别,支持 `debug`、`info`、`warn`、`error`。 |
|
||||
|
||||
## 运行方式
|
||||
|
||||
@@ -75,6 +76,11 @@ cd ez-api
|
||||
|
||||
脚本会拉起 `docker-compose.integration.yml` 中的服务,运行带 `integration` tag 的 Go 测试,并在完成后清理容器和卷。
|
||||
|
||||
## 日志
|
||||
|
||||
- 使用 [zerolog](https://github.com/rs/zerolog) 输出结构化日志,默认 ConsoleWriter。
|
||||
- 通过 `EZ_LOG_LEVEL` 控制控制平面的日志等级,配合异步 DB 写入(LogWriter)一起使用。
|
||||
|
||||
## 设计决策
|
||||
|
||||
- **异步日志**: 日志不会立即写入 DB。它们被缓冲在内存中,并分批刷新,以减少 DB IOPS。
|
||||
|
||||
Reference in New Issue
Block a user