refactor: add shared logging crate

This commit is contained in:
2026-04-21 12:08:42 +08:00
parent 07fcbe4a2f
commit 854a7a2568
18 changed files with 280 additions and 68 deletions

View File

@@ -0,0 +1,32 @@
# shared-logging 共享日志 crate 占位说明
日期:`2026-04-21`
## 1. crate 职责
`shared-logging` 是 Rust 工作区统一日志基础设施 crate后续负责
1. 统一 `tracing subscriber` 初始化入口
2. 统一日志过滤器解析逻辑
3. 统一当前阶段日志输出风格
4.`api-server`、后续 `spacetime-module`、测试支撑与独立入口提供可复用日志初始化能力
## 2. 当前阶段说明
当前阶段已完成最小落地:
1. 提供 `resolve_env_filter(...)`
2. 提供 `init_tracing(...)`
3.`api-server` 的日志初始化逻辑迁出为共享 crate
后续与本 crate 直接相关的任务包括:
1. 根据环境扩展日志输出格式
2. 补充测试入口、worker 入口与其它主工程 crate 的统一接入
3. 视需要补充 JSON 输出、链路追踪或远端采集适配
## 3. 边界约束
1. `shared-logging` 只承接日志初始化与基础设施,不承接 HTTP 业务语义。
2. `TraceLayer`、request id、响应头、错误 envelope 等 HTTP 逻辑继续留在 `api-server`
3. 不允许把业务埋点、审计事件或供应商日志适配塞进本 crate。