Files
XCEngine/docs/api/debug/logger/log.md

43 lines
1.0 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.
# Logger::Log
```cpp
void Log(LogLevel level, LogCategory category,
const Containers::String& message, const char* file = nullptr,
int32_t line = 0, const char* function = nullptr);
```
通用日志记录方法,支持完整的日志信息包括源码位置。
**参数:**
- `level` - 日志级别Verbose、Debug、Info、Warning、Error、Fatal
- `category` - 日志分类General、Rendering、Physics 等)
- `message` - 日志消息内容
- `file` - 源码文件名(可选)
- `line` - 源码行号(可选)
- `function` - 函数名(可选)
**返回:**
**线程安全:**
**示例:**
```cpp
#include "XCEngine/Debug/Logger.h"
using namespace XCEngine::Debug;
Logger& logger = Logger::Get();
// 完整调用(包含源码位置)
logger.Log(LogLevel::Error, LogCategory::Network,
"Connection timeout", __FILE__, __LINE__, __FUNCTION__);
// 简化调用
logger.Log(LogLevel::Info, LogCategory::General, "Simple message");
```
## 相关文档
- [Logger](logger.md) - 返回类总览