docs: update core and debug API docs
This commit is contained in:
@@ -1,29 +1,37 @@
|
||||
# Logger::RemoveSink
|
||||
|
||||
```cpp
|
||||
void RemoveSink(ILogSink* sink)
|
||||
void RemoveSink(ILogSink* sink);
|
||||
```
|
||||
|
||||
从日志系统移除指定的输出目标。通过指针查找并移除对应的 Sink,Logger 不再向该目标发送日志。
|
||||
从 Logger 移除指定的日志输出槽。
|
||||
|
||||
**参数:**
|
||||
- `sink` - 要移除的日志输出目标指针
|
||||
- `sink` - 指向要移除的 ILogSink 接口的指针
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(n),n 为注册的 Sink 数量
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Debug/Logger.h>
|
||||
#include "XCEngine/Debug/Logger.h"
|
||||
#include "XCEngine/Debug/ConsoleLogSink.h"
|
||||
|
||||
auto fileSink = std::make_unique<XCEngine::Debug::FileLogSink>("app.log");
|
||||
XCEngine::Debug::FileLogSink* rawPtr = fileSink.get();
|
||||
XCEngine::Debug::Logger::Get().AddSink(std::move(fileSink));
|
||||
// 稍后移除
|
||||
XCEngine::Debug::Logger::Get().RemoveSink(rawPtr);
|
||||
using namespace XCEngine::Debug;
|
||||
|
||||
Logger& logger = Logger::Get();
|
||||
auto consoleSink = std::make_unique<ConsoleLogSink>();
|
||||
logger.AddSink(consoleSink);
|
||||
|
||||
// 移除 Sink(传入原始指针)
|
||||
logger.RemoveSink(consoleSink.get());
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Logger 总览](logger.md) - 返回类总览
|
||||
- [ILogSink](../ilogsink/ilogsink.md) - 日志输出接口
|
||||
- [Logger](logger.md) - 返回类总览
|
||||
- [AddSink](addsink.md) - 添加日志输出槽
|
||||
|
||||
Reference in New Issue
Block a user