refactor: reorganize docs into plan/ and add skills/
This commit is contained in:
47
docs/api/debug/debug-filelogsink.md
Normal file
47
docs/api/debug/debug-filelogsink.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# FileLogSink
|
||||
|
||||
**命名空间**: `XCEngine::Debug`
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**描述**: 文件日志输出槽,将日志持久化到磁盘文件。
|
||||
|
||||
## 概述
|
||||
|
||||
`FileLogSink` 是 `ILogSink` 的文件实现。它使用 `FileWriter` 将日志追加写入文件,支持自动换行和缓冲区刷新。
|
||||
|
||||
## 公共方法
|
||||
|
||||
### 构造/析构
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `FileLogSink(const Containers::String& filePath)` | 构造函数,指定文件路径 |
|
||||
| `~FileLogSink()` | 析构函数 |
|
||||
|
||||
### ILogSink 实现
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `void Log(const LogEntry& entry) override` | 将日志追加写入文件 |
|
||||
| `void Flush() override` | 刷新文件缓冲区 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// 创建文件日志输出
|
||||
auto fileSink = std::make_unique<FileLogSink>("logs/app.log");
|
||||
|
||||
// 添加到 Logger
|
||||
Logger::Get().AddSink(std::move(fileSink));
|
||||
|
||||
// 日志将自动写入文件
|
||||
XE_LOG(LogCategory::General, LogLevel::Info, "Game started");
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Logger](./debug-logger.md) - 日志记录器
|
||||
- [ILogSink](./debug-ilogsink.md) - 日志输出接口
|
||||
- [ConsoleLogSink](./debug-consolelogsink.md) - 控制台输出
|
||||
- [Core/FileWriter](../core/core-filewriter.md) - 文件写入工具
|
||||
Reference in New Issue
Block a user