From 3ddee8090c703bf383e814d8872360f484e55173 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 3 Mar 2020 16:30:22 +0100 Subject: [PATCH] [libcalamares] Drop intermediate CLog class - All the real work is done in CDebug, so remove the base class. --- src/libcalamares/utils/Logger.cpp | 14 ++++++++++---- src/libcalamares/utils/Logger.h | 26 ++++---------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index 0e207fa02..c50dd726b 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -172,20 +172,26 @@ setupLogfile() qInstallMessageHandler( CalamaresLogHandler ); } -CLog::CLog( unsigned int debugLevel ) +CDebug::CDebug( unsigned int debugLevel ) : QDebug( &m_msg ) , m_debugLevel( debugLevel ) { + if ( debugLevel <= LOGERROR ) + { + m_msg = QStringLiteral( "ERROR:" ); + } + else if ( debugLevel <= LOGWARNING ) + { + m_msg = QStringLiteral( "WARNING:" ); + } } -CLog::~CLog() +CDebug::~CDebug() { log( m_msg.toUtf8().data(), m_debugLevel ); } -CDebug::~CDebug() {} - const char Continuation[] = "\n "; const char SubEntry[] = " .. "; diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index 33954bd37..987095adc 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -41,35 +41,17 @@ enum LOGVERBOSE = 8 }; -class DLLEXPORT CLog : public QDebug +class DLLEXPORT CDebug : public QDebug { public: - explicit CLog( unsigned int debugLevel ); - virtual ~CLog(); + explicit CDebug( unsigned int debugLevel = LOGDEBUG ); + virtual ~CDebug(); private: QString m_msg; unsigned int m_debugLevel; }; -class DLLEXPORT CDebug : public CLog -{ -public: - CDebug( unsigned int debugLevel = LOGDEBUG ) - : CLog( debugLevel ) - { - if ( debugLevel <= LOGERROR ) - { - *this << "ERROR:"; - } - else if ( debugLevel <= LOGWARNING ) - { - *this << "WARNING:"; - } - } - virtual ~CDebug(); -}; - /** * @brief The full path of the log file. */ @@ -219,7 +201,7 @@ operator<<( QDebug& s, const DebugMap& t ) } } // namespace Logger -#define cDebug() (Logger::CDebug( Logger::LOGDEBUG ) << Q_FUNC_INFO << Logger::Continuation) +#define cDebug() ( Logger::CDebug( Logger::LOGDEBUG ) << Q_FUNC_INFO << Logger::Continuation ) #define cWarning() Logger::CDebug( Logger::LOGWARNING ) #define cError() Logger::CDebug( Logger::LOGERROR )