From 3d0d987d895686d749073006c9eca96aa650b9ac Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 10 Mar 2024 01:10:19 +0100 Subject: [PATCH] Logging: Introduce logOnce helper For cases where printing a message once is enough and to avoid spamming log.txt --- src/Cemu/Logging/CemuLogging.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 728c8b93..388e51ab 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -7,7 +7,7 @@ enum class LogType : sint32 // note: IDs must be in range 1-64 Force = 63, // always enabled Placeholder = 62, // always disabled - APIErrors = Force, // alias for Force. Logs bad parameters or other API errors in OS libs + APIErrors = Force, // alias for Force. Logs bad parameters or other API usage mistakes or unintended errors in OS libs CoreinitFile = 0, GX2 = 1, @@ -99,6 +99,8 @@ bool cemuLog_log(LogType type, const T* format, TArgs&&... args) return cemuLog_log(type, format_str, std::forward(args)...); } +#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)