diff --git a/src/Cafe/OS/libs/padscore/padscore.cpp b/src/Cafe/OS/libs/padscore/padscore.cpp index cad9193a..3faa5fba 100644 --- a/src/Cafe/OS/libs/padscore/padscore.cpp +++ b/src/Cafe/OS/libs/padscore/padscore.cpp @@ -170,7 +170,7 @@ void padscoreExport_WPADRead(PPCInterpreter_t* hCPU) { ppcDefineParamU32(channel, 0); ppcDefineParamPtr(wpadStatus, WPADStatus_t, 1); - cemuLog_log(LogType::InputAPI, "WPADRead({}, {:x})", channel, fmt::ptr(wpadStatus)); + cemuLog_log(LogType::InputAPI, "WPADRead({}, {:x})", channel, memory_getVirtualOffsetFromPointer(wpadStatus)); if (channel < InputManager::kMaxWPADControllers) { @@ -224,7 +224,7 @@ void padscoreExport_WPADGetInfo(PPCInterpreter_t* hCPU) { ppcDefineParamU32(channel, 0); ppcDefineParamStructPtr(wpadInfo, WPADInfo_t, 1); - cemuLog_log(LogType::InputAPI, "WPADGetInfo({}, 0x{:08x})", channel, fmt::ptr(wpadInfo)); + cemuLog_log(LogType::InputAPI, "WPADGetInfo({}, 0x{:08x})", channel, memory_getVirtualOffsetFromPointer(wpadInfo)); if (channel < InputManager::kMaxWPADControllers) { diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 25ec6ad8..c206c392 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -78,43 +78,22 @@ bool cemuLog_log(LogType type, std::string_view text); bool cemuLog_log(LogType type, std::u8string_view text); void cemuLog_waitForFlush(); // wait until all log lines are written -template -bool cemuLog_log(LogType type, std::basic_string formatStr, TArgs&&... args) +template +bool cemuLog_log(LogType type, fmt::format_string formatStr, TArgs&&... args) { if (!cemuLog_isLoggingEnabled(type)) return false; - if constexpr (sizeof...(TArgs) == 0) - { - cemuLog_log(type, std::basic_string_view(formatStr.data(), formatStr.size())); - return true; - } - else - { - const auto format_view = fmt::basic_string_view(formatStr); -#if FMT_VERSION >= 110000 - const auto text = fmt::vformat(format_view, fmt::make_format_args>(args...)); -#else - const auto text = fmt::vformat(format_view, fmt::make_format_args>(args...)); -#endif - cemuLog_log(type, std::basic_string_view(text.data(), text.size())); - } - return true; -} -template -bool cemuLog_log(LogType type, const T* format, TArgs&&... args) -{ - if (!cemuLog_isLoggingEnabled(type)) - return false; - auto format_str = std::basic_string(format); - return cemuLog_log(type, format_str, std::forward(args)...); + cemuLog_log(type, fmt::format(formatStr, std::forward(args)...)); + + return true; } #define cemuLog_logOnce(...) { static bool _not_first_call = false; if (!_not_first_call) { _not_first_call = true; cemuLog_log(__VA_ARGS__); } } // same as cemuLog_log, but only outputs in debug mode -template -bool cemuLog_logDebug(LogType type, TFmt format, TArgs&&... args) +template +bool cemuLog_logDebug(LogType type, fmt::format_string format, TArgs&&... args) { #ifdef CEMU_DEBUG_ASSERT return cemuLog_log(type, format, std::forward(args)...); @@ -123,6 +102,15 @@ bool cemuLog_logDebug(LogType type, TFmt format, TArgs&&... args) #endif } +inline bool cemuLog_logDebug(LogType type, std::string_view message) +{ +#ifdef CEMU_DEBUG_ASSERT + return cemuLog_log(type, message); +#else + return false; +#endif +} + #define cemuLog_logDebugOnce(...) { static bool _not_first_call = false; if (!_not_first_call) { _not_first_call = true; cemuLog_logDebug(__VA_ARGS__); } } // utility function for logging binary data as a hex dump