Files
XCEngine/docs/api/XCEngine/Debug/ILogSink/Log.md

52 lines
936 B
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.
# ILogSink::Log
输出一条已经构造完成的日志记录。
```cpp
virtual void Log(const LogEntry& entry) = 0;
```
## 行为说明
这是纯虚接口。`Logger` 负责创建 `LogEntry`、做全局过滤和序列化分发sink 实现只需要关心如何消费这条记录。
常见实现策略包括:
- 控制台打印
- 文件写入
- 编辑器面板缓存
- 远程调试通道转发
## 参数
- `entry` - 已构造完成的日志记录。
## 返回值
- 无。
## 线程语义
- 由具体实现决定。
- 在当前引擎实现中,通过 `Logger` 分发时通常是串行调用。
## 示例
```cpp
class CountingSink final : public XCEngine::Debug::ILogSink {
public:
void Log(const XCEngine::Debug::LogEntry& entry) override {
++count;
}
void Flush() override {}
int count = 0;
};
```
## 相关文档
- [返回类型总览](ILogSink.md)
- [Logger::AddSink](../Logger/AddSink.md)