From 8008ec895ab03b60ca49b7004e1197b374ec594a Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 3 Sep 2024 23:10:55 +0200 Subject: [PATCH] logging: Respect QT_NO_INFO_OUTPUT --- ext/libstrawberry-common/core/logging.cpp | 43 +++++++++++++++++++---- ext/libstrawberry-common/core/logging.h | 19 ++++++---- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/ext/libstrawberry-common/core/logging.cpp b/ext/libstrawberry-common/core/logging.cpp index d4fb8ef6a..da7c818de 100644 --- a/ext/libstrawberry-common/core/logging.cpp +++ b/ext/libstrawberry-common/core/logging.cpp @@ -374,20 +374,49 @@ void DumpStackTrace() { // It's okay that the LoggedDebug instance is copied to a QDebug in these. It doesn't override any behavior that should be needed after return. #define qCreateLogger(line, pretty_function, category, level) logging::CreateLogger(logging::Level_##level, logging::ParsePrettyFunction(pretty_function), line, category) -QDebug CreateLoggerInfo(int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Info); } -QDebug CreateLoggerFatal(int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Fatal); } -QDebug CreateLoggerError(int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Error); } +QDebug CreateLoggerFatal(const int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Fatal); } +QDebug CreateLoggerError(const int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Error); } + +#ifdef QT_NO_INFO_OUTPUT +QNoDebug CreateLoggerInfo(const int line, const char *pretty_function, const char *category) { + + Q_UNUSED(line) + Q_UNUSED(pretty_function) + Q_UNUSED(category) + + return QNoDebug(); + +} +#else +QDebug CreateLoggerInfo(const int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Info); } +#endif // QT_NO_INFO_OUTPUT #ifdef QT_NO_WARNING_OUTPUT - QNoDebug CreateLoggerWarning(int, const char*, const char*) { return QNoDebug(); } +QNoDebug CreateLoggerWarning(const int line, const char *pretty_function, const char *category) { + + Q_UNUSED(line) + Q_UNUSED(pretty_function) + Q_UNUSED(category) + + return QNoDebug(); + +} #else - QDebug CreateLoggerWarning(int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Warning); } +QDebug CreateLoggerWarning(const int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Warning); } #endif // QT_NO_WARNING_OUTPUT #ifdef QT_NO_DEBUG_OUTPUT - QNoDebug CreateLoggerDebug(int, const char*, const char*) { return QNoDebug(); } +QNoDebug CreateLoggerDebug(const int line, const char *pretty_function, const char *category) { + + Q_UNUSED(line) + Q_UNUSED(pretty_function) + Q_UNUSED(category) + + return QNoDebug(); + +} #else - QDebug CreateLoggerDebug(int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Debug); } +QDebug CreateLoggerDebug(const int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Debug); } #endif // QT_NO_DEBUG_OUTPUT } // namespace logging diff --git a/ext/libstrawberry-common/core/logging.h b/ext/libstrawberry-common/core/logging.h index f6afb46a0..bdf5424c8 100644 --- a/ext/libstrawberry-common/core/logging.h +++ b/ext/libstrawberry-common/core/logging.h @@ -72,20 +72,25 @@ enum Level { void DumpStackTrace(); -QDebug CreateLoggerInfo(int line, const char *pretty_function, const char *category); -QDebug CreateLoggerFatal(int line, const char *pretty_function, const char *category); -QDebug CreateLoggerError(int line, const char *pretty_function, const char *category); +QDebug CreateLoggerFatal(const int line, const char *pretty_function, const char *category); +QDebug CreateLoggerError(const int line, const char *pretty_function, const char *category); + +#ifdef QT_NO_INFO_OUTPUT +QNoDebug CreateLoggerInfo(const int line, const char *pretty_function, const char *category); +#else +QDebug CreateLoggerInfo(const int line, const char *pretty_function, const char *category); +#endif // QT_NO_INFO_OUTPUT #ifdef QT_NO_WARNING_OUTPUT - QNoDebug CreateLoggerWarning(int, const char*, const char*); +QNoDebug CreateLoggerWarning(const int line, const char *pretty_function, const char *category); #else - QDebug CreateLoggerWarning(int line, const char *pretty_function, const char *category); +QDebug CreateLoggerWarning(const int line, const char *pretty_function, const char *category); #endif // QT_NO_WARNING_OUTPUT #ifdef QT_NO_DEBUG_OUTPUT - QNoDebug CreateLoggerDebug(int, const char*, const char*); +QNoDebug CreateLoggerDebug(const int line, const char *pretty_function, const char *category); #else - QDebug CreateLoggerDebug(int line, const char *pretty_function, const char *category); +QDebug CreateLoggerDebug(const int line, const char *pretty_function, const char *category); #endif // QT_NO_DEBUG_OUTPUT void GLog(const char *domain, int level, const char *message, void *user_data);