From 79ac16afeb8d6a10f5991aa2d2dd8d698f516ffb Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Sun, 1 Mar 2020 19:11:25 -0800 Subject: [PATCH] Move unneeded declarations and macros from logging header. Some functions and macros aren't used outside of logging.cpp and don't need be declared in header. Functions can be static. --- ext/libclementine-common/core/logging.cpp | 14 +++++++++++--- ext/libclementine-common/core/logging.h | 9 --------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ext/libclementine-common/core/logging.cpp b/ext/libclementine-common/core/logging.cpp index 54eb99735..85634a9c5 100644 --- a/ext/libclementine-common/core/logging.cpp +++ b/ext/libclementine-common/core/logging.cpp @@ -51,6 +51,9 @@ static const char* kMessageHandlerMagic = "__logging_message__"; static const int kMessageHandlerMagicLength = strlen(kMessageHandlerMagic); static QtMessageHandler sOriginalMessageHandler = nullptr; +static QDebug CreateLogger(Level level, const QString& class_name, int line, + const char* category); + void GLog(const char* domain, int level, const char* message, void* user_data) { switch (level) { case G_LOG_FLAG_RECURSION: @@ -147,7 +150,7 @@ void SetLevels(const QString& levels) { } } -QString ParsePrettyFunction(const char* pretty_function) { +static QString ParsePrettyFunction(const char* pretty_function) { // Get the class name out of the function name. QString class_name = pretty_function; const int paren = class_name.indexOf('('); @@ -168,8 +171,8 @@ QString ParsePrettyFunction(const char* pretty_function) { return class_name; } -QDebug CreateLogger(Level level, const QString& class_name, int line, - const char* category) { +static QDebug CreateLogger(Level level, const QString& class_name, int line, + const char* category) { // Map the level to a string const char* level_name = nullptr; switch (level) { @@ -280,6 +283,11 @@ void DumpStackTrace() { #endif } +#define qCreateLogger(line, pretty_function, category, level) \ + logging::CreateLogger(logging::Level_##level, \ + logging::ParsePrettyFunction(pretty_function), line, \ + category) + QDebug CreateLoggerFatal(int line, const char* pretty_function, const char* category) { return qCreateLogger(line, pretty_function, category, Fatal); diff --git a/ext/libclementine-common/core/logging.h b/ext/libclementine-common/core/logging.h index ec075f2cf..b5fd0d4b3 100644 --- a/ext/libclementine-common/core/logging.h +++ b/ext/libclementine-common/core/logging.h @@ -44,11 +44,6 @@ #define qLogCat(level, category) \ logging::CreateLogger##level(__LINE__, __PRETTY_FUNCTION__, category) -#define qCreateLogger(line, pretty_function, category, level) \ - logging::CreateLogger(logging::Level_##level, \ - logging::ParsePrettyFunction(pretty_function), line, \ - category) - #endif // QT_NO_DEBUG_STREAM namespace logging { @@ -71,10 +66,6 @@ void SetLevels(const QString& levels); void DumpStackTrace(); -QString ParsePrettyFunction(const char* pretty_function); -QDebug CreateLogger(Level level, const QString& class_name, int line, - const char* category); - QDebug CreateLoggerFatal(int line, const char* pretty_function, const char* category); QDebug CreateLoggerError(int line, const char* pretty_function,