Unified logging: Replace LogSystem with EditorConsoleSink

- Created EditorConsoleSink (implements ILogSink interface)
- EditorConsoleSink stores logs in memory buffer (max 1000 entries)
- Added to Debug::Logger in Application::Initialize()
- ConsolePanel now reads from EditorConsoleSink via static GetInstance()
- Removed separate LogSystem singleton
- Removed editor/src/Core/LogEntry.h (no longer needed)

Now Editor and Engine share the same Debug::Logger, with ConsolePanel
displaying logs via EditorConsoleSink.
This commit is contained in:
2026-03-25 16:13:02 +08:00
parent b08f682e5c
commit 16e2065c6c
28 changed files with 355 additions and 121 deletions

View File

@@ -0,0 +1,43 @@
#include "Core/EditorConsoleSink.h"
namespace XCEngine {
namespace Debug {
EditorConsoleSink* EditorConsoleSink::GetInstance() {
static EditorConsoleSink instance;
return &instance;
}
EditorConsoleSink::EditorConsoleSink() = default;
EditorConsoleSink::~EditorConsoleSink() = default;
void EditorConsoleSink::Log(const LogEntry& entry) {
std::lock_guard<std::mutex> lock(m_mutex);
if (m_logs.size() >= MAX_LOGS) {
m_logs.erase(m_logs.begin());
}
m_logs.push_back(entry);
if (m_callback) {
m_callback();
}
}
void EditorConsoleSink::Flush() {
}
const std::vector<LogEntry>& EditorConsoleSink::GetLogs() const {
return m_logs;
}
void EditorConsoleSink::Clear() {
std::lock_guard<std::mutex> lock(m_mutex);
m_logs.clear();
}
void EditorConsoleSink::SetCallback(std::function<void()> callback) {
m_callback = std::move(callback);
}
} // namespace Debug
} // namespace XCEngine