From d72e3b3c22b788008304d42b7f02f5014036243f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 15 Apr 2019 07:57:25 -0400 Subject: [PATCH] [libcalamares] Simplify writing of logging continuations - Instead of Continuation(), write just Continuation - All that futzing with overloads and tag-classes isn't needed since the whole point is to output some constant string. Leave cleverness for later, if it's needed. --- src/libcalamares/utils/Logger.cpp | 32 ++--------------------------- src/libcalamares/utils/Logger.h | 34 +++++-------------------------- 2 files changed, 7 insertions(+), 59 deletions(-) diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index 3061e0a5e..5f4401ca1 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -189,36 +189,8 @@ CDebug::~CDebug() { } -static const char continuation[] = "\n "; -static const char subentry[] = " .. "; - -QDebug& -operator<<( QDebug& s, Continuation ) -{ - s << continuation; - return s; -} - -QDebug& -operator<<( QDebug& s, SubEntry ) -{ - s << subentry; - return s; -} - -CDebug& -operator<<( CDebug&& s, Continuation ) -{ - s << continuation; - return s; -} - -CDebug& -operator<<( CDebug&& s, SubEntry ) -{ - s << subentry; - return s; -} +const char Continuation[] = "\n "; +const char SubEntry[] = " .. "; QString toString( const QVariant& v ) { diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index d3861279e..d7af886b3 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -27,25 +27,8 @@ namespace Logger { - /** @brief tag-class used for continuing debug-output on the next line - * - * A continuation starts a new debug-log line, without the timestamp and - * other leading information. Used when dumping tables and lists. Represented - * in the log by a newline and four spaces. - */ - struct Continuation - { - } ; - - /** @brief tag-class used to indicate a log line is a sub-entry - * - * Sub-entries indicate additional information that isn't a continuation - * of the previous line, or sub-steps of something that has already been logged. - * Represented in the log as space dot dot space. - */ - struct SubEntry - { - } ; + DLLEXPORT extern const char Continuation[]; + DLLEXPORT extern const char SubEntry[]; enum { @@ -113,13 +96,6 @@ namespace Logger /** @brief Would the given @p level really be logged? */ DLLEXPORT bool logLevelEnabled( unsigned int level ); - /// @brief Output a continuation - DLLEXPORT CDebug& operator <<( CDebug&& s, Continuation c ); - DLLEXPORT QDebug& operator <<( QDebug& s, Continuation c ); - /// @brief Output a subentry marker - DLLEXPORT CDebug& operator <<( CDebug&& s, SubEntry level ); - DLLEXPORT QDebug& operator <<( QDebug& s, SubEntry level ); - /** * @brief Row-oriented formatted logging. * @@ -186,7 +162,7 @@ namespace Logger inline QDebug& operator <<( QDebug& s, const DebugRow& t ) { - s << Continuation() << t.first << ':' << ' ' << t.second; + s << Continuation << t.first << ':' << ' ' << t.second; return s; } @@ -195,7 +171,7 @@ namespace Logger operator <<( QDebug& s, const DebugList& c ) { for( const auto& i : c.list ) - s << Continuation() << i; + s << Continuation << i; return s; } @@ -207,7 +183,7 @@ namespace Logger operator <<( QDebug& s, const DebugMap& t ) { for ( auto it = t.map.constBegin(); it != t.map.constEnd(); ++it ) - s << Continuation() << it.key().toUtf8().constData() << ':' << ' ' << toString( it.value() ).toUtf8().constData(); + s << Continuation << it.key().toUtf8().constData() << ':' << ' ' << toString( it.value() ).toUtf8().constData(); return s; } }