lolly/internal/logging/AGENTS.md
xfy 179aacac04 docs: 添加模块上下文文档 (AGENTS.md)
为各模块添加上下文文档,帮助 AI 助手理解代码结构:
- AGENTS.md: 项目根目录上下文
- docs/AGENTS.md: 文档目录说明
- internal/AGENTS.md: 内部包结构概览
- 各子模块 AGENTS.md: 模块特定上下文和约定

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 16:25:51 +08:00

38 lines
1.1 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.

<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-04-02 | Updated: 2026-04-02 -->
# logging
## Purpose
日志模块,使用 zerolog 提供零分配的 JSON 日志输出和访问日志记录。
## Key Files
| File | Description |
|------|-------------|
| `logging.go` | 日志初始化和访问日志记录Init()、LogAccess()、parseLevel() |
## For AI Agents
### Working In This Directory
- 使用 zerolog 的链式 API 记录日志
- `Init(level, pretty)` 初始化pretty=true 使用 ConsoleWriter开发模式
- `LogAccess()` 记录请求日志method、path、status、size、duration、remote_addr
- 日志级别debug、info、warn、error默认 info
### Testing Requirements
- 运行测试:`go test ./internal/logging/...`
- 测试日志级别解析和格式化输出
### Common Patterns
- 全局日志实例 `log`,通过 `Init()` 初始化
- zerolog 的零分配设计适合高并发场景
- 生产模式输出 JSON 格式,便于日志采集系统解析
## Dependencies
### External
- `github.com/rs/zerolog` - 零分配 JSON 日志库
- `github.com/valyala/fasthttp` - 获取请求信息
<!-- MANUAL: -->