From 5248a37eb3ac162d8fc86f3bf4c2f9314842f467 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 3 Mar 2020 16:37:17 +0100 Subject: [PATCH] [libcalamares] Add FUNC_INFO into all debug messages - This is needlessly verbose - Chase CreatePartitionTableJob which needs to bind to a temporary --- src/libcalamares/utils/Logger.cpp | 8 +++++++- src/libcalamares/utils/Logger.h | 9 +++++---- src/modules/partition/jobs/CreatePartitionTableJob.cpp | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index c50dd726b..c39e73c50 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -172,9 +172,10 @@ setupLogfile() qInstallMessageHandler( CalamaresLogHandler ); } -CDebug::CDebug( unsigned int debugLevel ) +CDebug::CDebug( unsigned int debugLevel, const char* func ) : QDebug( &m_msg ) , m_debugLevel( debugLevel ) + , m_funcinfo( func ) { if ( debugLevel <= LOGERROR ) { @@ -189,6 +190,11 @@ CDebug::CDebug( unsigned int debugLevel ) CDebug::~CDebug() { + if ( m_funcinfo ) + { + m_msg.prepend( Continuation ); + m_msg.prepend( m_funcinfo ); + } log( m_msg.toUtf8().data(), m_debugLevel ); } diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index 987095adc..2dfd2878f 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -44,12 +44,13 @@ enum class DLLEXPORT CDebug : public QDebug { public: - explicit CDebug( unsigned int debugLevel = LOGDEBUG ); + explicit CDebug( unsigned int debugLevel = LOGDEBUG, const char* func = nullptr ); virtual ~CDebug(); private: QString m_msg; unsigned int m_debugLevel; + const char* m_funcinfo = nullptr; }; /** @@ -201,8 +202,8 @@ operator<<( QDebug& s, const DebugMap& t ) } } // namespace Logger -#define cDebug() ( Logger::CDebug( Logger::LOGDEBUG ) << Q_FUNC_INFO << Logger::Continuation ) -#define cWarning() Logger::CDebug( Logger::LOGWARNING ) -#define cError() Logger::CDebug( Logger::LOGERROR ) +#define cDebug() Logger::CDebug( Logger::LOGDEBUG, Q_FUNC_INFO ) +#define cWarning() Logger::CDebug( Logger::LOGWARNING, Q_FUNC_INFO ) +#define cError() Logger::CDebug( Logger::LOGERROR, Q_FUNC_INFO ) #endif diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index 20a3c7e6a..b18f56a04 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -69,7 +69,7 @@ CreatePartitionTableJob::prettyStatusMessage() const static inline QDebug& -operator <<( QDebug& s, PartitionIterator& it ) +operator <<( QDebug&& s, PartitionIterator& it ) { s << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); return s;