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;
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -15,8 +15,13 @@ FileLogSink::~FileLogSink() {
|
||||
|
||||
void FileLogSink::Log(const LogEntry& entry) {
|
||||
if (!m_writer.IsOpen()) {
|
||||
// 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];
|
||||
std::time_t time = static_cast<std::time_t>(entry.timestamp);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user