Make stub log thread safe

This commit is contained in:
PJB3005
2026-03-12 11:11:09 +01:00
parent fa139ecf5c
commit 5f2f9d01c5
+6
View File
@@ -1,4 +1,5 @@
#include <vector>
#include <mutex>
#include "dusk/logging.h"
#include "imgui.h"
@@ -9,6 +10,7 @@ namespace dusk {
static ImGuiTextBuffer StubLogBuffer;
static std::vector<int> LineOffsets;
static bool StubLogPaused;
static std::mutex StubLogMutex;
const char* LogLevelName(const AuroraLogLevel level) {
switch (level) {
@@ -32,6 +34,8 @@ namespace dusk {
return;
}
std::lock_guard lock(StubLogMutex);
LineOffsets.push_back(StubLogBuffer.size());
const auto levelName = LogLevelName(level);
StubLogBuffer.appendf("[%s | %s] %s\n", levelName, module, message);
@@ -40,6 +44,8 @@ namespace dusk {
static void ClearPastFrame();
void ImGuiMenuTools::ShowStubLog() {
std::lock_guard lock(StubLogMutex);
if (!ImGuiConsole::CheckMenuViewToggle(ImGuiKey_F5, m_showStubLog)) {
ClearPastFrame();
return;