From 469a4d812d51340f49eb878490fe34fcfdcb92d9 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 4 Feb 2024 11:34:30 +0100 Subject: [PATCH] Minor improvements --- logdoctor/mainwindow.cpp | 20 ++++++++-------- logdoctor/modules/craplog/craplog.cpp | 2 +- logdoctor/modules/craplog/craplog.h | 2 +- logdoctor/modules/craplog/modules/datetime.h | 6 ++--- logdoctor/modules/craplog/modules/donuts.h | 6 ++--- logdoctor/modules/craplog/modules/formats.h | 6 ++--- logdoctor/modules/craplog/modules/hash.h | 6 ++--- logdoctor/modules/craplog/modules/lib.h | 24 ++++++++------------ logdoctor/modules/craplog/modules/logs.h | 6 ++--- logdoctor/modules/exceptions.cpp | 2 +- logdoctor/modules/exceptions.h | 2 +- 11 files changed, 39 insertions(+), 43 deletions(-) diff --git a/logdoctor/mainwindow.cpp b/logdoctor/mainwindow.cpp index 9e169751..d26c5cd1 100644 --- a/logdoctor/mainwindow.cpp +++ b/logdoctor/mainwindow.cpp @@ -1999,7 +1999,7 @@ void MainWindow::makeInitialChecks() // get a fresh list of log files this->on_button_LogFiles_RefreshList_clicked(); // set the default WS as the current one - switch ( this->craplog.getCurrentWSID() ) { + switch ( this->craplog.getCurrentWebServer() ) { case WS_APACHE: this->ui->box_StatsWarn_WebServer->setCurrentIndex( 0 ); this->ui->box_StatsCount_WebServer->setCurrentIndex( 0 ); @@ -2615,7 +2615,7 @@ void MainWindow::checkMakeStats_Makable() // switch to apache web server void MainWindow::on_button_LogFiles_Apache_clicked() { - if ( this->craplog.getCurrentWSID() != WS_APACHE ) { + if ( this->craplog.getCurrentWebServer() != WS_APACHE ) { // flat/unflat this->ui->button_LogFiles_Apache->setFlat( false ); this->ui->button_LogFiles_Nginx->setFlat( true ); @@ -2636,7 +2636,7 @@ void MainWindow::on_button_LogFiles_Apache_clicked() // switch to nginx web server void MainWindow::on_button_LogFiles_Nginx_clicked() { - if ( this->craplog.getCurrentWSID() != WS_NGINX ) { + if ( this->craplog.getCurrentWebServer() != WS_NGINX ) { // flat/unflat this->ui->button_LogFiles_Nginx->setFlat( false ); this->ui->button_LogFiles_Apache->setFlat( true ); @@ -2657,7 +2657,7 @@ void MainWindow::on_button_LogFiles_Nginx_clicked() // switch to iis web server void MainWindow::on_button_LogFiles_Iis_clicked() { - if ( this->craplog.getCurrentWSID() != WS_IIS ) { + if ( this->craplog.getCurrentWebServer() != WS_IIS ) { // flat/unflat this->ui->button_LogFiles_Iis->setFlat( false ); this->ui->button_LogFiles_Apache->setFlat( true ); @@ -4866,7 +4866,7 @@ void MainWindow::on_button_ConfApache_Format_Save_clicked() this->ui->inLine_ConfApache_Format_String->text().trimmed().toStdString() ) }; if ( success ) { this->ui->button_ConfApache_Format_Save->setEnabled( false ); - if ( this->craplog.getCurrentWSID() == WS_APACHE ) { + if ( this->craplog.getCurrentWebServer() == WS_APACHE ) { this->craplog.setCurrentLogFormat(); } } @@ -5237,7 +5237,7 @@ void MainWindow::on_button_ConfNginx_Format_Save_clicked() this->ui->inLine_ConfNginx_Format_String->text().trimmed().toStdString() ) }; if ( success ) { this->ui->button_ConfNginx_Format_Save->setEnabled( false ); - if ( this->craplog.getCurrentWSID() == WS_NGINX ) { + if ( this->craplog.getCurrentWebServer() == WS_NGINX ) { this->craplog.setCurrentLogFormat(); } } @@ -5605,7 +5605,7 @@ void MainWindow::on_radio_ConfIis_Format_W3C_toggled(bool checked) this->ui->inLine_ConfIis_Format_String->clear(); this->ui->inLine_ConfIis_Format_String->setEnabled( true ); this->ui->inLine_ConfIis_Format_String->setFocus(); - if ( this->craplog.getCurrentWSID() == WS_IIS ) { + if ( this->craplog.getCurrentWebServer() == WS_IIS ) { this->craplog.setCurrentLogFormat(); this->on_button_LogFiles_RefreshList_clicked(); } @@ -5623,7 +5623,7 @@ void MainWindow::on_radio_ConfIis_Format_NCSA_toggled(bool checked) this->ui->inLine_ConfIis_Format_String->setText( QString::fromStdString( this->craplog.getLogsFormatString( WS_IIS ) ) ); this->ui->inLine_ConfIis_Format_String->setEnabled( false ); this->ui->button_ConfIis_Format_Save->setEnabled( false ); - if ( this->craplog.getCurrentWSID() == WS_IIS ) { + if ( this->craplog.getCurrentWebServer() == WS_IIS ) { this->craplog.setCurrentLogFormat(); this->on_button_LogFiles_RefreshList_clicked(); } @@ -5641,7 +5641,7 @@ void MainWindow::on_radio_ConfIis_Format_IIS_toggled(bool checked) this->ui->inLine_ConfIis_Format_String->setText( QString::fromStdString( this->craplog.getLogsFormatString( WS_IIS ) ) ); this->ui->inLine_ConfIis_Format_String->setEnabled( false ); this->ui->button_ConfIis_Format_Save->setEnabled( false ); - if ( this->craplog.getCurrentWSID() == WS_IIS ) { + if ( this->craplog.getCurrentWebServer() == WS_IIS ) { this->craplog.setCurrentLogFormat(); this->on_button_LogFiles_RefreshList_clicked(); } @@ -5671,7 +5671,7 @@ void MainWindow::on_button_ConfIis_Format_Save_clicked() this->getIisLogsModule() ) }; if ( success ) { this->ui->button_ConfIis_Format_Save->setEnabled( false ); - if ( this->craplog.getCurrentWSID() == WS_IIS ) { + if ( this->craplog.getCurrentWebServer() == WS_IIS ) { this->craplog.setCurrentLogFormat(); } } diff --git a/logdoctor/modules/craplog/craplog.cpp b/logdoctor/modules/craplog/craplog.cpp index 45b26a8a..d0b71983 100644 --- a/logdoctor/modules/craplog/craplog.cpp +++ b/logdoctor/modules/craplog/craplog.cpp @@ -217,7 +217,7 @@ void Craplog::setCurrentWebServer( const WebServer web_server ) noexcept this->setCurrentLogFormat(); } -WebServer Craplog::getCurrentWSID() const noexcept +WebServer Craplog::getCurrentWebServer() const noexcept { return this->current_web_server; } diff --git a/logdoctor/modules/craplog/craplog.h b/logdoctor/modules/craplog/craplog.h index 7290be0c..3c6f004d 100644 --- a/logdoctor/modules/craplog/craplog.h +++ b/logdoctor/modules/craplog/craplog.h @@ -70,7 +70,7 @@ public: /*! \return The Web Server ID */ - WebServer getCurrentWSID() const noexcept; + WebServer getCurrentWebServer() const noexcept; //! Uses the current Web Server to set the relative logs format /*! diff --git a/logdoctor/modules/craplog/modules/datetime.h b/logdoctor/modules/craplog/modules/datetime.h index 8c27fd99..5806853b 100644 --- a/logdoctor/modules/craplog/modules/datetime.h +++ b/logdoctor/modules/craplog/modules/datetime.h @@ -1,5 +1,5 @@ -#ifndef LOGDOCTOR__CRAPLOG__DATETIME_H -#define LOGDOCTOR__CRAPLOG__DATETIME_H +#ifndef LOGDOCTOR__CRAPLOG__MODULES__DATETIME_H +#define LOGDOCTOR__CRAPLOG__MODULES__DATETIME_H #include @@ -25,4 +25,4 @@ std::vector processDateTime( std::string_view datetime, std::string } // namespace DateTimeOps -#endif // LOGDOCTOR__CRAPLOG__DATETIME_H +#endif // LOGDOCTOR__CRAPLOG__MODULES__DATETIME_H diff --git a/logdoctor/modules/craplog/modules/donuts.h b/logdoctor/modules/craplog/modules/donuts.h index f7430ea8..a667b4fc 100644 --- a/logdoctor/modules/craplog/modules/donuts.h +++ b/logdoctor/modules/craplog/modules/donuts.h @@ -1,5 +1,5 @@ -#ifndef LOGDOCTOR__CRAPLOG__DONUTS_H -#define LOGDOCTOR__CRAPLOG__DONUTS_H +#ifndef LOGDOCTOR__CRAPLOG__MODULES__DONUTS_H +#define LOGDOCTOR__CRAPLOG__MODULES__DONUTS_H #include @@ -84,4 +84,4 @@ private: }; -#endif // LOGDOCTOR__CRAPLOG__DONUTS_H +#endif // LOGDOCTOR__CRAPLOG__MODULES__DONUTS_H diff --git a/logdoctor/modules/craplog/modules/formats.h b/logdoctor/modules/craplog/modules/formats.h index 7e8f34ac..c0767517 100644 --- a/logdoctor/modules/craplog/modules/formats.h +++ b/logdoctor/modules/craplog/modules/formats.h @@ -1,5 +1,5 @@ -#ifndef LOGDOCTOR__CRAPLOG__FORMATS_H -#define LOGDOCTOR__CRAPLOG__FORMATS_H +#ifndef LOGDOCTOR__CRAPLOG__MODULES__FORMATS_H +#define LOGDOCTOR__CRAPLOG__MODULES__FORMATS_H #include @@ -439,4 +439,4 @@ private: }; -#endif // LOGDOCTOR__CRAPLOG__FORMATS_H +#endif // LOGDOCTOR__CRAPLOG__MODULES__FORMATS_H diff --git a/logdoctor/modules/craplog/modules/hash.h b/logdoctor/modules/craplog/modules/hash.h index 0cfdcb7b..cf836439 100644 --- a/logdoctor/modules/craplog/modules/hash.h +++ b/logdoctor/modules/craplog/modules/hash.h @@ -1,5 +1,5 @@ -#ifndef LOGDOCTOR__CRAPLOG__HASH_H -#define LOGDOCTOR__CRAPLOG__HASH_H +#ifndef LOGDOCTOR__CRAPLOG__MODULES__HASH_H +#define LOGDOCTOR__CRAPLOG__MODULES__HASH_H #include "main_lib.h" @@ -83,4 +83,4 @@ private: }; -#endif // LOGDOCTOR__CRAPLOG__HASH_H +#endif // LOGDOCTOR__CRAPLOG__MODULES__HASH_H diff --git a/logdoctor/modules/craplog/modules/lib.h b/logdoctor/modules/craplog/modules/lib.h index 9def5d41..8105c47a 100644 --- a/logdoctor/modules/craplog/modules/lib.h +++ b/logdoctor/modules/craplog/modules/lib.h @@ -1,5 +1,5 @@ -#ifndef LOGDOCTOR__CRAPLOG__LIB_H -#define LOGDOCTOR__CRAPLOG__LIB_H +#ifndef LOGDOCTOR__CRAPLOG__MODULES__LIB_H +#define LOGDOCTOR__CRAPLOG__MODULES__LIB_H #include @@ -15,10 +15,11 @@ */ enum class LogType #ifdef _MSC_VER - : __int8 { + : __int8 #else - : __INT8_TYPE__ { + : __INT8_TYPE__ #endif +{ Failed = -1, //!< Failed to determine the type Discarded = 0, //!< Not a valid file, will be discarded Access = 1 //!< Valid access logs file type @@ -26,7 +27,8 @@ enum class LogType //! Holds informations about a log file -struct LogFile final { +struct LogFile final +{ explicit LogFile() noexcept = default; explicit LogFile(const bool sel,const bool used,const size_t sz,const QString& nm,const std::string& hs,const std::string& pt) noexcept :selected{sel},used_already{used},size_{sz},name_{nm},hash_{hs},path_{pt}{} @@ -70,7 +72,8 @@ Q_DECLARE_METATYPE( LogFile ) //! Holds informations about a log format -struct LogsFormat final { +struct LogsFormat final +{ explicit LogsFormat() noexcept = default; explicit LogsFormat (const std::string& str,std::string&& itl,std::string&& fnl,std::vector&& seps,std::vector&& flds,const unsigned nl) noexcept @@ -84,11 +87,4 @@ struct LogsFormat final { }; -//! Hold the items of a blacklist/warnlist -struct BWlist final { - bool used; //!< Whether the list is set to be used or not - std::vector list; //!< The list of items -}; - - -#endif // LOGDOCTOR__CRAPLOG__LIB_H +#endif // LOGDOCTOR__CRAPLOG__MODULES__LIB_H diff --git a/logdoctor/modules/craplog/modules/logs.h b/logdoctor/modules/craplog/modules/logs.h index 0de56e37..bb29ee4d 100644 --- a/logdoctor/modules/craplog/modules/logs.h +++ b/logdoctor/modules/craplog/modules/logs.h @@ -1,5 +1,5 @@ -#ifndef LOGDOCTOR__CRAPLOG__LOGS_H -#define LOGDOCTOR__CRAPLOG__LOGS_H +#ifndef LOGDOCTOR__CRAPLOG__MODULES__LOGS_H +#define LOGDOCTOR__CRAPLOG__MODULES__LOGS_H #include "lib.h" @@ -27,4 +27,4 @@ LogType defineFileType( } // namespace LogOps -#endif // LOGDOCTOR__CRAPLOG__LOGS_H +#endif // LOGDOCTOR__CRAPLOG__MODULES__LOGS_H diff --git a/logdoctor/modules/exceptions.cpp b/logdoctor/modules/exceptions.cpp index f7ff7bb4..e05b249f 100644 --- a/logdoctor/modules/exceptions.cpp +++ b/logdoctor/modules/exceptions.cpp @@ -6,7 +6,7 @@ #include -DoNotCatchException::DoNotCatchException( const char* msg ) +DoNotCatchException::DoNotCatchException( const std::string& msg ) { std::cerr << "LogDoctor: Exception: " << msg << std::endl; } diff --git a/logdoctor/modules/exceptions.h b/logdoctor/modules/exceptions.h index 719ba36b..2a4227db 100644 --- a/logdoctor/modules/exceptions.h +++ b/logdoctor/modules/exceptions.h @@ -19,7 +19,7 @@ class LogDoctorException {}; struct DoNotCatchException final { - explicit DoNotCatchException( const char* msg ); + explicit DoNotCatchException( const std::string& msg ); };