[libcalamares] Rationalize logging
- Move logging-levels to an enum - (re-)Order logging-levels so that the normal debug statement is not the most-important (lowest level). - Drop using namespace std;
This commit is contained in:
parent
6693f81375
commit
ae5511c2f3
@ -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.";
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 );
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user