summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEblo <7004497+Eblo@users.noreply.github.com>2025-11-03 23:08:06 -0500
committerGitHub <noreply@github.com>2025-11-03 21:08:06 -0700
commit5215c79dedd94b6042b96e6e5c446a0a36760311 (patch)
treec54d9e6abaac999d54845bb22d2e9c404fc19e2d
parent1c97d8f5dac4595b56dbe7d24c174c18caca9608 (diff)
Address logging issues (#1317)
* Address logging issues * Default log levels for debug and release
-rw-r--r--CMake/logging.cmake20
-rw-r--r--CMakeLists.txt1
m---------libultraship0
-rw-r--r--mm/2s2h/BenPort.cpp7
4 files changed, 27 insertions, 1 deletions
diff --git a/CMake/logging.cmake b/CMake/logging.cmake
new file mode 100644
index 000000000..12b201b53
--- /dev/null
+++ b/CMake/logging.cmake
@@ -0,0 +1,20 @@
+set(SPDLOG_LEVEL_TRACE 0)
+set(SPDLOG_LEVEL_DEBUG 1)
+set(SPDLOG_LEVEL_INFO 2)
+set(SPDLOG_LEVEL_WARN 3)
+set(SPDLOG_LEVEL_ERROR 4)
+set(SPDLOG_LEVEL_CRITICAL 5)
+set(SPDLOG_LEVEL_OFF 6)
+set(LOG_LEVELS "SPDLOG_LEVEL_TRACE;SPDLOG_LEVEL_DEBUG;SPDLOG_LEVEL_INFO;SPDLOG_LEVEL_WARN;SPDLOG_LEVEL_ERROR;SPDLOG_LEVEL_CRITICAL;SPDLOG_LEVEL_OFF")
+set(LOG_LEVEL SPDLOG_LEVEL_TRACE CACHE STRING "The spdlog level that prints will be logged out. Overridden to SPDLOG_LEVEL_ERROR on Release builds.")
+set_property(CACHE LOG_LEVEL PROPERTY STRINGS ${LOG_LEVELS})
+if(NOT LOG_LEVEL IN_LIST LOG_LEVELS)
+ message(FATAL_ERROR "LOG_LEVEL must be one of ${LOG_LEVELS}")
+endif()
+set(SPDLOG_ACTIVE_LEVEL ${${LOG_LEVEL}})
+set(LOG_LEVEL_GAME_PRINTS ${SPDLOG_LEVEL_OFF})
+
+add_compile_definitions(
+ LOG_LEVEL_GAME_PRINTS=${LOG_LEVEL_GAME_PRINTS}
+ SPDLOG_ACTIVE_LEVEL=${SPDLOG_ACTIVE_LEVEL}
+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f2a9fbde..38efb64cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,7 @@ set(GAME_STR "MM")
project(2s2h VERSION 3.0.0 LANGUAGES C CXX)
include(CMake/2ship-cvars.cmake)
include(CMake/lus-cvars.cmake)
+include(CMake/logging.cmake)
set(PROJECT_BUILD_NAME "Mion Alfa" CACHE STRING "" FORCE)
set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "" FORCE)
diff --git a/libultraship b/libultraship
-Subproject 5f4be9b6f5f74917c303ab8b66a0b2f4ef91613
+Subproject 5d498e780f25dc3c05804b0328db683121d96a2
diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp
index 680334a1d..e23afc2a1 100644
--- a/mm/2s2h/BenPort.cpp
+++ b/mm/2s2h/BenPort.cpp
@@ -195,8 +195,13 @@ OTRGlobals::OTRGlobals() {
context->InitWindow(benFast3dWindow);
// Override LUS defaults
+#if (_DEBUG)
+ int defaultLogLevel = 0;
+#else
+ int defaultLogLevel = 2;
+#endif
Ship::Context::GetInstance()->GetLogger()->set_level(
- (spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1));
+ (spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", defaultLogLevel));
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();