Files
XCSDD/docs/api/debug/logger/addsink.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

28 lines
836 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.
# Logger::AddSink
```cpp
void AddSink(std::unique_ptr<ILogSink> sink)
```
向日志系统添加一个输出目标Sink。Logger 持有 Sink 的所有权,传入的 `unique_ptr` 被移动到内部容器中。每次日志记录时,所有已注册的 Sink 的 `Log` 方法都会被调用。
**参数:**
- `sink` - 要添加的日志输出目标,使用 `std::unique_ptr` 包装
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Debug/Logger.h>
XCEngine::Debug::Logger::Get().Initialize();
XCEngine::Debug::Logger::Get().AddSink(std::make_unique<XCEngine::Debug::ConsoleLogSink>());
XCEngine::Debug::Logger::Get().AddSink(std::make_unique<XCEngine::Debug::FileLogSink>("app.log"));
```
## 相关文档
- [Logger 总览](logger.md) - 返回类总览
- [ILogSink](../ilogsink/ilogsink.md) - 日志输出接口