Implement logger changes (#5914)

* Implement logger changes, and make default log level dynamic based on debug/release.

* Bump LUS.

* typo

Co-authored-by: Eblo <7004497+Eblo@users.noreply.github.com>

---------

Co-authored-by: Eblo <7004497+Eblo@users.noreply.github.com>
This commit is contained in:
Malkierian
2025-11-03 18:54:01 -07:00
committed by GitHub
parent 0014f40676
commit cf275b1a6c
6 changed files with 33 additions and 6 deletions

View File

@@ -13,8 +13,8 @@ extern "C"
#include <libultraship/log/luslog.h>
#include <soh/Enhancements/item-tables/ItemTableTypes.h>
#if defined(INCLUDE_GAME_PRINTF) && defined(_DEBUG)
#define osSyncPrintf(fmt, ...) lusprintf(__FILE__, __LINE__, 0, fmt, ##__VA_ARGS__)
#if (LOG_LEVEL_GAME_PRINTS >= SPDLOG_ACTIVE_LEVEL) && !(LOG_LEVEL_GAME_PRINTS >= 6)
#define osSyncPrintf(...) lusprintf(__FILE__, __LINE__, LOG_LEVEL_GAME_PRINTS , __VA_ARGS__)
#else
#define osSyncPrintf(fmt, ...) osSyncPrintfUnused(fmt, ##__VA_ARGS__)
#endif

View File

@@ -225,7 +225,7 @@ StaticData::PopulateTranslationMap(std::unordered_map<uint32_t, CustomMessage> i
if (output.contains(string)) {
if (output[string] != key) {
// RANDOTODO should this cause an error of some kind?
SPDLOG_DEBUG("\tREPEATED STRING IN " + message.GetEnglish(MF_CLEAN) + "\n\n");
SPDLOG_DEBUG("REPEATED STRING IN " + message.GetEnglish(MF_CLEAN));
}
} else {
output[string] = key;
@@ -244,7 +244,7 @@ StaticData::PopulateTranslationMap(std::unordered_map<uint32_t, RandomizerHintTe
if (output.contains(string)) {
if (output[string] != key) {
// RANDOTODO should this cause an error of some kind?
SPDLOG_DEBUG("\tREPEATED STRING WITH " + string + "\n\n");
SPDLOG_DEBUG("REPEATED STRING WITH " + string);
}
} else {
output[string] = key;

View File

@@ -12,6 +12,7 @@
#include <fast/resource/type/DisplayList.h>
#include <ship/window/Window.h>
#include <soh/GameVersions.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include "Enhancements/gameconsole.h"
#ifdef _WIN32
@@ -319,8 +320,13 @@ void OTRGlobals::Initialize() {
context->InitCrashHandler();
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"), 1));
(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 =