mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-20 14:44:24 -04:00
Make stub log thread safe
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user