Expand description
错误日志记录 (Error Log)
统一将 HTTP 错误响应和业务异常写入 logs/error.log 文件,
同时在 dev 环境下写入内存环形缓冲供控制台查询。
§两条写入路径
| 函数 | 触发场景 | 格式 |
|---|---|---|
log_http_error | HTTP 4xx/5xx 响应 | [ts] HTTP METHOD /path status=N member=N body=... |
log_app_error | 业务 AppError | [ts] APP kind=xxx code=N msg=... detail=... |
§初始化
在 AppState::new() 中调用 init() 设置日志文件路径,
未初始化时回退到 {CARGO_MANIFEST_DIR}/logs/error.log。
Functions§
- init
- 初始化错误日志路径
- log_
app_ error - 记录业务层 AppError
- log_
http_ error - 记录 HTTP 4xx/5xx 响应