Implement simple area sorted logs
This commit is contained in:
parent
46c0414894
commit
8ad57633ae
@ -42,6 +42,7 @@ public:
|
||||
enum class LogType {
|
||||
MODCALL,
|
||||
FULL,
|
||||
FULLAREA
|
||||
};
|
||||
Q_ENUM(LogType)
|
||||
};
|
||||
|
@ -50,6 +50,13 @@ public:
|
||||
*/
|
||||
void flush(const QString f_entry);
|
||||
|
||||
/**
|
||||
* @brief Writes log entry into area seperated logfiles.
|
||||
* @param Preformatted QString which will be written into the logfile
|
||||
* @param Area name of the target logfile.
|
||||
*/
|
||||
void flushArea(const QString f_entry, const QString f_areaName);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Filename of the logfile used. This will always be the time the server starts up.
|
||||
|
@ -27,6 +27,9 @@ ULogger::ULogger(QObject* parent) :
|
||||
case DataTypes::LogType::FULL :
|
||||
writerFull = new WriterFull;
|
||||
break;
|
||||
case DataTypes::LogType::FULLAREA :
|
||||
writerFull = new WriterFull;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +42,9 @@ ULogger::~ULogger()
|
||||
case DataTypes::LogType::FULL :
|
||||
writerFull->deleteLater();
|
||||
break;
|
||||
case DataTypes::LogType::FULLAREA :
|
||||
writerFull->deleteLater();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,6 +154,9 @@ void ULogger::updateAreaBuffer(const QString& f_areaName, const QString& f_logEn
|
||||
if (ConfigManager::loggingType() == DataTypes::LogType::FULL){
|
||||
writerFull->flush(f_logEntry);
|
||||
}
|
||||
if (ConfigManager::loggingType() == DataTypes::LogType::FULLAREA) {
|
||||
writerFull->flushArea(f_logEntry, f_areaName);
|
||||
}
|
||||
}
|
||||
|
||||
QQueue<QString> ULogger::buffer(const QString& f_areaName)
|
||||
|
@ -30,6 +30,17 @@ void WriterFull::flush(const QString f_entry)
|
||||
{
|
||||
l_logfile.setFileName(QString("logs/%1.log").arg(QDate::currentDate().toString("yyyy-MM-dd")));
|
||||
|
||||
if (l_logfile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||
QTextStream file_stream(&l_logfile);
|
||||
file_stream << f_entry;
|
||||
}
|
||||
l_logfile.close();
|
||||
}
|
||||
|
||||
void WriterFull::flushArea(const QString f_entry, const QString f_areaName)
|
||||
{
|
||||
l_logfile.setFileName(QString("logs/%1_%2.log").arg(f_areaName, QDate::currentDate().toString("yyyy-MM-dd")));
|
||||
|
||||
if (l_logfile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||
QTextStream file_stream(&l_logfile);
|
||||
file_stream << f_entry;
|
||||
|
Loading…
Reference in New Issue
Block a user