Files
quyun-v2/docs/plan.md
2026-01-26 18:20:03 +08:00

79 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Implementation Plan: Improve Error Logging
**Branch**: `main` | **Date**: 2026-01-26 | **Spec**: N/A
**Input**: 完善应用错误记录,输出更精确的错误定位信息。
**Note**: 本计划遵循 `docs/templates/plan-template.md`
## Summary
定位当前错误记录入口与结构,补充关键上下文信息(请求 ID、路径、用户/租户 ID、处理器名称、错误链并统一输出格式方便快速定位问题。
## Technical Context
**Language/Version**: Go 1.22
**Primary Dependencies**: Fiber, logrus, errorx
**Storage**: N/A
**Testing**: go test / 运行时日志
**Target Platform**: local/staging
**Project Type**: Web application
**Performance Goals**: N/A
**Constraints**: 不修改生成文件
**Scale/Scope**: 日志格式与错误处理
## Constitution Check
- 遵循 `backend/llm.txt`
- 只改非生成文件
## Project Structure
```text
backend/app/errorx/
backend/providers/http/
backend/app/middlewares/
```
## Plan Phases
### Phase 1: 现状定位
- 追踪错误记录入口与结构errorx + middleware + http provider
### Phase 2: 日志增强
- 补充 request-id、path、method、tenant/user、handler、error chain。
- 确认错误等级与格式一致。
### Phase 3: 验证
- 使用典型 4xx/5xx 请求验证日志输出。
## Tasks
**Format**: `[ID] [P?] [Story] Description`
### Phase 1
- [x] T001 [US0] 定位错误记录入口与字段
### Phase 2
- [x] T010 [US1] 增强错误日志上下文
- [x] T011 [US1] 统一格式与等级
### Phase 3
- [x] T020 [US2] 验证输出与文档说明
## Dependencies
- Phase 1 → Phase 2 → Phase 3
## Acceptance Criteria
- 日志可直接定位请求来源与错误链。
- 关键字段完整request-id、path、tenant/user、handler
## Risks
- 日志字段增加影响性能或泄露敏感信息。
## Complexity Tracking
无。