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.
This commit is contained in:
Jim Broadus 2020-03-01 19:11:25 -08:00 committed by John Maguire
parent 90cf4988ea
commit 79ac16afeb
2 changed files with 11 additions and 12 deletions

View File

@ -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);

View File

@ -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,