From f48ad6a1ca13d1abebd2c3b1f789bbe10f6fff1a Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 20 Apr 2023 13:14:11 +0200 Subject: [PATCH] Dont format logging calls with only the format string --- src/Cemu/Logging/CemuLogging.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 09a08ec7..f28bce57 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -76,21 +76,28 @@ auto ForwardEnum(std::tuple t) } template -bool cemuLog_log(LogType type, std::basic_string format, TArgs&&... args) +bool cemuLog_log(LogType type, std::basic_string formatStr, TArgs&&... args) { if (!cemuLog_isLoggingEnabled(type)) return false; - - const auto format_view = fmt::basic_string_view(format); - const auto text = fmt::vformat(format_view, fmt::make_format_args>(ForwardEnum(args)...)); - cemuLog_log(type, std::basic_string_view(text.data(), text.size())); + 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); + const auto text = fmt::vformat(format_view, fmt::make_format_args>(ForwardEnum(args)...)); + cemuLog_log(type, std::basic_string_view(text.data(), text.size())); + } return true; } template bool cemuLog_log(LogType type, const T* format, TArgs&&... args) { - auto format_str=std::basic_string(format); + auto format_str = std::basic_string(format); return cemuLog_log(type, format_str, std::forward(args)...); }