fix: 修复Logger模块Bug\n- Logger.h: m_categoryEnabled数组初始化错误,只有第一个元素为true\n- FileLogSink: 添加文件关闭时自动重开逻辑\n- main.cpp: 集成Engine Logger

This commit is contained in:
2026-03-15 14:55:23 +08:00
parent c6d7ef4c39
commit 3767f3a6c5
3 changed files with 7 additions and 3 deletions

View File

@@ -42,7 +42,7 @@ private:
std::vector<std::unique_ptr<ILogSink>> m_sinks;
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;
bool m_initialized = false;
};

View File

@@ -15,7 +15,12 @@ FileLogSink::~FileLogSink() {
void FileLogSink::Log(const LogEntry& entry) {
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];

View File

@@ -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().SetMinimumLevel(LogLevel::Debug);
Logger::Get().Info(LogCategory::General, "Engine Logger initialized");
AllocConsole();
freopen("CONOUT$", "w", stdout);