From 5ff39c1cb50f09cac7e8b95ab603729e8415e24f Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 30 Mar 2025 23:33:45 -0700 Subject: [PATCH] Implement Log Level selector setting. --- soh/soh/OTRGlobals.cpp | 4 ++++ soh/soh/SohGui/SohMenuDevTools.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 83b13c21c..0f55192f8 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -346,6 +346,10 @@ OTRGlobals::OTRGlobals() { context->InitCrashHandler(); context->InitConsole(); + Ship::Context::GetInstance()->GetLogger()->set_level( + (spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), 1)); + Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); + auto sohInputEditorWindow = std::make_shared(CVAR_WINDOW("ControllerConfiguration"), "Configure Controller"); auto sohFast3dWindow = std::make_shared(std::vector>({sohInputEditorWindow})); context->InitWindow(sohFast3dWindow); diff --git a/soh/soh/SohGui/SohMenuDevTools.cpp b/soh/soh/SohGui/SohMenuDevTools.cpp index 3a769aea4..92795b3f1 100644 --- a/soh/soh/SohGui/SohMenuDevTools.cpp +++ b/soh/soh/SohGui/SohMenuDevTools.cpp @@ -85,6 +85,17 @@ void SohMenu::AddMenuDevTools() { } }) .SameLine(true); + AddWidget(path, "Log Level", WIDGET_CVAR_COMBOBOX) + .CVar("gDeveloperTools.LogLevel") + .Options(ComboboxOptions() + .Tooltip("The log level determines which messages are printed to the " + "console. This does not affect the log file output") + .ComboMap(logLevels)) + .Callback([](WidgetInfo& info) { + Ship::Context::GetInstance()->GetLogger()->set_level( + (spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), 1)); + }) + .PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_DEBUG_MODE_OFF).active; }); // Stats path.sidebarName = "Stats";