[libcalamares] Log to file and stdout consistently

- The log **file** got every QDebug object, while stdout only
  got the ones of sufficient logging level. A CDebug object checks the
  logging level before writing anything -- so those already were
  consistent, but any qDebug() in the program (not cDebug()!) would
  reach the writing-function anyway, and so log to the file.
  Fix this weird inconsistency by checking log-level just once,
  for both writes.
This commit is contained in:
Adriaan de Groot 2021-05-31 11:39:13 +02:00
parent 716328cafb
commit b68e535131

View File

@ -69,7 +69,7 @@ logLevel()
static void static void
log( const char* msg, unsigned int debugLevel, bool withTime = true ) log( const char* msg, unsigned int debugLevel, bool withTime = true )
{ {
if ( true ) if ( logLevelEnabled( debugLevel ) )
{ {
QMutexLocker lock( &s_mutex ); QMutexLocker lock( &s_mutex );
@ -81,11 +81,7 @@ log( const char* msg, unsigned int debugLevel, bool withTime = true )
<< QString::number( debugLevel ).toUtf8().data() << "]: " << msg << std::endl; << QString::number( debugLevel ).toUtf8().data() << "]: " << msg << std::endl;
logfile.flush(); logfile.flush();
}
if ( logLevelEnabled( debugLevel ) )
{
QMutexLocker lock( &s_mutex );
if ( withTime ) if ( withTime )
{ {
std::cout << QTime::currentTime().toString().toUtf8().data() << " [" std::cout << QTime::currentTime().toString().toUtf8().data() << " ["