Turn MAX_LOGLEVEL into a true constant (and fix self-comparison warning)
This replaces the MAX_LOGLEVEL define with a constexpr variable in order to fix self-comparison warnings in the logging macros when compiling with Clang. (Without this change, the log level check in the logging macros is expanded into something like this: `if (LINFO <= LINFO)`, which triggers a tautological compare warning.)
This commit is contained in:
parent
6bf10e0276
commit
7855e5f73b
|
@ -402,7 +402,7 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDefaultGraphicsBackendName(JNIEn
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetMaxLogLevel(JNIEnv*, jclass)
|
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetMaxLogLevel(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
return static_cast<jint>(MAX_LOGLEVEL);
|
return static_cast<jint>(Common::Log::MAX_LOGLEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv*, jclass,
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv*, jclass,
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \
|
#define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if constexpr (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \
|
if constexpr (Common::Log::MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \
|
||||||
{ \
|
{ \
|
||||||
if (!(_a_)) \
|
if (!(_a_)) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -43,6 +43,6 @@
|
||||||
#define DEBUG_ASSERT(_a_) \
|
#define DEBUG_ASSERT(_a_) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if constexpr (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \
|
if constexpr (Common::Log::MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \
|
||||||
ASSERT(_a_); \
|
ASSERT(_a_); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
|
@ -76,6 +76,12 @@ enum LOG_LEVELS
|
||||||
LDEBUG = 5, // Detailed debugging - might make things slow.
|
LDEBUG = 5, // Detailed debugging - might make things slow.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
|
constexpr auto MAX_LOGLEVEL = Common::Log::LOG_LEVELS::LDEBUG;
|
||||||
|
#else
|
||||||
|
constexpr auto MAX_LOGLEVEL = Common::Log::LOG_LEVELS::LINFO;
|
||||||
|
#endif // logging
|
||||||
|
|
||||||
static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
|
static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
|
||||||
|
|
||||||
void GenericLogFmtImpl(LOG_LEVELS level, LOG_TYPE type, const char* file, int line,
|
void GenericLogFmtImpl(LOG_LEVELS level, LOG_TYPE type, const char* file, int line,
|
||||||
|
@ -99,19 +105,11 @@ void GenericLog(LOG_LEVELS level, LOG_TYPE type, const char* file, int line, con
|
||||||
;
|
;
|
||||||
} // namespace Common::Log
|
} // namespace Common::Log
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
||||||
#define MAX_LOGLEVEL Common::Log::LOG_LEVELS::LDEBUG
|
|
||||||
#else
|
|
||||||
#ifndef MAX_LOGLEVEL
|
|
||||||
#define MAX_LOGLEVEL Common::Log::LOG_LEVELS::LINFO
|
|
||||||
#endif // loglevel
|
|
||||||
#endif // logging
|
|
||||||
|
|
||||||
// Let the compiler optimize this out
|
// Let the compiler optimize this out
|
||||||
#define GENERIC_LOG(t, v, ...) \
|
#define GENERIC_LOG(t, v, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (v <= MAX_LOGLEVEL) \
|
if (v <= Common::Log::MAX_LOGLEVEL) \
|
||||||
Common::Log::GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
|
Common::Log::GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -146,7 +144,7 @@ void GenericLog(LOG_LEVELS level, LOG_TYPE type, const char* file, int line, con
|
||||||
#define GENERIC_LOG_FMT(t, v, format, ...) \
|
#define GENERIC_LOG_FMT(t, v, format, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (v <= MAX_LOGLEVEL) \
|
if (v <= Common::Log::MAX_LOGLEVEL) \
|
||||||
{ \
|
{ \
|
||||||
/* Use a macro-like name to avoid shadowing warnings */ \
|
/* Use a macro-like name to avoid shadowing warnings */ \
|
||||||
constexpr auto GENERIC_LOG_FMT_N = Common::CountFmtReplacementFields(format); \
|
constexpr auto GENERIC_LOG_FMT_N = Common::CountFmtReplacementFields(format); \
|
||||||
|
|
|
@ -315,7 +315,7 @@ static void VLogInfo(std::string_view format, fmt::format_args args)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool use_internal_log = s_use_internal_log.load(std::memory_order_relaxed);
|
const bool use_internal_log = s_use_internal_log.load(std::memory_order_relaxed);
|
||||||
if (MAX_LOGLEVEL < Common::Log::LINFO && !use_internal_log)
|
if (Common::Log::MAX_LOGLEVEL < Common::Log::LINFO && !use_internal_log)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string text = fmt::vformat(format, args);
|
std::string text = fmt::vformat(format, args);
|
||||||
|
|
|
@ -804,7 +804,7 @@ static int ParseAttribList(u8* attrib_id_list, u16& start_id, u16& end_id)
|
||||||
const u8 type_id = attrib_list.Read8(attrib_offset);
|
const u8 type_id = attrib_list.Read8(attrib_offset);
|
||||||
attrib_offset++;
|
attrib_offset++;
|
||||||
|
|
||||||
if constexpr (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG)
|
if constexpr (Common::Log::MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG)
|
||||||
{
|
{
|
||||||
DEBUG_ASSERT(sequence == SDP_SEQ8);
|
DEBUG_ASSERT(sequence == SDP_SEQ8);
|
||||||
(void)seq_size;
|
(void)seq_size;
|
||||||
|
|
|
@ -77,7 +77,7 @@ void LogConfigWidget::CreateWidgets()
|
||||||
verbosity_layout->addWidget(m_verbosity_error);
|
verbosity_layout->addWidget(m_verbosity_error);
|
||||||
verbosity_layout->addWidget(m_verbosity_warning);
|
verbosity_layout->addWidget(m_verbosity_warning);
|
||||||
verbosity_layout->addWidget(m_verbosity_info);
|
verbosity_layout->addWidget(m_verbosity_info);
|
||||||
if constexpr (MAX_LOGLEVEL == Common::Log::LOG_LEVELS::LDEBUG)
|
if constexpr (Common::Log::MAX_LOGLEVEL == Common::Log::LOG_LEVELS::LDEBUG)
|
||||||
{
|
{
|
||||||
verbosity_layout->addWidget(m_verbosity_debug);
|
verbosity_layout->addWidget(m_verbosity_debug);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue