[libcalamares] Drop intermediate CLog class

- All the real work is done in CDebug, so remove the base class.
This commit is contained in:
Adriaan de Groot 2020-03-03 16:30:22 +01:00
parent ae633c7e7b
commit 3ddee8090c
2 changed files with 14 additions and 26 deletions

View File

@ -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[] = " .. ";

View File

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