[libcalamares] Drop intermediate CLog class

- All the real work is done in CDebug, so remove the base class.
main
Adriaan de Groot 5 years ago
parent ae633c7e7b
commit 3ddee8090c

@ -172,20 +172,26 @@ setupLogfile()
qInstallMessageHandler( CalamaresLogHandler ); qInstallMessageHandler( CalamaresLogHandler );
} }
CLog::CLog( unsigned int debugLevel ) CDebug::CDebug( unsigned int debugLevel )
: QDebug( &m_msg ) : QDebug( &m_msg )
, m_debugLevel( debugLevel ) , 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 ); log( m_msg.toUtf8().data(), m_debugLevel );
} }
CDebug::~CDebug() {}
const char Continuation[] = "\n "; const char Continuation[] = "\n ";
const char SubEntry[] = " .. "; const char SubEntry[] = " .. ";

@ -41,35 +41,17 @@ enum
LOGVERBOSE = 8 LOGVERBOSE = 8
}; };
class DLLEXPORT CLog : public QDebug class DLLEXPORT CDebug : public QDebug
{ {
public: public:
explicit CLog( unsigned int debugLevel ); explicit CDebug( unsigned int debugLevel = LOGDEBUG );
virtual ~CLog(); virtual ~CDebug();
private: private:
QString m_msg; QString m_msg;
unsigned int m_debugLevel; 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. * @brief The full path of the log file.
*/ */
@ -219,7 +201,7 @@ operator<<( QDebug& s, const DebugMap& t )
} }
} // namespace Logger } // 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 cWarning() Logger::CDebug( Logger::LOGWARNING )
#define cError() Logger::CDebug( Logger::LOGERROR ) #define cError() Logger::CDebug( Logger::LOGERROR )

Loading…
Cancel
Save