From b22a83658a68e27a1d7c02a07d37a185de2e4a4a Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Fri, 10 Sep 2021 23:51:38 +0200 Subject: [PATCH] Cleanup Logger --- core/include/logger/u_logger.h | 22 ++++----- core/include/logger/writer_full.h | 2 +- core/include/logger/writer_modcall.h | 2 +- core/src/logger/u_logger.cpp | 74 ++++++++++++++-------------- core/src/logger/writer_full.cpp | 4 +- core/src/logger/writer_modcall.cpp | 4 +- 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/core/include/logger/u_logger.h b/core/include/logger/u_logger.h index c0688d5..b102943 100644 --- a/core/include/logger/u_logger.h +++ b/core/include/logger/u_logger.h @@ -55,41 +55,41 @@ public slots: /** * @brief Adds an IC log entry to the area buffer and writes it to the respective log format. */ - void logIC(const QString& f_charName, const QString& f_oocName, const QString& f_ipid, - const QString& f_areaName, const QString &f_message); + void logIC(const QString& f_char_name, const QString& f_ooc_name, const QString& f_ipid, + const QString& f_area_name, const QString &f_message); /** * @brief Adds an OOC log entry to the area buffer and writes it to the respective log format. */ void logOOC(const QString& f_charName, const QString& f_oocName, const QString& f_ipid, - const QString& f_areaName, const QString& f_message); + const QString& f_area_name, const QString& f_message); /** * @brief Adds an login attempt to the area buffer and writes it to the respective log format. */ - void logLogin(const QString& f_charName, const QString& f_oocName, const QString& f_moderatorName, - const QString& f_ipid, const QString &f_areaName, const bool& f_success); + void logLogin(const QString& f_char_name, const QString& f_ooc_name, const QString& f_moderator_name, + const QString& f_ipid, const QString &f_area_name, const bool& f_success); /** * @brief Adds a command usage to the area buffer and writes it to the respective log format. */ - void logCMD(const QString& f_charName, const QString &f_ipid, const QString& f_oocName, const QString f_command, - const QStringList f_args, const QString f_areaName); + void logCMD(const QString& f_char_name, const QString &f_ipid, const QString& f_ooc_name, const QString& f_command, + const QStringList& f_args, const QString& f_area_name); /** * @brief Adds a player kick to the area buffer and writes it to the respective log format. */ - void logKick(const QString& f_moderator, const QString& f_targetIPID); + void logKick(const QString& f_moderator, const QString& f_target_ipid); /** * @brief Adds a player ban to the area buffer and writes it to the respective log format. */ - void logBan(const QString& f_moderator, const QString& f_targetIPID, const QString &f_duration); + void logBan(const QString& f_moderator, const QString& f_target_ipid, const QString &f_duration); /** * @brief Adds a modcall event to the area buffer, also triggers modcall writing. */ - void logModcall(const QString& f_charName, const QString &f_ipid, const QString& f_oocName, const QString& f_areaName); + void logModcall(const QString& f_charName, const QString &f_ipid, const QString& f_oocName, const QString& f_area_name); /** * @brief Logs any connection attempt to the server, wether sucessful or not. @@ -103,7 +103,7 @@ private: * @param Name of the area which buffer is modified. * @param Formatted QString to be added into the buffer. */ - void updateAreaBuffer(const QString& f_areaName, const QString& f_logEntry); + void updateAreaBuffer(const QString& f_areaName, const QString& f_log_entry); /** * @brief QMap of all available area buffers. diff --git a/core/include/logger/writer_full.h b/core/include/logger/writer_full.h index 6156332..69a17f3 100644 --- a/core/include/logger/writer_full.h +++ b/core/include/logger/writer_full.h @@ -55,7 +55,7 @@ public: * @param Preformatted QString which will be written into the logfile * @param Area name of the target logfile. */ - void flush(const QString f_entry, const QString f_areaName); + void flush(const QString f_entry, const QString f_area_name); private: /** diff --git a/core/include/logger/writer_modcall.h b/core/include/logger/writer_modcall.h index 727ea44..3670250 100644 --- a/core/include/logger/writer_modcall.h +++ b/core/include/logger/writer_modcall.h @@ -51,7 +51,7 @@ public: * @param QQueue of the area that will be written into the logfile. * @param Name of the area for the filename. */ - void flush(const QString f_areaName, QQueue f_buffer); + void flush(const QString f_area_name, QQueue f_buffer); private: /** diff --git a/core/src/logger/u_logger.cpp b/core/src/logger/u_logger.cpp index c416a3b..2e2d6e5 100644 --- a/core/src/logger/u_logger.cpp +++ b/core/src/logger/u_logger.cpp @@ -44,36 +44,36 @@ ULogger::~ULogger() } } -void ULogger::logIC(const QString& f_charName, const QString& f_oocName, const QString& f_ipid, - const QString& f_areaName, const QString& f_message) +void ULogger::logIC(const QString& f_char_name, const QString& f_ooc_name, const QString& f_ipid, + const QString& f_area_name, const QString& f_message) { QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_logEntry = QStringLiteral("[%1][%5][IC][%2(%3)][%4]%6\n") - .arg(l_time, f_charName, f_oocName, f_ipid, f_areaName, f_message); - updateAreaBuffer(f_areaName,l_logEntry); + .arg(l_time, f_char_name, f_ooc_name, f_ipid, f_area_name, f_message); + updateAreaBuffer(f_area_name,l_logEntry); } -void ULogger::logOOC(const QString& f_charName, const QString& f_oocName, const QString& f_ipid, - const QString& f_areaName, const QString& f_message) +void ULogger::logOOC(const QString& f_char_name, const QString& f_ooc_name, const QString& f_ipid, + const QString& f_area_name, const QString& f_message) { QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_logEntry = QStringLiteral("[%1][%5][OOC][%2(%3)][%4]%6\n") - .arg(l_time, f_charName, f_oocName, f_ipid, f_areaName, f_message); - updateAreaBuffer(f_areaName,l_logEntry); + .arg(l_time, f_char_name, f_ooc_name, f_ipid, f_area_name, f_message); + updateAreaBuffer(f_area_name,l_logEntry); } -void ULogger::logLogin(const QString& f_charName, const QString& f_oocName, const QString& f_moderatorName, - const QString& f_ipid, const QString& f_areaName, const bool &f_success) +void ULogger::logLogin(const QString& f_char_name, const QString& f_ooc_name, const QString& f_moderator_name, + const QString& f_ipid, const QString& f_area_name, const bool &f_success) { QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); - QString l_success = f_success ? "SUCCESS][" + f_moderatorName : "FAILED][" + f_moderatorName; + QString l_success = f_success ? "SUCCESS][" + f_moderator_name : "FAILED][" + f_moderator_name; QString l_logEntry = QStringLiteral("[%1][LOGIN][%2][%3][%4(%5)]\n") - .arg(l_time, l_success, f_ipid, f_charName, f_oocName); - updateAreaBuffer(f_areaName, l_logEntry); + .arg(l_time, l_success, f_ipid, f_char_name, f_ooc_name); + updateAreaBuffer(f_area_name, l_logEntry); } -void ULogger::logCMD(const QString& f_charName,const QString& f_ipid, const QString& f_oocName, const QString f_command, - const QStringList f_args, const QString f_areaName) +void ULogger::logCMD(const QString& f_char_name,const QString& f_ipid, const QString& f_ooc_name, const QString& f_command, + const QStringList& f_args, const QString& f_area_name) { QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_logEntry; @@ -81,48 +81,48 @@ void ULogger::logCMD(const QString& f_charName,const QString& f_ipid, const QStr // These must be filtered out if (f_command == "login") { l_logEntry = QStringLiteral("[%1][%2][LOGIN][%5][%3(%4)]\n") - .arg(l_time, f_areaName, f_charName, f_oocName, f_ipid); + .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid); } else if (f_command == "rootpass") { l_logEntry = QStringLiteral("[%1][%2][ROOTPASS][%5][%3(%4)]\n") - .arg(l_time, f_areaName, f_charName, f_oocName, f_ipid); + .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_ipid); } else if (f_command == "adduser" && !f_args.isEmpty()) { l_logEntry = QStringLiteral("[%1][%2][USERADD][%6][%3(%4)]%5\n") - .arg(l_time, f_areaName, f_charName, f_oocName, f_args.at(0), f_ipid); + .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_args.at(0), f_ipid); } else { l_logEntry = QStringLiteral("[%1][%2][CMD][%7][%3(%4)]/%5 %6\n") - .arg(l_time, f_areaName, f_charName, f_oocName, f_command, f_args.join(" "), f_ipid); + .arg(l_time, f_area_name, f_char_name, f_ooc_name, f_command, f_args.join(" "), f_ipid); } - updateAreaBuffer(f_areaName,l_logEntry); + updateAreaBuffer(f_area_name,l_logEntry); } -void ULogger::logKick(const QString& f_moderator, const QString& f_targetIPID) +void ULogger::logKick(const QString& f_moderator, const QString& f_target_ipid) { QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_logEntry = QStringLiteral("[%1][%2][KICK][%3]\n") - .arg(l_time, f_moderator, f_targetIPID); + .arg(l_time, f_moderator, f_target_ipid); updateAreaBuffer("SERVER",l_logEntry); } -void ULogger::logBan(const QString &f_moderator, const QString &f_targetIPID, const QString &f_duration) +void ULogger::logBan(const QString &f_moderator, const QString &f_target_ipid, const QString &f_duration) { QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_logEntry = QStringLiteral("[%1][%2][BAN][%3][%4]\n") - .arg(l_time, f_moderator, f_targetIPID, f_duration); + .arg(l_time, f_moderator, f_target_ipid, f_duration); updateAreaBuffer("SERVER",l_logEntry); } -void ULogger::logModcall(const QString &f_charName, const QString &f_ipid, const QString &f_oocName, const QString &f_areaName) +void ULogger::logModcall(const QString &f_char_name, const QString &f_ipid, const QString &f_oocName, const QString &f_area_name) { QString l_time = QDateTime::currentDateTime().toString("ddd MMMM d yyyy | hh:mm:ss"); QString l_logEvent = QStringLiteral("[%1][%2][MODCALL][%5][%3(%4)]\n") - .arg(l_time, f_areaName, f_charName, f_oocName, f_ipid); - updateAreaBuffer(f_areaName, l_logEvent); + .arg(l_time, f_area_name, f_char_name, f_oocName, f_ipid); + updateAreaBuffer(f_area_name, l_logEvent); if (ConfigManager::loggingType() == DataTypes::LogType::MODCALL) { - writerModcall->flush(f_areaName, buffer(f_areaName)); + writerModcall->flush(f_area_name, buffer(f_area_name)); } } @@ -134,28 +134,28 @@ void ULogger::logConnectionAttempt(const QString& f_ip_address, const QString& f updateAreaBuffer("SERVER",l_logEntry); } -void ULogger::updateAreaBuffer(const QString& f_areaName, const QString& f_logEntry) +void ULogger::updateAreaBuffer(const QString& f_area_name, const QString& f_log_entry) { - QQueuel_buffer = m_bufferMap.value(f_areaName); + QQueuel_buffer = m_bufferMap.value(f_area_name); if (l_buffer.length() <= ConfigManager::logBuffer()) { - l_buffer.enqueue(f_logEntry); + l_buffer.enqueue(f_log_entry); } else { l_buffer.dequeue(); - l_buffer.enqueue(f_logEntry); + l_buffer.enqueue(f_log_entry); } - m_bufferMap.insert(f_areaName, l_buffer); + m_bufferMap.insert(f_area_name, l_buffer); if (ConfigManager::loggingType() == DataTypes::LogType::FULL){ - writerFull->flush(f_logEntry); + writerFull->flush(f_log_entry); } if (ConfigManager::loggingType() == DataTypes::LogType::FULLAREA) { - writerFull->flush(f_logEntry, f_areaName); + writerFull->flush(f_log_entry, f_area_name); } } -QQueue ULogger::buffer(const QString& f_areaName) +QQueue ULogger::buffer(const QString& f_area_name) { - return m_bufferMap.value(f_areaName); + return m_bufferMap.value(f_area_name); } diff --git a/core/src/logger/writer_full.cpp b/core/src/logger/writer_full.cpp index ea99842..199c8fc 100644 --- a/core/src/logger/writer_full.cpp +++ b/core/src/logger/writer_full.cpp @@ -37,9 +37,9 @@ void WriterFull::flush(const QString f_entry) l_logfile.close(); } -void WriterFull::flush(const QString f_entry, const QString f_areaName) +void WriterFull::flush(const QString f_entry, const QString f_area_name) { - l_logfile.setFileName(QString("logs/%1_%2.log").arg(f_areaName, QDate::currentDate().toString("yyyy-MM-dd"))); + l_logfile.setFileName(QString("logs/%1_%2.log").arg(f_area_name, QDate::currentDate().toString("yyyy-MM-dd"))); if (l_logfile.open(QIODevice::WriteOnly | QIODevice::Append)) { QTextStream file_stream(&l_logfile); diff --git a/core/src/logger/writer_modcall.cpp b/core/src/logger/writer_modcall.cpp index 68abc84..cea8e4a 100644 --- a/core/src/logger/writer_modcall.cpp +++ b/core/src/logger/writer_modcall.cpp @@ -31,9 +31,9 @@ WriterModcall::WriterModcall(QObject* parent) : } } -void WriterModcall::flush(const QString f_areaName, QQueue f_buffer) +void WriterModcall::flush(const QString f_area_name, QQueue f_buffer) { - l_logfile.setFileName(QString("logs/modcall/report_%1_%2.log").arg(f_areaName, (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss")))); + l_logfile.setFileName(QString("logs/modcall/report_%1_%2.log").arg(f_area_name, (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss")))); if (l_logfile.open(QIODevice::WriteOnly | QIODevice::Append)) { QTextStream file_stream(&l_logfile);