diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 40d4abf24..5cfbbf21f 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -89,7 +89,7 @@ CalamaresApplication::init() CalamaresApplication::~CalamaresApplication() { - cDebug( LOGVERBOSE ) << "Shutting down Calamares..."; + cDebug( Logger::LOGVERBOSE ) << "Shutting down Calamares..."; // if ( JobQueue::instance() ) // JobQueue::instance()->stop(); @@ -98,7 +98,7 @@ CalamaresApplication::~CalamaresApplication() // delete JobQueue::instance(); - cDebug( LOGVERBOSE ) << "Finished shutdown."; + cDebug( Logger::LOGVERBOSE ) << "Finished shutdown."; } diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index 4fbac6f03..a19386ba4 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -2,7 +2,7 @@ * * Copyright 2010-2011, Christian Muehlhaeuser * Copyright 2014, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017-2018, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,13 +34,8 @@ #define LOGFILE_SIZE 1024 * 256 -#define RELEASE_LEVEL_THRESHOLD 0 -#define DEBUG_LEVEL_THRESHOLD LOGEXTRA - -using namespace std; - -static ofstream logfile; -static unsigned int s_threshold = 0; +static std::ofstream logfile; +static unsigned int s_threshold = 0; // Set to non-zero on first logging call static QMutex s_mutex; namespace Logger @@ -56,9 +51,9 @@ log( const char* msg, unsigned int debugLevel, bool toDisk = true ) s_threshold = LOGVERBOSE; else #ifdef QT_NO_DEBUG - s_threshold = RELEASE_LEVEL_THRESHOLD; + s_threshold = LOG_DISABLE; #else - s_threshold = DEBUG_LEVEL_THRESHOLD; + s_threshold = LOGEXTRA; #endif // Comparison is < threshold, below ++s_threshold; @@ -75,7 +70,7 @@ log( const char* msg, unsigned int debugLevel, bool toDisk = true ) << " - " << QTime::currentTime().toString().toUtf8().data() << " [" << QString::number( debugLevel ).toUtf8().data() << "]: " - << msg << endl; + << msg << std::endl; logfile.flush(); } @@ -84,11 +79,10 @@ log( const char* msg, unsigned int debugLevel, bool toDisk = true ) { QMutexLocker lock( &s_mutex ); - cout << QTime::currentTime().toString().toUtf8().data() + std::cout << QTime::currentTime().toString().toUtf8().data() << " [" << QString::number( debugLevel ).toUtf8().data() << "]: " - << msg << endl; - - cout.flush(); + << msg << std::endl; + std::cout.flush(); } } @@ -155,7 +149,7 @@ setupLogfile() cDebug() << "Using log file:" << logFile(); - logfile.open( logFile().toLocal8Bit(), ios::app ); + logfile.open( logFile().toLocal8Bit(), std::ios::app ); qInstallMessageHandler( CalamaresLogHandler ); } diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index 7f9077035..9244100de 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -25,13 +25,19 @@ #include "DllMacro.h" -#define LOGDEBUG 1 -#define LOGINFO 2 -#define LOGEXTRA 5 -#define LOGVERBOSE 8 - namespace Logger { + enum + { + LOG_DISABLE = 0, + LOGERROR = 1, + LOGWARNING = 2, + LOGINFO = 3, + LOGEXTRA = 5, + LOGDEBUG = 6, + LOGVERBOSE = 8 + } ; + class DLLEXPORT CLog : public QDebug { public: