Logging bump (#5938)

* Bump LUS, call `InitLogging` with both values at `trace`.
Set up proper conditional default log level in Dev Tools.

* Update LUS ref.
This commit is contained in:
Malkierian 2025-11-09 18:27:19 -07:00 committed by GitHub
parent 7ff93a3960
commit 6b83070343
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 41 additions and 48 deletions

View File

@ -1,20 +0,0 @@
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}
)

View File

@ -9,7 +9,9 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment ve
project(Ship VERSION 9.1.1 LANGUAGES C CXX) project(Ship VERSION 9.1.1 LANGUAGES C CXX)
include(CMake/soh-cvars.cmake) include(CMake/soh-cvars.cmake)
include(CMake/lus-cvars.cmake) include(CMake/lus-cvars.cmake)
include(CMake/logging.cmake) set(SPDLOG_LEVEL_TRACE 0)
set(SPDLOG_LEVEL_OFF 6)
set(SPDLOG_MIN_CUTOFF SPDLOG_LEVEL_TRACE CACHE STRING "cutoff at trace")
option(SUPPRESS_WARNINGS "Suppress warnings in LUS and src (decomp)" ON) option(SUPPRESS_WARNINGS "Suppress warnings in LUS and src (decomp)" ON)
if(SUPPRESS_WARNINGS) if(SUPPRESS_WARNINGS)

@ -1 +1 @@
Subproject commit 17a0b7939bd05f5e617cef89457ca43774fc9a9f Subproject commit a8bdcab363571038bb71f195f21ec3e9033a220d

View File

@ -337,13 +337,15 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
"ENABLE_DX11;" "ENABLE_DX11;"
">" ">"
"$<$<CONFIG:Release>:" "$<$<CONFIG:Release>:"
"NDEBUG" "NDEBUG;"
">" ">"
"$<$<BOOL:${BUILD_REMOTE_CONTROL}>:ENABLE_REMOTE_CONTROL>" "$<$<BOOL:${BUILD_REMOTE_CONTROL}>:ENABLE_REMOTE_CONTROL>"
"INCLUDE_GAME_PRINTF;" "INCLUDE_GAME_PRINTF;"
"F3DEX_GBI_2" "F3DEX_GBI_2"
"UNICODE;" "UNICODE;"
"_UNICODE" "_UNICODE"
SPDLOG_ACTIVE_LEVEL=${SPDLOG_MIN_CUTOFF}
LOG_LEVEL_GAME_PRINTS=${SPDLOG_LEVEL_OFF}
STORMLIB_NO_AUTO_LINK STORMLIB_NO_AUTO_LINK
"_CRT_SECURE_NO_WARNINGS;" "_CRT_SECURE_NO_WARNINGS;"
NOMINMAX NOMINMAX
@ -354,7 +356,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
"NOINCLUDE_GAME_PRINTF;" "NOINCLUDE_GAME_PRINTF;"
"_DEBUG;" "_DEBUG;"
"_CRT_SECURE_NO_WARNINGS;" "_CRT_SECURE_NO_WARNINGS;"
"ENABLE_OPENGL" "ENABLE_OPENGL;"
">" ">"
"$<$<CONFIG:Release>:" "$<$<CONFIG:Release>:"
"NDEBUG;" "NDEBUG;"
@ -363,7 +365,9 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
"F3DEX_GBI_2" "F3DEX_GBI_2"
"WIN32;" "WIN32;"
"UNICODE;" "UNICODE;"
"_UNICODE" "_UNICODE;"
SPDLOG_ACTIVE_LEVEL=${SPDLOG_MIN_CUTOFF}
LOG_LEVEL_GAME_PRINTS=${SPDLOG_LEVEL_OFF}
STORMLIB_NO_AUTO_LINK STORMLIB_NO_AUTO_LINK
NOMINMAX NOMINMAX
) )
@ -371,33 +375,35 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_compile_definitions(${PROJECT_NAME} PRIVATE target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:" "$<$<CONFIG:Debug>:"
"_DEBUG" "_DEBUG;"
">" ">"
"$<$<CONFIG:Release>:" "$<$<CONFIG:Release>:"
"NDEBUG" "NDEBUG;"
">" ">"
"F3DEX_GBI_2" "F3DEX_GBI_2;"
"SPDLOG_ACTIVE_LEVEL=3;"
"SPDLOG_NO_THREAD_ID;" "SPDLOG_NO_THREAD_ID;"
"SPDLOG_NO_TLS;" "SPDLOG_NO_TLS;"
"STBI_NO_THREAD_LOCALS;" "STBI_NO_THREAD_LOCALS;"
SPDLOG_ACTIVE_LEVEL=${SPDLOG_MIN_CUTOFF}
LOG_LEVEL_GAME_PRINTS=${SPDLOG_LEVEL_OFF}
) )
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_definitions(${PROJECT_NAME} PRIVATE target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:" "$<$<CONFIG:Debug>:"
"_DEBUG" "_DEBUG;"
">" ">"
"$<$<CONFIG:Release>:" "$<$<CONFIG:Release>:"
"NDEBUG" "NDEBUG;"
">" ">"
"F3DEX_GBI_2" "F3DEX_GBI_2;"
"$<$<BOOL:${BUILD_REMOTE_CONTROL}>:ENABLE_REMOTE_CONTROL>" "$<$<BOOL:${BUILD_REMOTE_CONTROL}>:ENABLE_REMOTE_CONTROL>;"
"SPDLOG_ACTIVE_LEVEL=0;"
"_CONSOLE;" "_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;" "_CRT_SECURE_NO_WARNINGS;"
"ENABLE_OPENGL;" "ENABLE_OPENGL;"
"UNICODE;" "UNICODE;"
"_UNICODE" "_UNICODE;"
SPDLOG_ACTIVE_LEVEL=${SPDLOG_MIN_CUTOFF}
LOG_LEVEL_GAME_PRINTS=${SPDLOG_LEVEL_OFF}
) )
endif() endif()
################################################################################ ################################################################################

View File

@ -292,10 +292,17 @@ void OTRGlobals::Initialize() {
OOT_NTSC_JP_GC, OOT_NTSC_US_GC, OOT_PAL_GC, OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2, OOT_NTSC_JP_GC, OOT_NTSC_US_GC, OOT_PAL_GC, OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2,
}; };
context->InitLogging(); #if (_DEBUG)
context->InitGfxDebugger(); auto defaultLogLevel = spdlog::level::trace;
#else
auto defaultLogLevel = spdlog::level::info;
#endif
context->InitLogging(defaultLogLevel, defaultLogLevel);
context->InitConfiguration(); context->InitConfiguration();
context->InitConsoleVariables(); context->InitConsoleVariables();
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
context->InitGfxDebugger();
context->InitFileDropMgr(); context->InitFileDropMgr();
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
@ -320,15 +327,6 @@ void OTRGlobals::Initialize() {
context->InitCrashHandler(); context->InitCrashHandler();
context->InitConsole(); context->InitConsole();
#if (_DEBUG)
int defaultLogLevel = 0;
#else
int defaultLogLevel = 2;
#endif
Ship::Context::GetInstance()->GetLogger()->set_level(
(spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), defaultLogLevel));
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
auto sohInputEditorWindow = auto sohInputEditorWindow =
std::make_shared<SohInputEditorWindow>(CVAR_WINDOW("ControllerConfiguration"), "Configure Controller"); std::make_shared<SohInputEditorWindow>(CVAR_WINDOW("ControllerConfiguration"), "Configure Controller");
auto sohFast3dWindow = auto sohFast3dWindow =

View File

@ -11,6 +11,12 @@ static const std::unordered_map<int32_t, const char*> logLevels = {
{ DEBUG_LOG_OFF, "Off" }, { DEBUG_LOG_OFF, "Off" },
}; };
#ifdef _DEBUG
DebugLogOption defaultLogLevel = DEBUG_LOG_TRACE;
#else
DebugLogOption defaultLogLevel = DEBUG_LOG_INFO;
#endif
static const std::unordered_map<int32_t, const char*> debugSaveFileModes = { static const std::unordered_map<int32_t, const char*> debugSaveFileModes = {
{ 0, "Off" }, { 0, "Off" },
{ 1, "Vanilla" }, { 1, "Vanilla" },
@ -110,10 +116,11 @@ void SohMenu::AddMenuDevTools() {
.Options(ComboboxOptions() .Options(ComboboxOptions()
.Tooltip("The log level determines which messages are printed to the console." .Tooltip("The log level determines which messages are printed to the console."
" This does not affect the log file output") " This does not affect the log file output")
.ComboMap(logLevels)) .ComboMap(logLevels)
.DefaultIndex(defaultLogLevel))
.Callback([](WidgetInfo& info) { .Callback([](WidgetInfo& info) {
Ship::Context::GetInstance()->GetLogger()->set_level( Ship::Context::GetInstance()->GetLogger()->set_level(
(spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), DEBUG_LOG_DEBUG)); (spdlog::level::level_enum)CVarGetInteger(CVAR_DEVELOPER_TOOLS("LogLevel"), defaultLogLevel));
}) })
.PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_DEBUG_MODE_OFF).active; }); .PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_DEBUG_MODE_OFF).active; });