Logging: Introduce logOnce helper

For cases where printing a message once is enough and to avoid spamming log.txt
This commit is contained in:
Exzap 2024-03-10 01:10:19 +01:00
parent bb88b5c36d
commit 3d0d987d89

View File

@ -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<TArgs>(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<typename TFmt, typename ... TArgs>
bool cemuLog_logDebug(LogType type, TFmt format, TArgs&&... args)