fix: 修复Logger模块Bug\n- Logger.h: m_categoryEnabled数组初始化错误,只有第一个元素为true\n- FileLogSink: 添加文件关闭时自动重开逻辑\n- main.cpp: 集成Engine Logger
This commit is contained in:
@@ -42,7 +42,7 @@ private:
|
|||||||
|
|
||||||
std::vector<std::unique_ptr<ILogSink>> m_sinks;
|
std::vector<std::unique_ptr<ILogSink>> m_sinks;
|
||||||
LogLevel m_minimumLevel = LogLevel::Verbose;
|
LogLevel m_minimumLevel = LogLevel::Verbose;
|
||||||
bool m_categoryEnabled[11] = { true };
|
bool m_categoryEnabled[11] = { true, true, true, true, true, true, true, true, true, true, true };
|
||||||
Threading::Mutex m_mutex;
|
Threading::Mutex m_mutex;
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ FileLogSink::~FileLogSink() {
|
|||||||
|
|
||||||
void FileLogSink::Log(const LogEntry& entry) {
|
void FileLogSink::Log(const LogEntry& entry) {
|
||||||
if (!m_writer.IsOpen()) {
|
if (!m_writer.IsOpen()) {
|
||||||
return;
|
// File not open, try to reopen
|
||||||
|
m_writer.Open(m_filePath.CStr(), true);
|
||||||
|
if (!m_writer.IsOpen()) {
|
||||||
|
// Still not open - output to debug
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char timestamp[32];
|
char timestamp[32];
|
||||||
|
|||||||
@@ -970,7 +970,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
|
|
||||||
Logger::Get().AddSink(std::make_unique<FileLogSink>("D3D12_engine_log.txt"));
|
Logger::Get().AddSink(std::make_unique<FileLogSink>("D3D12_engine_log.txt"));
|
||||||
Logger::Get().SetMinimumLevel(LogLevel::Debug);
|
Logger::Get().SetMinimumLevel(LogLevel::Debug);
|
||||||
Logger::Get().Info(LogCategory::General, "Engine Logger initialized");
|
|
||||||
|
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
freopen("CONOUT$", "w", stdout);
|
freopen("CONOUT$", "w", stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user