From 1e8d4a9bbc076a9fae4e1e1e2cfef68dc2fdc734 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 22 Jan 2023 20:53:13 +0100 Subject: [PATCH 01/36] Added Result in Utilities Introduced typedefs for Result's data --- logdoctor/utilities/result.cpp | 56 ++++++++++++++++++++++++++++++++++ logdoctor/utilities/result.h | 51 +++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 logdoctor/utilities/result.cpp create mode 100644 logdoctor/utilities/result.h diff --git a/logdoctor/utilities/result.cpp b/logdoctor/utilities/result.cpp new file mode 100644 index 00000000..3c64d909 --- /dev/null +++ b/logdoctor/utilities/result.cpp @@ -0,0 +1,56 @@ + +#include "result.h" +#include "modules/exceptions.h" + + +template +Result::Result() +{ + this->result = false; +} + +template +Result::Result( const bool ok, const T& data ) +{ + this->result = ok; + this->data = std::move(data); +} + +template +Result::operator bool() +{ + return this->result; +} + +/* +template +const bool Result::isOk() +{ + return this->result == true; +} + +template +const bool Result::isErr() +{ + return this->result == false; +} +*/ + +template +const T& Result::getData() +{ + if ( this->result ) { + return this->data; + } else { + // unexpected operation + throw GenericException( "Result is Err, no data to be returned", true ); + } +} + + +template class Result< stats_dates_t >; // std::unordered_map>>> +template class Result< stats_warn_items_t >; // std::vector>>> +template class Result< stats_speed_items_t >; // std::vector>> +template class Result< stats_day_items_t >; // std::unordered_map> +template class Result< stats_relat_items_t >; // std::vector> +template class Result< stats_count_items_t >; // std::vector> diff --git a/logdoctor/utilities/result.h b/logdoctor/utilities/result.h new file mode 100644 index 00000000..d477c0e3 --- /dev/null +++ b/logdoctor/utilities/result.h @@ -0,0 +1,51 @@ +#ifndef RESULT_H +#define RESULT_H + +#include + +#include +#include +#include + + +//! Result +/*! + Holds the result for an operation and the relative data +*/ +template +class Result +{ +public: + Result(); + Result( const bool ok, const T& data ); + + explicit operator bool(); + + /* + //! Checks if the operation was successful + const bool isOk(); + + //! Checks if the operation has failed + const bool isErr(); + */ + + //! Returns the data + const T& getData(); + +private: + + bool result; + + T data; +}; + + +// data types +typedef std::unordered_map>>> stats_dates_t; +typedef std::vector>>> stats_warn_items_t; +typedef std::vector>> stats_speed_items_t; +typedef std::unordered_map> stats_day_items_t; +typedef std::vector> stats_relat_items_t; +typedef std::vector> stats_count_items_t; + +#endif // RESULT_H From d3e261cbb548077db22c332125cca175fba9bc31 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 22 Jan 2023 20:58:38 +0100 Subject: [PATCH 02/36] Improvements and updates Code improvements. Replaced plain data types with Result's typedefs. --- logdoctor/modules/crapview/crapview.cpp | 78 +++++++++----------- logdoctor/modules/crapview/crapview.h | 13 ++-- logdoctor/modules/crapview/modules/query.cpp | 57 +++++++------- logdoctor/modules/crapview/modules/query.h | 15 ++-- 4 files changed, 79 insertions(+), 84 deletions(-) diff --git a/logdoctor/modules/crapview/crapview.cpp b/logdoctor/modules/crapview/crapview.cpp index 1260135a..fa1af295 100644 --- a/logdoctor/modules/crapview/crapview.cpp +++ b/logdoctor/modules/crapview/crapview.cpp @@ -174,10 +174,13 @@ const QString Crapview::parseTextualFilter( const QString& filter_str ) void Crapview::refreshDates() { - std::tuple>>>> result; + Result result; this->dbQuery.refreshDates( result ); - if ( std::get<0>(result) ) { - this->dates = std::get<1>(result); + if ( result ) { + this->dates.clear(); + // std::unordered_map>>> + // { web_server_id : { year : { month : [ days ] } } } + this->dates = std::move( result.getData() ); } } void Crapview::clearDates() @@ -302,15 +305,16 @@ void Crapview::updateWarn( QTableWidget* table , const QString& web_server ) void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& hour ) { - std::tuple>>>> result; + Result result; this->dbQuery.getWarnCounts( result, web_server, year, month, day, hour ); - if ( std::get<0>(result) ) { - // get data - // { hour : { 10th_minutes : count } } - std::vector>>> &items = std::get<1>(result); + if ( result ) { + // std::vector>>> + // day -> [ hours[ 10th_minutes[ lines[ log_data ] ] ] ] + // hour -> [ 10th_minutes[ minute[ lines[ log_data ] ] ] ] + auto& items = result.getData(); // bars std::vector> sets; @@ -470,8 +474,6 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const // apply the chart to the view chart->setChart( b_chart ); chart->setRenderHint( QPainter::Antialiasing ); - - items.clear(); } } @@ -479,16 +481,16 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& protocol, const QString& method, const QString& uri, const QString& query, const QString& response ) { - std::tuple>>> result; + Result result; this->dbQuery.getSpeedData( result, web_server, year, month, day, protocol, method, uri, query, response ); - if ( std::get<0>(result) ) { - // get data - // { hour : { 10th_minutes : count } } - std::vector>> &items = std::get<1>(result); + if ( result ) { + // std::vector>> + // [ ( epoch_msec, [ log_data ] ) ] + auto& items = result.getData(); // draw the speed chart QLineSeries *line = new QLineSeries(); @@ -619,8 +621,6 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons // add the chart to the view chart->setChart( l_chart ); chart->setRenderHint(QPainter::Antialiasing); - - items.clear(); } } @@ -628,15 +628,16 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& field ) { - std::tuple>> result; + Result result; this->dbQuery.getItemsCount( result, web_server, year, month, day, field ); - if ( std::get<0>(result) ) { - // get data - std::vector> &aux_items = std::get<1>(result); + if ( result ) { + // std::vector> + // [ ( log_item, count ) ] + auto& items = result.getData(); // make the pie QPieSeries *pie = new QPieSeries(); @@ -644,9 +645,9 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons const int max_items=15; int aux, count, oth_count=0; QString item; - for ( int i=0; i( aux_items.at(i) ); - count = std::get<1>( aux_items.at(i) ); + for ( int i=0; i( items.at(i) ); + count = std::get<1>( items.at(i) ); if ( i >= max_items ) { oth_count += count; } else { @@ -655,10 +656,9 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons aux = table->rowCount(); table->insertRow( aux ); table->setItem( aux, 0, new QTableWidgetItem( QString::fromStdString( std::to_string(count) ))); - table->setItem( aux, 1, new QTableWidgetItem( std::get<0>( aux_items.at(i) ) )); + table->setItem( aux, 1, new QTableWidgetItem( std::get<0>( items.at(i) ) )); } table->verticalHeader()->setVisible( false ); - aux_items.clear(); if ( oth_count > 0 ) { pie->append( TR::tr( "Others" ), oth_count ); @@ -683,17 +683,17 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, const QString& to_year, const QString& to_month, const QString& to_day, const QString& field , const QString& filter ) { - std::tuple>> result; + Result result; this->dbQuery.getDaytimeCounts( result, web_server, from_year, from_month, from_day, to_year, to_month, to_day, field, filter ); - if ( std::get<0>(result) ) { - // get data + if ( result ) { + // std::unordered_map> // { hour : { 10th_minutes : count } } - std::unordered_map> &items = std::get<1>(result); + auto& items = result.getData(); // draw the chart QString date; @@ -799,8 +799,6 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t // apply the chart to the view chart->setChart( b_chart ); chart->setRenderHint( QPainter::Antialiasing ); - - items.clear(); } } @@ -809,7 +807,7 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, const QString& to_year, const QString& to_month, const QString& to_day, const QString& field_1, const QString& filter_1, const QString& field_2, const QString& filter_2 ) { bool period = true; - std::tuple>> result; + Result result; if ( from_year == to_year && from_month == to_month && from_day == to_day ) { @@ -830,10 +828,10 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& field_2, filter_2 ); } - if ( std::get<0>(result) ) { - // get data - // { hour : { 10th_minutes : count } } - std::vector> &items = std::get<1>(result); + if ( result ) { + // std::vector> + // [ ( epoch_ms, count ) ] + auto& items = result.getData(); // draw the relational chart QLineSeries *line = new QLineSeries(); @@ -924,8 +922,6 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& // add the chart to the view chart->setChart( a_chart ); chart->setRenderHint(QPainter::Antialiasing); - - items.clear(); } } @@ -1085,10 +1081,6 @@ const bool Crapview::calcGlobals( std::vector>& recu work_list.push_back( QString("%1.%2 %3").arg(f).arg(d).arg(sfx) ); } } - - recurs.clear(); - traf_day.clear(); traf_hour.clear(); - perf_time.clear(); perf_sent.clear(); perf_receiv.clear(); } return result; diff --git a/logdoctor/modules/crapview/crapview.h b/logdoctor/modules/crapview/crapview.h index 93746c1f..cd9fc4c9 100644 --- a/logdoctor/modules/crapview/crapview.h +++ b/logdoctor/modules/crapview/crapview.h @@ -40,21 +40,21 @@ public: //! Parses a filter for a database field with boolean type /*! \param field_str The given filter - \return The resulting filter to apply at the query + \return The resulting filter to apply to the query */ const QString parseBooleanFilter( const QString& filter_str ); //! Parses a filter for a log field with integer type /*! \param field_str The given filter - \return The resulting filter to apply at the query + \return The resulting filter to apply to the query */ const QString parseNumericFilter( const QString& filter_str ); //! Parses a filter for a log field with text type /*! \param field_str The given filter - \return The resulting filter to apply at the query + \return The resulting filter to apply to the query */ const QString parseTextualFilter( const QString& filter_str ); @@ -286,8 +286,9 @@ private: DbQuery dbQuery; // collection of available dates - // { web_server_id : { year : { month_str : [ days ] } } } - std::unordered_map>>> dates; + // db_dates_t = std::unordered_map>>> + // { web_server_id : { year : { month : [ days ] } } } + stats_dates_t dates; // collection of available fields, for tabs which needs them // { tab : [ fields ] } @@ -342,7 +343,7 @@ private: // convert log fields to log fields IDs const QHash LogFields_s2i = { - {QString::fromStdString(this->dbQuery.FIELDS.at( 0)), 0}, + {QString::fromStdString(this->dbQuery.FIELDS.at( 0)), 0}, {QString::fromStdString(this->dbQuery.FIELDS.at(10)), 10}, {QString::fromStdString(this->dbQuery.FIELDS.at(11)), 11}, {QString::fromStdString(this->dbQuery.FIELDS.at(12)), 12}, diff --git a/logdoctor/modules/crapview/modules/query.cpp b/logdoctor/modules/crapview/modules/query.cpp index 83691ab0..c24b2902 100644 --- a/logdoctor/modules/crapview/modules/query.cpp +++ b/logdoctor/modules/crapview/modules/query.cpp @@ -148,11 +148,12 @@ const QString DbQuery::getDbField( const QString& tr_fld ) // get a fresh map of available dates -void DbQuery::refreshDates(std::tuple>>>> &result) +void DbQuery::refreshDates( Result& result ) { bool successful = true; - std::unordered_map>>> dates = { - {11, {}}, {12, {}}, {13, {}} }; + stats_dates_t dates = { // std::unordered_map>>> + {11, {}}, {12, {}}, {13, {}} + }; QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -290,7 +291,7 @@ void DbQuery::refreshDates(std::tuple>>>> &result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& hour_ ) +void DbQuery::getWarnCounts( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& hour_ ) { bool successful = true; - std::vector>>> items; + stats_warn_items_t items; // std::vector>>> QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -487,15 +488,15 @@ void DbQuery::getWarnCounts( std::tuple>>>& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& protocol_f, const QString& method_f, const QString& uri_f, const QString& query_f, const QString& response_f ) +void DbQuery::getSpeedData( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& protocol_f, const QString& method_f, const QString& uri_f, const QString& query_f, const QString& response_f ) { bool successful = true; - std::vector>> data; + stats_speed_items_t data; // std::vector>> QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -764,12 +765,12 @@ void DbQuery::getSpeedData(std::tuple>>& result, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& log_field ) +void DbQuery::getItemsCount( Result& result, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& log_field ) { bool successful = true; QHash aux_items; - std::vector> items; + stats_count_items_t items; // std::vector> QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -943,16 +944,16 @@ void DbQuery::getItemsCount( std::tuple>>& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_, const QString& field_filter ) +void DbQuery::getDaytimeCounts( Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_, const QString& field_filter ) { bool successful = true; - std::unordered_map> data = { + stats_day_items_t data = { // std::unordered_map> {0, {{0,0},{10,0},{20,0},{30,0},{40,0},{50,0}}}, {1, {{0,0},{10,0},{20,0},{30,0},{40,0},{50,0}}}, {2, {{0,0},{10,0},{20,0},{30,0},{40,0},{50,0}}}, {3, {{0,0},{10,0},{20,0},{30,0},{40,0},{50,0}}}, {4, {{0,0},{10,0},{20,0},{30,0},{40,0},{50,0}}}, {5, {{0,0},{10,0},{20,0},{30,0},{40,0},{50,0}}}, @@ -1199,16 +1200,16 @@ void DbQuery::getDaytimeCounts( std::tuple>> &result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) +void DbQuery::getRelationalCountsDay( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) { bool successful = true; - std::vector> data; + stats_relat_items_t data; // std::vector> QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -1448,15 +1449,15 @@ void DbQuery::getRelationalCountsDay(std::tuple>> &result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) +void DbQuery::getRelationalCountsPeriod( Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) { bool successful = true; - std::vector> data; + stats_relat_items_t data; // std::vector> QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -1839,7 +1840,7 @@ void DbQuery::getRelationalCountsPeriod(std::tuple @@ -70,7 +71,7 @@ public: /*! \param result Tuple which will hold the result of the operation and the data */ - void refreshDates( std::tuple>>>>& result ); + void refreshDates( Result& result ); //! Updates the database applying the changes made in the Warnings statistics table @@ -92,7 +93,7 @@ public: \param hour_ The hour */ void getWarnCounts( - std::tuple>>>>& result, + Result& result, const QString& web_server, const QString& year_, const QString& month_, @@ -114,7 +115,7 @@ public: \param response_f The filter for the Response field */ void getSpeedData( - std::tuple>>>& result, + Result& result, const QString& web_server, const QString& year_, const QString& month_, @@ -136,7 +137,7 @@ public: \param log_field The log field */ void getItemsCount( - std::tuple>>& result, + Result& result, const QString& web_server, const QString& year, const QString& month, @@ -158,7 +159,7 @@ public: \param field_filter The filter to apply */ void getDaytimeCounts( - std::tuple>>& result, + Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, @@ -180,7 +181,7 @@ public: \see getRelationalCountsPeriod() */ void getRelationalCountsDay( - std::tuple>>& result, + Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& log_field_1_, const QString& field_filter_1, @@ -204,7 +205,7 @@ public: \see getRelationalCountsDay() */ void getRelationalCountsPeriod( - std::tuple>>& result, + Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, From 7950726553cdc6f0a2131a4e3e0addbff3cd0083 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 22 Jan 2023 20:59:11 +0100 Subject: [PATCH 03/36] Updated CMakeLists.txt --- logdoctor/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/logdoctor/CMakeLists.txt b/logdoctor/CMakeLists.txt index 2688b926..e68a1820 100644 --- a/logdoctor/CMakeLists.txt +++ b/logdoctor/CMakeLists.txt @@ -39,6 +39,8 @@ set(PROJECT_SOURCES utilities/gzip.cpp utilities/io.h utilities/io.cpp + utilities/result.h + utilities/result.cpp utilities/rtf.h utilities/rtf.cpp utilities/strings.h From 79917abe4552fd337bf2fff72f2d90b823bd7475 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 22 Jan 2023 21:01:06 +0100 Subject: [PATCH 04/36] Updated documentation --- docs/html/annotated.html | 25 +++--- docs/html/classCrapview.html | 6 +- docs/html/classDbQuery-members.html | 14 ++-- docs/html/classDbQuery.html | 88 ++++++++++---------- docs/html/classMainWindow-members.html | 2 +- docs/html/classMainWindow.html | 10 +-- docs/html/classResult-members.html | 87 ++++++++++++++++++++ docs/html/classResult.html | 107 +++++++++++++++++++++++++ docs/html/classes.html | 2 +- docs/html/functions_func_g.html | 13 +-- docs/html/functions_func_m.html | 2 +- docs/html/functions_func_r.html | 2 +- docs/html/functions_g.html | 13 +-- docs/html/functions_m.html | 2 +- docs/html/functions_r.html | 2 +- docs/html/functions_x.html | 3 +- docs/html/functions_y.html | 3 +- docs/html/hierarchy.html | 19 ++--- docs/html/search/all_10.js | 15 ++-- docs/html/search/all_16.js | 4 +- docs/html/search/all_17.js | 4 +- docs/html/search/all_6.js | 87 ++++++++++---------- docs/html/search/all_c.js | 2 +- docs/html/search/classes_9.js | 3 +- docs/html/search/functions_10.js | 2 +- docs/html/search/functions_6.js | 85 ++++++++++---------- docs/html/search/functions_c.js | 2 +- 27 files changed, 404 insertions(+), 200 deletions(-) create mode 100644 docs/html/classResult-members.html create mode 100644 docs/html/classResult.html diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 0bbd5828..b2e36b81 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -111,18 +111,19 @@ $(function() {  CLogParserExceptionLogParserException  CMainSliceRepresents a slice  CMainWindowMainWindow - CRichTextRichText - CSHA256 - CSnake - CTile - CSnakeGameSnake - CStoreOpsStoreOps - CStringOpsStringOps - CStyleSecStyleSec - CTextBrowserTextBrowser - CTRTR - CVecOpsVecOps - CWebServerExceptionWebServerException + CResultResult + CRichTextRichText + CSHA256 + CSnake + CTile + CSnakeGameSnake + CStoreOpsStoreOps + CStringOpsStringOps + CStyleSecStyleSec + CTextBrowserTextBrowser + CTRTR + CVecOpsVecOps + CWebServerExceptionWebServerException diff --git a/docs/html/classCrapview.html b/docs/html/classCrapview.html index 53de8983..c3cbc2cc 100644 --- a/docs/html/classCrapview.html +++ b/docs/html/classCrapview.html @@ -1014,7 +1014,7 @@ Private Member Functions -
Returns
The resulting filter to apply at the query
+
Returns
The resulting filter to apply to the query
@@ -1041,7 +1041,7 @@ Private Member Functions -
Returns
The resulting filter to apply at the query
+
Returns
The resulting filter to apply to the query
@@ -1068,7 +1068,7 @@ Private Member Functions -
Returns
The resulting filter to apply at the query
+
Returns
The resulting filter to apply to the query
diff --git a/docs/html/classDbQuery-members.html b/docs/html/classDbQuery-members.html index 8667b0f5..0a0abfa1 100644 --- a/docs/html/classDbQuery-members.html +++ b/docs/html/classDbQuery-members.html @@ -77,19 +77,19 @@ $(function() {

This is the complete list of members for DbQuery, including all inherited members.

- + - + - - - - - + + + + + diff --git a/docs/html/classDbQuery.html b/docs/html/classDbQuery.html index a2e52f8c..0c94e7e3 100644 --- a/docs/html/classDbQuery.html +++ b/docs/html/classDbQuery.html @@ -88,30 +88,30 @@ void  - - - + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -135,8 +135,8 @@ Private Member Functions
getDaytimeCounts(std::tuple< bool, std::unordered_map< int, std::unordered_map< int, int > > > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_, const QString &field_filter)DbQuery
getDaytimeCounts(Result< stats_day_items_t > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_, const QString &field_filter)DbQuery
getDbField(const QString &tr_fld)DbQueryprivate
getGlobalCounts(const QString &web_server, const std::unordered_map< int, std::unordered_map< int, std::vector< int > > > &dates, std::vector< std::unordered_map< QString, int > > &recurs, std::tuple< QString, int > &traf_date, std::unordered_map< int, double > &traf_day, std::unordered_map< int, double > &traf_hour, std::vector< long long > &perf_time, std::vector< long long > &perf_sent, std::vector< long long > &perf_receiv, long &req_count)DbQuery
getItemsCount(std::tuple< bool, std::vector< std::tuple< QString, int > > > &result, const QString &web_server, const QString &year, const QString &month, const QString &day, const QString &log_field)DbQuery
getItemsCount(Result< stats_count_items_t > &result, const QString &web_server, const QString &year, const QString &month, const QString &day, const QString &log_field)DbQuery
getMinuteGap(const int &minute, const int &gap=10)DbQueryprivate
getMonthDays(const int &year, const int &month)DbQueryprivate
getMonthNumber(const QString &month_str)DbQueryprivate
getMonthsCount(const int &from_year, const int &from_month, const int &to_year, const int &to_month)DbQueryprivate
getRelationalCountsDay(std::tuple< bool, std::vector< std::tuple< long long, int > > > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)DbQuery
getRelationalCountsPeriod(std::tuple< bool, std::vector< std::tuple< long long, int > > > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)DbQuery
getSpeedData(std::tuple< bool, std::vector< std::tuple< long long, std::vector< QString > > > > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &protocol_f, const QString &method_f, const QString &uri_f, const QString &query_f, const QString &response_f)DbQuery
getWarnCounts(std::tuple< bool, std::vector< std::vector< std::vector< std::vector< QString > > > > > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &hour_)DbQuery
refreshDates(std::tuple< bool, std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, std::vector< int > > > > > &result)DbQuery
getRelationalCountsDay(Result< stats_relat_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)DbQuery
getRelationalCountsPeriod(Result< stats_relat_items_t > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)DbQuery
getSpeedData(Result< stats_speed_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &protocol_f, const QString &method_f, const QString &uri_f, const QString &query_f, const QString &response_f)DbQuery
getWarnCounts(Result< stats_warn_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &hour_)DbQuery
refreshDates(Result< stats_dates_t > &result)DbQuery
setDbPath(const std::string &path)DbQuery
setDialogLevel(const int &new_level)DbQuery
updateWarnings(const QString &web_server, const std::vector< std::tuple< int, int > > &updates)DbQuery
setDialogLevel (c
void setDbPath (const std::string &path)
 Sets the path for the logs Collection database. More...
 
void refreshDates (std::tuple< bool, std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, std::vector< int > > > > > &result)
 Refreshes the dates which are available in the database. More...
 
void refreshDates (Result< stats_dates_t > &result)
 Refreshes the dates which are available in the database. More...
 
void updateWarnings (const QString &web_server, const std::vector< std::tuple< int, int > > &updates)
 Updates the database applying the changes made in the Warnings statistics table. More...
 
void getWarnCounts (std::tuple< bool, std::vector< std::vector< std::vector< std::vector< QString > > > > > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &hour_)
 Retrieves the data needed for the Warnings statistics. More...
 
void getSpeedData (std::tuple< bool, std::vector< std::tuple< long long, std::vector< QString > > > > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &protocol_f, const QString &method_f, const QString &uri_f, const QString &query_f, const QString &response_f)
 Retrieves the data needed for the Speed statistics. More...
 
void getItemsCount (std::tuple< bool, std::vector< std::tuple< QString, int > > > &result, const QString &web_server, const QString &year, const QString &month, const QString &day, const QString &log_field)
 Retrieves the data needed for the Counts statistics. More...
 
void getDaytimeCounts (std::tuple< bool, std::unordered_map< int, std::unordered_map< int, int > > > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_, const QString &field_filter)
 Retrieves the data needed for the Daytime statistics. More...
 
void getRelationalCountsDay (std::tuple< bool, std::vector< std::tuple< long long, int > > > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)
 Retrieves the data needed for the Relationsl statistics. More...
 
void getRelationalCountsPeriod (std::tuple< bool, std::vector< std::tuple< long long, int > > > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)
 Retrieves the data needed for the Relational statistics. More...
 
void getWarnCounts (Result< stats_warn_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &hour_)
 Retrieves the data needed for the Warnings statistics. More...
 
void getSpeedData (Result< stats_speed_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &protocol_f, const QString &method_f, const QString &uri_f, const QString &query_f, const QString &response_f)
 Retrieves the data needed for the Speed statistics. More...
 
void getItemsCount (Result< stats_count_items_t > &result, const QString &web_server, const QString &year, const QString &month, const QString &day, const QString &log_field)
 Retrieves the data needed for the Counts statistics. More...
 
void getDaytimeCounts (Result< stats_day_items_t > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_, const QString &field_filter)
 Retrieves the data needed for the Daytime statistics. More...
 
void getRelationalCountsDay (Result< stats_relat_items_t > &result, const QString &web_server, const QString &year_, const QString &month_, const QString &day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)
 Retrieves the data needed for the Relationsl statistics. More...
 
void getRelationalCountsPeriod (Result< stats_relat_items_t > &result, const QString &web_server, const QString &from_year_, const QString &from_month_, const QString &from_day_, const QString &to_year_, const QString &to_month_, const QString &to_day_, const QString &log_field_1_, const QString &field_filter_1, const QString &log_field_2_, const QString &field_filter_2)
 Retrieves the data needed for the Relational statistics. More...
 
const bool getGlobalCounts (const QString &web_server, const std::unordered_map< int, std::unordered_map< int, std::vector< int > > > &dates, std::vector< std::unordered_map< QString, int > > &recurs, std::tuple< QString, int > &traf_date, std::unordered_map< int, double > &traf_day, std::unordered_map< int, double > &traf_hour, std::vector< long long > &perf_time, std::vector< long long > &perf_sent, std::vector< long long > &perf_receiv, long &req_count)
 Retrieves the data needed for the Global statistics. More...
 
 

Member Function Documentation

- -

◆ getDaytimeCounts()

+ +

◆ getDaytimeCounts()

@@ -144,7 +144,7 @@ Private Member Functions void DbQuery::getDaytimeCounts ( - std::tuple< bool, std::unordered_map< int, std::unordered_map< int, int > > > &  + Result< stats_day_items_t > &  result, @@ -357,8 +357,8 @@ Private Member Functions
- -

◆ getItemsCount()

+ +

◆ getItemsCount()

@@ -366,7 +366,7 @@ Private Member Functions void DbQuery::getItemsCount ( - std::tuple< bool, std::vector< std::tuple< QString, int > > > &  + Result< stats_count_items_t > &  result, @@ -638,8 +638,8 @@ Private Member Functions
- -

◆ getRelationalCountsDay()

+ +

◆ getRelationalCountsDay()

@@ -647,7 +647,7 @@ Private Member Functions void DbQuery::getRelationalCountsDay ( - std::tuple< bool, std::vector< std::tuple< long long, int > > > &  + Result< stats_relat_items_t > &  result, @@ -721,12 +721,12 @@ Private Member Functions -
See also
getRelationalCountsPeriod()
+
See also
getRelationalCountsPeriod()
- -

◆ getRelationalCountsPeriod()

+ +

◆ getRelationalCountsPeriod()

@@ -734,7 +734,7 @@ Private Member Functions void DbQuery::getRelationalCountsPeriod ( - std::tuple< bool, std::vector< std::tuple< long long, int > > > &  + Result< stats_relat_items_t > &  result, @@ -829,12 +829,12 @@ Private Member Functions -
See also
getRelationalCountsDay()
+
See also
getRelationalCountsDay()
- -

◆ getSpeedData()

+ +

◆ getSpeedData()

@@ -842,7 +842,7 @@ Private Member Functions void DbQuery::getSpeedData ( - std::tuple< bool, std::vector< std::tuple< long long, std::vector< QString > > > > &  + Result< stats_speed_items_t > &  result, @@ -926,8 +926,8 @@ Private Member Functions
- -

◆ getWarnCounts()

+ +

◆ getWarnCounts()

@@ -935,7 +935,7 @@ Private Member Functions void DbQuery::getWarnCounts ( - std::tuple< bool, std::vector< std::vector< std::vector< std::vector< QString > > > > > &  + Result< stats_warn_items_t > &  result, @@ -991,8 +991,8 @@ Private Member Functions
- -

◆ refreshDates()

+ +

◆ refreshDates()

@@ -1000,7 +1000,7 @@ Private Member Functions void DbQuery::refreshDates ( - std::tuple< bool, std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, std::vector< int > > > > > &  + Result< stats_dates_t > &  result) diff --git a/docs/html/classMainWindow-members.html b/docs/html/classMainWindow-members.html index e8cea435..f225e841 100644 --- a/docs/html/classMainWindow-members.html +++ b/docs/html/classMainWindow-members.html @@ -88,7 +88,7 @@ $(function() { geometryToString()MainWindowprivate list2string(const std::vector< std::string > &list, const bool &user_agent=false)MainWindowprivate makeInitialChecks()MainWindowprivate - menu_actionEnglish_triggered()MainWindowprivateslot + menu_actionEnglishGb_triggered()MainWindowprivateslot printableSize(const int &bytes)MainWindowprivate printableSpeed(const int &bytes, const int &secs)MainWindowprivate printableTime(const int &seconds)MainWindowprivate diff --git a/docs/html/classMainWindow.html b/docs/html/classMainWindow.html index 4c0fbeab..c10f99c9 100644 --- a/docs/html/classMainWindow.html +++ b/docs/html/classMainWindow.html @@ -92,8 +92,8 @@ Inheritance diagram for MainWindow:
- - + +

Private Slots

void menu_actionEnglish_triggered ()
 
void menu_actionEnglishGb_triggered ()
 
@@ -297,8 +297,8 @@ void  - - - - - - - - - + + + + + + + + + +

Private Member Functions

craplogFinished ( - -

◆ menu_actionEnglish_triggered

+ +

◆ menu_actionEnglishGb_triggered

@@ -307,7 +307,7 @@ void 
craplogFinished ( - + diff --git a/docs/html/classResult-members.html b/docs/html/classResult-members.html new file mode 100644 index 00000000..3d0fed55 --- /dev/null +++ b/docs/html/classResult-members.html @@ -0,0 +1,87 @@ + + + + + + + +LogDoctor: Member List + + + + + + + + + +
+
+
void MainWindow::menu_actionEnglish_triggered void MainWindow::menu_actionEnglishGb_triggered ( )
+ + + + + + +
+
LogDoctor 2.00 +
+
Parse Apache2/Nginx/IIS logs and create statistics
+
+ + + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
Result< T > Member List
+
+
+ +

This is the complete list of members for Result< T >, including all inherited members.

+ + +
getData()Result< T >
+ + + + diff --git a/docs/html/classResult.html b/docs/html/classResult.html new file mode 100644 index 00000000..0fe75f09 --- /dev/null +++ b/docs/html/classResult.html @@ -0,0 +1,107 @@ + + + + + + + +LogDoctor: Result< T > Class Template Reference + + + + + + + + + +
+
+ + + + + + + +
+
LogDoctor 2.00 +
+
Parse Apache2/Nginx/IIS logs and create statistics
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
+ +
Result< T > Class Template Reference
+
+
+ +

Result. + More...

+ +

#include <result.h>

+ + + + + +

+Public Member Functions

+const T & getData ()
 Returns the data.
 
+

Detailed Description

+
template<typename T>
+class Result< T >

Result.

+

Holds the result for an operation and the relative data

+

The documentation for this class was generated from the following files:
    +
  • logdoctor/utilities/result.h
  • +
  • logdoctor/utilities/result.cpp
  • +
+
+ + + + diff --git a/docs/html/classes.html b/docs/html/classes.html index c7c1f3c6..382f6ab1 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -105,7 +105,7 @@ $(function() {
MainSlice
MainWindow
R
-
RichText
+
Result
RichText
S
SHA256
Snake
SnakeGame
StoreOps
StringOps
StyleSec
diff --git a/docs/html/functions_func_g.html b/docs/html/functions_func_g.html index e2ed3922..8a829c75 100644 --- a/docs/html/functions_func_g.html +++ b/docs/html/functions_func_g.html @@ -85,8 +85,9 @@ $(function() {
  • getColorSchemes() : ColorSec
  • getCurrentLogFormat() : Craplog
  • getCurrentWSID() : Craplog
  • +
  • getData() : Result< T >
  • getDays() : Crapview
  • -
  • getDaytimeCounts() : DbQuery
  • +
  • getDaytimeCounts() : DbQuery
  • getDbField() : DbQuery
  • getDialogsLevel() : Craplog, Crapview
  • getFields() : Crapview
  • @@ -96,7 +97,7 @@ $(function() {
  • getHashesDatabasePath() : Craplog
  • getHours() : Crapview
  • getIisLogSample() : FormatOps
  • -
  • getItemsCount() : DbQuery
  • +
  • getItemsCount() : DbQuery
  • getLogFieldID() : Crapview
  • getLogFieldString() : Crapview
  • getLogFileItem() : Craplog
  • @@ -115,13 +116,13 @@ $(function() {
  • getParsedLines() : Craplog, LogOps
  • getParsedSize() : LogOps
  • getPerfSize() : Craplog
  • -
  • getRelationalCountsDay() : DbQuery
  • -
  • getRelationalCountsPeriod() : DbQuery
  • -
  • getSpeedData() : DbQuery
  • +
  • getRelationalCountsDay() : DbQuery
  • +
  • getRelationalCountsPeriod() : DbQuery
  • +
  • getSpeedData() : DbQuery
  • getStatsDatabasePath() : Craplog
  • getStyleSheet() : StyleSec
  • getTotalSize() : Craplog, LogOps
  • -
  • getWarnCounts() : DbQuery
  • +
  • getWarnCounts() : DbQuery
  • getWarningSize() : Craplog
  • getWarnlist() : Craplog
  • getWideLinesUsage() : TextBrowser
  • diff --git a/docs/html/functions_func_m.html b/docs/html/functions_func_m.html index 1ea354c4..5f058b00 100644 --- a/docs/html/functions_func_m.html +++ b/docs/html/functions_func_m.html @@ -79,7 +79,7 @@ $(function() {
  • makeInitialChecks() : MainWindow
  • makePreview() : TextBrowser
  • makeStyleSheet() : StyleSec
  • -
  • menu_actionEnglish_triggered() : MainWindow
  • +
  • menu_actionEnglishGb_triggered() : MainWindow
  • move() : Food
  • msgDatabaseCreated() : DialogSec
  • diff --git a/docs/html/functions_func_r.html b/docs/html/functions_func_r.html index 708ee848..acfd00d8 100644 --- a/docs/html/functions_func_r.html +++ b/docs/html/functions_func_r.html @@ -78,7 +78,7 @@ $(function() {
  • readConfigs() : MainWindow
  • readFile() : GZutils, IOutils
  • recalculateAngles() : DonutBreakdown
  • -
  • refreshDates() : Crapview, DbQuery
  • +
  • refreshDates() : Crapview, DbQuery
  • refreshStatsDates() : MainWindow
  • renameAsCopy() : IOutils
  • replace() : StringOps
  • diff --git a/docs/html/functions_g.html b/docs/html/functions_g.html index 7609031c..adcaa6d7 100644 --- a/docs/html/functions_g.html +++ b/docs/html/functions_g.html @@ -86,8 +86,9 @@ $(function() {
  • getColorSchemes() : ColorSec
  • getCurrentLogFormat() : Craplog
  • getCurrentWSID() : Craplog
  • +
  • getData() : Result< T >
  • getDays() : Crapview
  • -
  • getDaytimeCounts() : DbQuery
  • +
  • getDaytimeCounts() : DbQuery
  • getDbField() : DbQuery
  • getDialogsLevel() : Craplog, Crapview
  • getFields() : Crapview
  • @@ -97,7 +98,7 @@ $(function() {
  • getHashesDatabasePath() : Craplog
  • getHours() : Crapview
  • getIisLogSample() : FormatOps
  • -
  • getItemsCount() : DbQuery
  • +
  • getItemsCount() : DbQuery
  • getLogFieldID() : Crapview
  • getLogFieldString() : Crapview
  • getLogFileItem() : Craplog
  • @@ -116,13 +117,13 @@ $(function() {
  • getParsedLines() : Craplog, LogOps
  • getParsedSize() : LogOps
  • getPerfSize() : Craplog
  • -
  • getRelationalCountsDay() : DbQuery
  • -
  • getRelationalCountsPeriod() : DbQuery
  • -
  • getSpeedData() : DbQuery
  • +
  • getRelationalCountsDay() : DbQuery
  • +
  • getRelationalCountsPeriod() : DbQuery
  • +
  • getSpeedData() : DbQuery
  • getStatsDatabasePath() : Craplog
  • getStyleSheet() : StyleSec
  • getTotalSize() : Craplog, LogOps
  • -
  • getWarnCounts() : DbQuery
  • +
  • getWarnCounts() : DbQuery
  • getWarningSize() : Craplog
  • getWarnlist() : Craplog
  • getWideLinesUsage() : TextBrowser
  • diff --git a/docs/html/functions_m.html b/docs/html/functions_m.html index 225ceede..7b5156db 100644 --- a/docs/html/functions_m.html +++ b/docs/html/functions_m.html @@ -80,7 +80,7 @@ $(function() {
  • makePreview() : TextBrowser
  • makeStyleSheet() : StyleSec
  • MAX_SNAKE_LENGTH : SnakeGame
  • -
  • menu_actionEnglish_triggered() : MainWindow
  • +
  • menu_actionEnglishGb_triggered() : MainWindow
  • movable : Food
  • move() : Food
  • msgDatabaseCreated() : DialogSec
  • diff --git a/docs/html/functions_r.html b/docs/html/functions_r.html index 39ca357e..f487d15d 100644 --- a/docs/html/functions_r.html +++ b/docs/html/functions_r.html @@ -78,7 +78,7 @@ $(function() {
  • readConfigs() : MainWindow
  • readFile() : GZutils, IOutils
  • recalculateAngles() : DonutBreakdown
  • -
  • refreshDates() : Crapview, DbQuery
  • +
  • refreshDates() : Crapview, DbQuery
  • refreshStatsDates() : MainWindow
  • renameAsCopy() : IOutils
  • replace() : StringOps
  • diff --git a/docs/html/functions_x.html b/docs/html/functions_x.html index 8e927b67..afe45d93 100644 --- a/docs/html/functions_x.html +++ b/docs/html/functions_x.html @@ -74,8 +74,9 @@ $(function() {
    Here is a list of all documented class members with links to the class documentation for each member:

    - x -

    diff --git a/docs/html/functions_y.html b/docs/html/functions_y.html index 0bfa5106..f5b35f1a 100644 --- a/docs/html/functions_y.html +++ b/docs/html/functions_y.html @@ -74,8 +74,9 @@ $(function() {
    Here is a list of all documented class members with links to the class documentation for each member:

    - y -

    diff --git a/docs/html/hierarchy.html b/docs/html/hierarchy.html index 1fab20d3..2a99a420 100644 --- a/docs/html/hierarchy.html +++ b/docs/html/hierarchy.html @@ -122,15 +122,16 @@ $(function() {
     CCrapupCrapup
     CCrissCrossCrissCross
     CSnakeGameSnake
     CSHA256
     CStoreOpsStoreOps
     CStringOpsStringOps
     CStyleSecStyleSec
     CTextBrowserTextBrowser
     CSnake::Tile
     CVecOps< T >VecOps
     Cstd::vector
     CSnake
     CResult< T >Result
     CSHA256
     CStoreOpsStoreOps
     CStringOpsStringOps
     CStyleSecStyleSec
     CTextBrowserTextBrowser
     CSnake::Tile
     CVecOps< T >VecOps
     Cstd::vector
     CSnake
    diff --git a/docs/html/search/all_10.js b/docs/html/search/all_10.js index 2a29594b..74a24bdb 100644 --- a/docs/html/search/all_10.js +++ b/docs/html/search/all_10.js @@ -4,17 +4,18 @@ var searchData= ['readconfigs_1',['readConfigs',['../classMainWindow.html#aae306cbf256c5a686cc8d9f2a1dbb18b',1,'MainWindow']]], ['readfile_2',['readFile',['../classGZutils.html#a72f6960bddea2b816af84e7773d5c6b2',1,'GZutils::readFile()'],['../classIOutils.html#a185c38eff9d9f4432c8138404941915e',1,'IOutils::readFile()']]], ['recalculateangles_3',['recalculateAngles',['../classDonutBreakdown.html#acd747ee2bbd23ce84eaf9d4db57938e3',1,'DonutBreakdown']]], - ['refreshdates_4',['refreshDates',['../classCrapview.html#ac98b1cbc75604b5145b5cff36e96eb78',1,'Crapview::refreshDates()'],['../classDbQuery.html#af0b44989b67b5735e7ca93a17a250eb3',1,'DbQuery::refreshDates()']]], + ['refreshdates_4',['refreshDates',['../classCrapview.html#ac98b1cbc75604b5145b5cff36e96eb78',1,'Crapview::refreshDates()'],['../classDbQuery.html#a666a5e656764c18907affcd169988212',1,'DbQuery::refreshDates()']]], ['refreshstatsdates_5',['refreshStatsDates',['../classMainWindow.html#ac8f4c84b43d14b6dcc6cb7b5f75ce343',1,'MainWindow']]], ['renameascopy_6',['renameAsCopy',['../classIOutils.html#a8fc152ae29702c3760a4f519ceb0b62a',1,'IOutils']]], ['replace_7',['replace',['../classStringOps.html#a9b073c9a47d2af00d33f1f5b05c167ad',1,'StringOps']]], ['requesttimeout_8',['requestTimeout',['../classCrapup.html#afe79a787fc0820afbc4573ca7091d880',1,'Crapup']]], ['resetperfdata_9',['resetPerfData',['../classLogOps.html#a811fb8fd3c84f4980c9044c16909457f',1,'LogOps']]], ['resolvepath_10',['resolvePath',['../classMainWindow.html#a0ef3bd8e892ddb8a70696c56e35bd79e',1,'MainWindow']]], - ['richlogsdefault_11',['richLogsDefault',['../classRichText.html#a28bf0bdd659cc7b7a58eab9e5cfad495',1,'RichText']]], - ['richlogsfailure_12',['richLogsFailure',['../classRichText.html#a6e5fe6270e6fed0b9e7c42eafc9b4732',1,'RichText']]], - ['richtext_13',['RichText',['../classRichText.html',1,'']]], - ['rotateimg_14',['rotateImg',['../classCrapup.html#a334624ab394fd773b0e6063e7baf7960',1,'Crapup']]], - ['rstrip_15',['rstrip',['../classStringOps.html#a698efee881c6b05439f4fb5016c6c92e',1,'StringOps']]], - ['run_16',['run',['../classCraplog.html#a9c3081cf6cf94b454a87a4d71de3003d',1,'Craplog']]] + ['result_11',['Result',['../classResult.html',1,'']]], + ['richlogsdefault_12',['richLogsDefault',['../classRichText.html#a28bf0bdd659cc7b7a58eab9e5cfad495',1,'RichText']]], + ['richlogsfailure_13',['richLogsFailure',['../classRichText.html#a6e5fe6270e6fed0b9e7c42eafc9b4732',1,'RichText']]], + ['richtext_14',['RichText',['../classRichText.html',1,'']]], + ['rotateimg_15',['rotateImg',['../classCrapup.html#a334624ab394fd773b0e6063e7baf7960',1,'Crapup']]], + ['rstrip_16',['rstrip',['../classStringOps.html#a698efee881c6b05439f4fb5016c6c92e',1,'StringOps']]], + ['run_17',['run',['../classCraplog.html#a9c3081cf6cf94b454a87a4d71de3003d',1,'Craplog']]] ]; diff --git a/docs/html/search/all_16.js b/docs/html/search/all_16.js index a8025930..de3f9a30 100644 --- a/docs/html/search/all_16.js +++ b/docs/html/search/all_16.js @@ -1,5 +1,5 @@ var searchData= [ - ['x_0',['x',['../classFood.html#a327d5731323aa500756f0b56a88e6bb5',1,'Food::x()'],['../structBodyPart.html#ad028f53499627e8fed0cc33b9464949b',1,'BodyPart::x()']]], - ['x_1',['X',['../classFood.html#ad31c5ac2518540d64c10143938fe8eb5',1,'Food']]] + ['x_0',['X',['../classFood.html#ad31c5ac2518540d64c10143938fe8eb5',1,'Food']]], + ['x_1',['x',['../classFood.html#a327d5731323aa500756f0b56a88e6bb5',1,'Food::x()'],['../structBodyPart.html#ad028f53499627e8fed0cc33b9464949b',1,'BodyPart::x()']]] ]; diff --git a/docs/html/search/all_17.js b/docs/html/search/all_17.js index 4178afb4..65f7f531 100644 --- a/docs/html/search/all_17.js +++ b/docs/html/search/all_17.js @@ -1,5 +1,5 @@ var searchData= [ - ['y_0',['y',['../classFood.html#a5dcfa7ef89ddcf8fd089ef99e7d6044f',1,'Food::y()'],['../structBodyPart.html#aa6c8fd72d59c9d20fa1943eac0ca8074',1,'BodyPart::y()']]], - ['y_1',['Y',['../classFood.html#a26a6873b59ce15c8cc7566338e4ee4ab',1,'Food']]] + ['y_0',['Y',['../classFood.html#a26a6873b59ce15c8cc7566338e4ee4ab',1,'Food']]], + ['y_1',['y',['../classFood.html#a5dcfa7ef89ddcf8fd089ef99e7d6044f',1,'Food::y()'],['../structBodyPart.html#aa6c8fd72d59c9d20fa1943eac0ca8074',1,'BodyPart::y()']]] ]; diff --git a/docs/html/search/all_6.js b/docs/html/search/all_6.js index a0582931..47a5a81d 100644 --- a/docs/html/search/all_6.js +++ b/docs/html/search/all_6.js @@ -14,47 +14,48 @@ var searchData= ['getcolorschemes_11',['getColorSchemes',['../classColorSec.html#a4ad467469ba6b81fd0827f73ac53b6f8',1,'ColorSec']]], ['getcurrentlogformat_12',['getCurrentLogFormat',['../classCraplog.html#a9d289b49aedb0fbc2ce02bd805a1a65c',1,'Craplog']]], ['getcurrentwsid_13',['getCurrentWSID',['../classCraplog.html#a9a49a14e50120682a342ea3ba63947a5',1,'Craplog']]], - ['getdays_14',['getDays',['../classCrapview.html#ad03099fd23d33fbd0f7ef5fcc1c67bde',1,'Crapview']]], - ['getdaytimecounts_15',['getDaytimeCounts',['../classDbQuery.html#a31937b71d3088a7cb84a522e85cc86f1',1,'DbQuery']]], - ['getdbfield_16',['getDbField',['../classDbQuery.html#a17b84cf6ad72726387256e5c6288e93c',1,'DbQuery']]], - ['getdialogslevel_17',['getDialogsLevel',['../classCraplog.html#a955b8b094062a6e2ee89cf884dd7b028',1,'Craplog::getDialogsLevel()'],['../classCrapview.html#a9c117a07b9eb26532156e82d7852725b',1,'Crapview::getDialogsLevel()']]], - ['getfields_18',['getFields',['../classCrapview.html#a9b565e2994fc2f5c7379898fb39c7f15',1,'Crapview']]], - ['getfont_19',['getFont',['../classTextBrowser.html#aef0e5e3fb14ca9b48c1d668aebc33b33',1,'TextBrowser']]], - ['getfontfamily_20',['getFontFamily',['../classTextBrowser.html#ab7ad4bfc3ef92bd938e00dc438559c0b',1,'TextBrowser']]], - ['getglobalcounts_21',['getGlobalCounts',['../classDbQuery.html#ae504836c92d55d421d5e34b145b2065b',1,'DbQuery']]], - ['gethashesdatabasepath_22',['getHashesDatabasePath',['../classCraplog.html#a2b66000f63d8ab34e894b90fe3496e43',1,'Craplog']]], - ['gethours_23',['getHours',['../classCrapview.html#ad6eb1887779aaa5f7c2aa95911e832b8',1,'Crapview']]], - ['getiislogsample_24',['getIisLogSample',['../classFormatOps.html#a1fe9ff3f875e96c0866622f1a60f29b5',1,'FormatOps']]], - ['getitemscount_25',['getItemsCount',['../classDbQuery.html#a47744cc993d6a4bada0a8aec992a2c23',1,'DbQuery']]], - ['getlogfieldid_26',['getLogFieldID',['../classCrapview.html#a2907f88ba82158c8c58f54383b4a7c2a',1,'Crapview']]], - ['getlogfieldstring_27',['getLogFieldString',['../classCrapview.html#ab4aa28144e1d1a8f7954e0a3c6d3f9d1',1,'Crapview']]], - ['getlogfileitem_28',['getLogFileItem',['../classCraplog.html#a8fc3affaf8da7695390877c63b5b6051',1,'Craplog']]], - ['getlogsformat_29',['getLogsFormat',['../classCraplog.html#a946a0f980c91d713bd01cca8e822616d',1,'Craplog']]], - ['getlogsformatsample_30',['getLogsFormatSample',['../classCraplog.html#ae772867818dcfac15eba8f94da7f0493',1,'Craplog']]], - ['getlogsformatstring_31',['getLogsFormatString',['../classCraplog.html#a159ff9779d1ff85c8ecc6cb63274d494',1,'Craplog']]], - ['getlogslist_32',['getLogsList',['../classCraplog.html#aa0c1078272a2c9c88e51da32c2cbf269',1,'Craplog']]], - ['getlogslistsize_33',['getLogsListSize',['../classCraplog.html#affcd5025487fb60f89d7a35c3c807454',1,'Craplog']]], - ['getlogspath_34',['getLogsPath',['../classCraplog.html#aefd29a191a45be88d34dcfadab076f6d',1,'Craplog']]], - ['getminutegap_35',['getMinuteGap',['../classDbQuery.html#ae172c2f717f939daa41c5a0681ca76c3',1,'DbQuery']]], - ['getmonthdays_36',['getMonthDays',['../classDbQuery.html#a3dcefca533b85ef4e4f8fc12bd380d3e',1,'DbQuery']]], - ['getmonthnumber_37',['getMonthNumber',['../classCrapview.html#af156af64d1cb47d1c0fe1bacc3745974',1,'Crapview::getMonthNumber()'],['../classDbQuery.html#a3254d6cbe61c890ebc6b9d97367256dd',1,'DbQuery::getMonthNumber()']]], - ['getmonths_38',['getMonths',['../classCrapview.html#aa8518f26e3769580bbd3439e094b221a',1,'Crapview']]], - ['getmonthscount_39',['getMonthsCount',['../classDbQuery.html#a2fd212eaa2c82188ffc469fa5737792b',1,'DbQuery']]], - ['getnginxlogsample_40',['getNginxLogSample',['../classFormatOps.html#a46cc3ff63986ec4437c20ccbd68569c2',1,'FormatOps']]], - ['getparsedlines_41',['getParsedLines',['../classLogOps.html#a239ed1c9dca8cbf31f8e7c3fe52c1be1',1,'LogOps::getParsedLines()'],['../classCraplog.html#ae933a2f390dc08664b2ea07acd0b1c39',1,'Craplog::getParsedLines()']]], - ['getparsedsize_42',['getParsedSize',['../classLogOps.html#a06ce568d05b595728093dd2458608f41',1,'LogOps']]], - ['getperfsize_43',['getPerfSize',['../classCraplog.html#a556449b0a92e4bea1e444faca663abd5',1,'Craplog']]], - ['getrelationalcountsday_44',['getRelationalCountsDay',['../classDbQuery.html#aa1691a2878a4a6821afdaf155251ec0b',1,'DbQuery']]], - ['getrelationalcountsperiod_45',['getRelationalCountsPeriod',['../classDbQuery.html#acae142053967818896367a61e808533c',1,'DbQuery']]], - ['getspeeddata_46',['getSpeedData',['../classDbQuery.html#a3aa22b5075bf5607d986d641668af1ea',1,'DbQuery']]], - ['getstatsdatabasepath_47',['getStatsDatabasePath',['../classCraplog.html#a1f08bdd3ce8f969684cfb2acccb3a8aa',1,'Craplog']]], - ['getstylesheet_48',['getStyleSheet',['../classStyleSec.html#ac0781d686293b84e935bd29fe5283b14',1,'StyleSec']]], - ['gettotalsize_49',['getTotalSize',['../classCraplog.html#a92dd0b6330bdc32c908e688b7eced812',1,'Craplog::getTotalSize()'],['../classLogOps.html#a669727346faca20c48fe8f00e3c906ec',1,'LogOps::getTotalSize()']]], - ['getwarncounts_50',['getWarnCounts',['../classDbQuery.html#a2fc983abeeec05d04a110a29f80c4009',1,'DbQuery']]], - ['getwarningsize_51',['getWarningSize',['../classCraplog.html#af79d254595263448fead944f82db8931',1,'Craplog']]], - ['getwarnlist_52',['getWarnlist',['../classCraplog.html#a53df5cc15fdc79c1708aaf002c2f7719',1,'Craplog']]], - ['getwidelinesusage_53',['getWideLinesUsage',['../classTextBrowser.html#a7a62dfd67e7a58f374951272ac13defd',1,'TextBrowser']]], - ['getyears_54',['getYears',['../classCrapview.html#ab3081c678b102b255fa9f32a8f94e052',1,'Crapview']]], - ['grow_55',['grow',['../classSnake.html#a524fb8b522e917f620cfb401f2badabe',1,'Snake']]], - ['gzutils_56',['GZutils',['../classGZutils.html',1,'']]] + ['getdata_14',['getData',['../classResult.html#a5de904d7791ed47839f47db2b6893957',1,'Result']]], + ['getdays_15',['getDays',['../classCrapview.html#ad03099fd23d33fbd0f7ef5fcc1c67bde',1,'Crapview']]], + ['getdaytimecounts_16',['getDaytimeCounts',['../classDbQuery.html#a78bce23f02038060ba4812534a1c4317',1,'DbQuery']]], + ['getdbfield_17',['getDbField',['../classDbQuery.html#a17b84cf6ad72726387256e5c6288e93c',1,'DbQuery']]], + ['getdialogslevel_18',['getDialogsLevel',['../classCraplog.html#a955b8b094062a6e2ee89cf884dd7b028',1,'Craplog::getDialogsLevel()'],['../classCrapview.html#a9c117a07b9eb26532156e82d7852725b',1,'Crapview::getDialogsLevel()']]], + ['getfields_19',['getFields',['../classCrapview.html#a9b565e2994fc2f5c7379898fb39c7f15',1,'Crapview']]], + ['getfont_20',['getFont',['../classTextBrowser.html#aef0e5e3fb14ca9b48c1d668aebc33b33',1,'TextBrowser']]], + ['getfontfamily_21',['getFontFamily',['../classTextBrowser.html#ab7ad4bfc3ef92bd938e00dc438559c0b',1,'TextBrowser']]], + ['getglobalcounts_22',['getGlobalCounts',['../classDbQuery.html#ae504836c92d55d421d5e34b145b2065b',1,'DbQuery']]], + ['gethashesdatabasepath_23',['getHashesDatabasePath',['../classCraplog.html#a2b66000f63d8ab34e894b90fe3496e43',1,'Craplog']]], + ['gethours_24',['getHours',['../classCrapview.html#ad6eb1887779aaa5f7c2aa95911e832b8',1,'Crapview']]], + ['getiislogsample_25',['getIisLogSample',['../classFormatOps.html#a1fe9ff3f875e96c0866622f1a60f29b5',1,'FormatOps']]], + ['getitemscount_26',['getItemsCount',['../classDbQuery.html#a34c32e81025f4c767cdf2ec6b4ab3bde',1,'DbQuery']]], + ['getlogfieldid_27',['getLogFieldID',['../classCrapview.html#a2907f88ba82158c8c58f54383b4a7c2a',1,'Crapview']]], + ['getlogfieldstring_28',['getLogFieldString',['../classCrapview.html#ab4aa28144e1d1a8f7954e0a3c6d3f9d1',1,'Crapview']]], + ['getlogfileitem_29',['getLogFileItem',['../classCraplog.html#a8fc3affaf8da7695390877c63b5b6051',1,'Craplog']]], + ['getlogsformat_30',['getLogsFormat',['../classCraplog.html#a946a0f980c91d713bd01cca8e822616d',1,'Craplog']]], + ['getlogsformatsample_31',['getLogsFormatSample',['../classCraplog.html#ae772867818dcfac15eba8f94da7f0493',1,'Craplog']]], + ['getlogsformatstring_32',['getLogsFormatString',['../classCraplog.html#a159ff9779d1ff85c8ecc6cb63274d494',1,'Craplog']]], + ['getlogslist_33',['getLogsList',['../classCraplog.html#aa0c1078272a2c9c88e51da32c2cbf269',1,'Craplog']]], + ['getlogslistsize_34',['getLogsListSize',['../classCraplog.html#affcd5025487fb60f89d7a35c3c807454',1,'Craplog']]], + ['getlogspath_35',['getLogsPath',['../classCraplog.html#aefd29a191a45be88d34dcfadab076f6d',1,'Craplog']]], + ['getminutegap_36',['getMinuteGap',['../classDbQuery.html#ae172c2f717f939daa41c5a0681ca76c3',1,'DbQuery']]], + ['getmonthdays_37',['getMonthDays',['../classDbQuery.html#a3dcefca533b85ef4e4f8fc12bd380d3e',1,'DbQuery']]], + ['getmonthnumber_38',['getMonthNumber',['../classCrapview.html#af156af64d1cb47d1c0fe1bacc3745974',1,'Crapview::getMonthNumber()'],['../classDbQuery.html#a3254d6cbe61c890ebc6b9d97367256dd',1,'DbQuery::getMonthNumber()']]], + ['getmonths_39',['getMonths',['../classCrapview.html#aa8518f26e3769580bbd3439e094b221a',1,'Crapview']]], + ['getmonthscount_40',['getMonthsCount',['../classDbQuery.html#a2fd212eaa2c82188ffc469fa5737792b',1,'DbQuery']]], + ['getnginxlogsample_41',['getNginxLogSample',['../classFormatOps.html#a46cc3ff63986ec4437c20ccbd68569c2',1,'FormatOps']]], + ['getparsedlines_42',['getParsedLines',['../classLogOps.html#a239ed1c9dca8cbf31f8e7c3fe52c1be1',1,'LogOps::getParsedLines()'],['../classCraplog.html#ae933a2f390dc08664b2ea07acd0b1c39',1,'Craplog::getParsedLines()']]], + ['getparsedsize_43',['getParsedSize',['../classLogOps.html#a06ce568d05b595728093dd2458608f41',1,'LogOps']]], + ['getperfsize_44',['getPerfSize',['../classCraplog.html#a556449b0a92e4bea1e444faca663abd5',1,'Craplog']]], + ['getrelationalcountsday_45',['getRelationalCountsDay',['../classDbQuery.html#a09f4401f27bf9ed27eb50cb6b4cbbedf',1,'DbQuery']]], + ['getrelationalcountsperiod_46',['getRelationalCountsPeriod',['../classDbQuery.html#a6dd70dbc8dd0a4f79aa066fb4ef93ee8',1,'DbQuery']]], + ['getspeeddata_47',['getSpeedData',['../classDbQuery.html#a6a1c4fddcdc6580da653bf2ad81d7558',1,'DbQuery']]], + ['getstatsdatabasepath_48',['getStatsDatabasePath',['../classCraplog.html#a1f08bdd3ce8f969684cfb2acccb3a8aa',1,'Craplog']]], + ['getstylesheet_49',['getStyleSheet',['../classStyleSec.html#ac0781d686293b84e935bd29fe5283b14',1,'StyleSec']]], + ['gettotalsize_50',['getTotalSize',['../classCraplog.html#a92dd0b6330bdc32c908e688b7eced812',1,'Craplog::getTotalSize()'],['../classLogOps.html#a669727346faca20c48fe8f00e3c906ec',1,'LogOps::getTotalSize()']]], + ['getwarncounts_51',['getWarnCounts',['../classDbQuery.html#aa3f8d1cdf799287f5aaeb4ae0e848393',1,'DbQuery']]], + ['getwarningsize_52',['getWarningSize',['../classCraplog.html#af79d254595263448fead944f82db8931',1,'Craplog']]], + ['getwarnlist_53',['getWarnlist',['../classCraplog.html#a53df5cc15fdc79c1708aaf002c2f7719',1,'Craplog']]], + ['getwidelinesusage_54',['getWideLinesUsage',['../classTextBrowser.html#a7a62dfd67e7a58f374951272ac13defd',1,'TextBrowser']]], + ['getyears_55',['getYears',['../classCrapview.html#ab3081c678b102b255fa9f32a8f94e052',1,'Crapview']]], + ['grow_56',['grow',['../classSnake.html#a524fb8b522e917f620cfb401f2badabe',1,'Snake']]], + ['gzutils_57',['GZutils',['../classGZutils.html',1,'']]] ]; diff --git a/docs/html/search/all_c.js b/docs/html/search/all_c.js index edd2a347..3565750b 100644 --- a/docs/html/search/all_c.js +++ b/docs/html/search/all_c.js @@ -8,7 +8,7 @@ var searchData= ['makepreview_5',['makePreview',['../classTextBrowser.html#a5b0eb8070202317c6e04534ca417c957',1,'TextBrowser']]], ['makestylesheet_6',['makeStyleSheet',['../classStyleSec.html#a7deedd8236a76bdb8ba050e1fb797f11',1,'StyleSec']]], ['max_5fsnake_5flength_7',['MAX_SNAKE_LENGTH',['../classSnakeGame.html#a3c6ebe785fb19d17383ea874819cc887',1,'SnakeGame']]], - ['menu_5factionenglish_5ftriggered_8',['menu_actionEnglish_triggered',['../classMainWindow.html#adffe78de926642168d16bfd8a2522c29',1,'MainWindow']]], + ['menu_5factionenglishgb_5ftriggered_8',['menu_actionEnglishGb_triggered',['../classMainWindow.html#a42ea06a6c166e5c8243944d4e5159514',1,'MainWindow']]], ['movable_9',['movable',['../classFood.html#ab4ab28e75609c4872fc47563909c4c61',1,'Food']]], ['move_10',['move',['../classFood.html#a7196aa14ad843820518dc9db03252d21',1,'Food']]], ['msgdatabasecreated_11',['msgDatabaseCreated',['../classDialogSec.html#ae916458257088da13a1a2bc885d5c71d',1,'DialogSec']]] diff --git a/docs/html/search/classes_9.js b/docs/html/search/classes_9.js index 6546caa9..992899ed 100644 --- a/docs/html/search/classes_9.js +++ b/docs/html/search/classes_9.js @@ -1,4 +1,5 @@ var searchData= [ - ['richtext_0',['RichText',['../classRichText.html',1,'']]] + ['result_0',['Result',['../classResult.html',1,'']]], + ['richtext_1',['RichText',['../classRichText.html',1,'']]] ]; diff --git a/docs/html/search/functions_10.js b/docs/html/search/functions_10.js index 68340346..2824b719 100644 --- a/docs/html/search/functions_10.js +++ b/docs/html/search/functions_10.js @@ -4,7 +4,7 @@ var searchData= ['readconfigs_1',['readConfigs',['../classMainWindow.html#aae306cbf256c5a686cc8d9f2a1dbb18b',1,'MainWindow']]], ['readfile_2',['readFile',['../classGZutils.html#a72f6960bddea2b816af84e7773d5c6b2',1,'GZutils::readFile()'],['../classIOutils.html#a185c38eff9d9f4432c8138404941915e',1,'IOutils::readFile()']]], ['recalculateangles_3',['recalculateAngles',['../classDonutBreakdown.html#acd747ee2bbd23ce84eaf9d4db57938e3',1,'DonutBreakdown']]], - ['refreshdates_4',['refreshDates',['../classCrapview.html#ac98b1cbc75604b5145b5cff36e96eb78',1,'Crapview::refreshDates()'],['../classDbQuery.html#af0b44989b67b5735e7ca93a17a250eb3',1,'DbQuery::refreshDates()']]], + ['refreshdates_4',['refreshDates',['../classCrapview.html#ac98b1cbc75604b5145b5cff36e96eb78',1,'Crapview::refreshDates()'],['../classDbQuery.html#a666a5e656764c18907affcd169988212',1,'DbQuery::refreshDates()']]], ['refreshstatsdates_5',['refreshStatsDates',['../classMainWindow.html#ac8f4c84b43d14b6dcc6cb7b5f75ce343',1,'MainWindow']]], ['renameascopy_6',['renameAsCopy',['../classIOutils.html#a8fc152ae29702c3760a4f519ceb0b62a',1,'IOutils']]], ['replace_7',['replace',['../classStringOps.html#a9b073c9a47d2af00d33f1f5b05c167ad',1,'StringOps']]], diff --git a/docs/html/search/functions_6.js b/docs/html/search/functions_6.js index 190f6a56..24366182 100644 --- a/docs/html/search/functions_6.js +++ b/docs/html/search/functions_6.js @@ -11,46 +11,47 @@ var searchData= ['getcolorschemes_8',['getColorSchemes',['../classColorSec.html#a4ad467469ba6b81fd0827f73ac53b6f8',1,'ColorSec']]], ['getcurrentlogformat_9',['getCurrentLogFormat',['../classCraplog.html#a9d289b49aedb0fbc2ce02bd805a1a65c',1,'Craplog']]], ['getcurrentwsid_10',['getCurrentWSID',['../classCraplog.html#a9a49a14e50120682a342ea3ba63947a5',1,'Craplog']]], - ['getdays_11',['getDays',['../classCrapview.html#ad03099fd23d33fbd0f7ef5fcc1c67bde',1,'Crapview']]], - ['getdaytimecounts_12',['getDaytimeCounts',['../classDbQuery.html#a31937b71d3088a7cb84a522e85cc86f1',1,'DbQuery']]], - ['getdbfield_13',['getDbField',['../classDbQuery.html#a17b84cf6ad72726387256e5c6288e93c',1,'DbQuery']]], - ['getdialogslevel_14',['getDialogsLevel',['../classCrapview.html#a9c117a07b9eb26532156e82d7852725b',1,'Crapview::getDialogsLevel()'],['../classCraplog.html#a955b8b094062a6e2ee89cf884dd7b028',1,'Craplog::getDialogsLevel()']]], - ['getfields_15',['getFields',['../classCrapview.html#a9b565e2994fc2f5c7379898fb39c7f15',1,'Crapview']]], - ['getfont_16',['getFont',['../classTextBrowser.html#aef0e5e3fb14ca9b48c1d668aebc33b33',1,'TextBrowser']]], - ['getfontfamily_17',['getFontFamily',['../classTextBrowser.html#ab7ad4bfc3ef92bd938e00dc438559c0b',1,'TextBrowser']]], - ['getglobalcounts_18',['getGlobalCounts',['../classDbQuery.html#ae504836c92d55d421d5e34b145b2065b',1,'DbQuery']]], - ['gethashesdatabasepath_19',['getHashesDatabasePath',['../classCraplog.html#a2b66000f63d8ab34e894b90fe3496e43',1,'Craplog']]], - ['gethours_20',['getHours',['../classCrapview.html#ad6eb1887779aaa5f7c2aa95911e832b8',1,'Crapview']]], - ['getiislogsample_21',['getIisLogSample',['../classFormatOps.html#a1fe9ff3f875e96c0866622f1a60f29b5',1,'FormatOps']]], - ['getitemscount_22',['getItemsCount',['../classDbQuery.html#a47744cc993d6a4bada0a8aec992a2c23',1,'DbQuery']]], - ['getlogfieldid_23',['getLogFieldID',['../classCrapview.html#a2907f88ba82158c8c58f54383b4a7c2a',1,'Crapview']]], - ['getlogfieldstring_24',['getLogFieldString',['../classCrapview.html#ab4aa28144e1d1a8f7954e0a3c6d3f9d1',1,'Crapview']]], - ['getlogfileitem_25',['getLogFileItem',['../classCraplog.html#a8fc3affaf8da7695390877c63b5b6051',1,'Craplog']]], - ['getlogsformat_26',['getLogsFormat',['../classCraplog.html#a946a0f980c91d713bd01cca8e822616d',1,'Craplog']]], - ['getlogsformatsample_27',['getLogsFormatSample',['../classCraplog.html#ae772867818dcfac15eba8f94da7f0493',1,'Craplog']]], - ['getlogsformatstring_28',['getLogsFormatString',['../classCraplog.html#a159ff9779d1ff85c8ecc6cb63274d494',1,'Craplog']]], - ['getlogslist_29',['getLogsList',['../classCraplog.html#aa0c1078272a2c9c88e51da32c2cbf269',1,'Craplog']]], - ['getlogslistsize_30',['getLogsListSize',['../classCraplog.html#affcd5025487fb60f89d7a35c3c807454',1,'Craplog']]], - ['getlogspath_31',['getLogsPath',['../classCraplog.html#aefd29a191a45be88d34dcfadab076f6d',1,'Craplog']]], - ['getminutegap_32',['getMinuteGap',['../classDbQuery.html#ae172c2f717f939daa41c5a0681ca76c3',1,'DbQuery']]], - ['getmonthdays_33',['getMonthDays',['../classDbQuery.html#a3dcefca533b85ef4e4f8fc12bd380d3e',1,'DbQuery']]], - ['getmonthnumber_34',['getMonthNumber',['../classCrapview.html#af156af64d1cb47d1c0fe1bacc3745974',1,'Crapview::getMonthNumber()'],['../classDbQuery.html#a3254d6cbe61c890ebc6b9d97367256dd',1,'DbQuery::getMonthNumber()']]], - ['getmonths_35',['getMonths',['../classCrapview.html#aa8518f26e3769580bbd3439e094b221a',1,'Crapview']]], - ['getmonthscount_36',['getMonthsCount',['../classDbQuery.html#a2fd212eaa2c82188ffc469fa5737792b',1,'DbQuery']]], - ['getnginxlogsample_37',['getNginxLogSample',['../classFormatOps.html#a46cc3ff63986ec4437c20ccbd68569c2',1,'FormatOps']]], - ['getparsedlines_38',['getParsedLines',['../classCraplog.html#ae933a2f390dc08664b2ea07acd0b1c39',1,'Craplog::getParsedLines()'],['../classLogOps.html#a239ed1c9dca8cbf31f8e7c3fe52c1be1',1,'LogOps::getParsedLines()']]], - ['getparsedsize_39',['getParsedSize',['../classLogOps.html#a06ce568d05b595728093dd2458608f41',1,'LogOps']]], - ['getperfsize_40',['getPerfSize',['../classCraplog.html#a556449b0a92e4bea1e444faca663abd5',1,'Craplog']]], - ['getrelationalcountsday_41',['getRelationalCountsDay',['../classDbQuery.html#aa1691a2878a4a6821afdaf155251ec0b',1,'DbQuery']]], - ['getrelationalcountsperiod_42',['getRelationalCountsPeriod',['../classDbQuery.html#acae142053967818896367a61e808533c',1,'DbQuery']]], - ['getspeeddata_43',['getSpeedData',['../classDbQuery.html#a3aa22b5075bf5607d986d641668af1ea',1,'DbQuery']]], - ['getstatsdatabasepath_44',['getStatsDatabasePath',['../classCraplog.html#a1f08bdd3ce8f969684cfb2acccb3a8aa',1,'Craplog']]], - ['getstylesheet_45',['getStyleSheet',['../classStyleSec.html#ac0781d686293b84e935bd29fe5283b14',1,'StyleSec']]], - ['gettotalsize_46',['getTotalSize',['../classCraplog.html#a92dd0b6330bdc32c908e688b7eced812',1,'Craplog::getTotalSize()'],['../classLogOps.html#a669727346faca20c48fe8f00e3c906ec',1,'LogOps::getTotalSize()']]], - ['getwarncounts_47',['getWarnCounts',['../classDbQuery.html#a2fc983abeeec05d04a110a29f80c4009',1,'DbQuery']]], - ['getwarningsize_48',['getWarningSize',['../classCraplog.html#af79d254595263448fead944f82db8931',1,'Craplog']]], - ['getwarnlist_49',['getWarnlist',['../classCraplog.html#a53df5cc15fdc79c1708aaf002c2f7719',1,'Craplog']]], - ['getwidelinesusage_50',['getWideLinesUsage',['../classTextBrowser.html#a7a62dfd67e7a58f374951272ac13defd',1,'TextBrowser']]], - ['getyears_51',['getYears',['../classCrapview.html#ab3081c678b102b255fa9f32a8f94e052',1,'Crapview']]], - ['grow_52',['grow',['../classSnake.html#a524fb8b522e917f620cfb401f2badabe',1,'Snake']]] + ['getdata_11',['getData',['../classResult.html#a5de904d7791ed47839f47db2b6893957',1,'Result']]], + ['getdays_12',['getDays',['../classCrapview.html#ad03099fd23d33fbd0f7ef5fcc1c67bde',1,'Crapview']]], + ['getdaytimecounts_13',['getDaytimeCounts',['../classDbQuery.html#a78bce23f02038060ba4812534a1c4317',1,'DbQuery']]], + ['getdbfield_14',['getDbField',['../classDbQuery.html#a17b84cf6ad72726387256e5c6288e93c',1,'DbQuery']]], + ['getdialogslevel_15',['getDialogsLevel',['../classCrapview.html#a9c117a07b9eb26532156e82d7852725b',1,'Crapview::getDialogsLevel()'],['../classCraplog.html#a955b8b094062a6e2ee89cf884dd7b028',1,'Craplog::getDialogsLevel()']]], + ['getfields_16',['getFields',['../classCrapview.html#a9b565e2994fc2f5c7379898fb39c7f15',1,'Crapview']]], + ['getfont_17',['getFont',['../classTextBrowser.html#aef0e5e3fb14ca9b48c1d668aebc33b33',1,'TextBrowser']]], + ['getfontfamily_18',['getFontFamily',['../classTextBrowser.html#ab7ad4bfc3ef92bd938e00dc438559c0b',1,'TextBrowser']]], + ['getglobalcounts_19',['getGlobalCounts',['../classDbQuery.html#ae504836c92d55d421d5e34b145b2065b',1,'DbQuery']]], + ['gethashesdatabasepath_20',['getHashesDatabasePath',['../classCraplog.html#a2b66000f63d8ab34e894b90fe3496e43',1,'Craplog']]], + ['gethours_21',['getHours',['../classCrapview.html#ad6eb1887779aaa5f7c2aa95911e832b8',1,'Crapview']]], + ['getiislogsample_22',['getIisLogSample',['../classFormatOps.html#a1fe9ff3f875e96c0866622f1a60f29b5',1,'FormatOps']]], + ['getitemscount_23',['getItemsCount',['../classDbQuery.html#a34c32e81025f4c767cdf2ec6b4ab3bde',1,'DbQuery']]], + ['getlogfieldid_24',['getLogFieldID',['../classCrapview.html#a2907f88ba82158c8c58f54383b4a7c2a',1,'Crapview']]], + ['getlogfieldstring_25',['getLogFieldString',['../classCrapview.html#ab4aa28144e1d1a8f7954e0a3c6d3f9d1',1,'Crapview']]], + ['getlogfileitem_26',['getLogFileItem',['../classCraplog.html#a8fc3affaf8da7695390877c63b5b6051',1,'Craplog']]], + ['getlogsformat_27',['getLogsFormat',['../classCraplog.html#a946a0f980c91d713bd01cca8e822616d',1,'Craplog']]], + ['getlogsformatsample_28',['getLogsFormatSample',['../classCraplog.html#ae772867818dcfac15eba8f94da7f0493',1,'Craplog']]], + ['getlogsformatstring_29',['getLogsFormatString',['../classCraplog.html#a159ff9779d1ff85c8ecc6cb63274d494',1,'Craplog']]], + ['getlogslist_30',['getLogsList',['../classCraplog.html#aa0c1078272a2c9c88e51da32c2cbf269',1,'Craplog']]], + ['getlogslistsize_31',['getLogsListSize',['../classCraplog.html#affcd5025487fb60f89d7a35c3c807454',1,'Craplog']]], + ['getlogspath_32',['getLogsPath',['../classCraplog.html#aefd29a191a45be88d34dcfadab076f6d',1,'Craplog']]], + ['getminutegap_33',['getMinuteGap',['../classDbQuery.html#ae172c2f717f939daa41c5a0681ca76c3',1,'DbQuery']]], + ['getmonthdays_34',['getMonthDays',['../classDbQuery.html#a3dcefca533b85ef4e4f8fc12bd380d3e',1,'DbQuery']]], + ['getmonthnumber_35',['getMonthNumber',['../classCrapview.html#af156af64d1cb47d1c0fe1bacc3745974',1,'Crapview::getMonthNumber()'],['../classDbQuery.html#a3254d6cbe61c890ebc6b9d97367256dd',1,'DbQuery::getMonthNumber()']]], + ['getmonths_36',['getMonths',['../classCrapview.html#aa8518f26e3769580bbd3439e094b221a',1,'Crapview']]], + ['getmonthscount_37',['getMonthsCount',['../classDbQuery.html#a2fd212eaa2c82188ffc469fa5737792b',1,'DbQuery']]], + ['getnginxlogsample_38',['getNginxLogSample',['../classFormatOps.html#a46cc3ff63986ec4437c20ccbd68569c2',1,'FormatOps']]], + ['getparsedlines_39',['getParsedLines',['../classCraplog.html#ae933a2f390dc08664b2ea07acd0b1c39',1,'Craplog::getParsedLines()'],['../classLogOps.html#a239ed1c9dca8cbf31f8e7c3fe52c1be1',1,'LogOps::getParsedLines()']]], + ['getparsedsize_40',['getParsedSize',['../classLogOps.html#a06ce568d05b595728093dd2458608f41',1,'LogOps']]], + ['getperfsize_41',['getPerfSize',['../classCraplog.html#a556449b0a92e4bea1e444faca663abd5',1,'Craplog']]], + ['getrelationalcountsday_42',['getRelationalCountsDay',['../classDbQuery.html#a09f4401f27bf9ed27eb50cb6b4cbbedf',1,'DbQuery']]], + ['getrelationalcountsperiod_43',['getRelationalCountsPeriod',['../classDbQuery.html#a6dd70dbc8dd0a4f79aa066fb4ef93ee8',1,'DbQuery']]], + ['getspeeddata_44',['getSpeedData',['../classDbQuery.html#a6a1c4fddcdc6580da653bf2ad81d7558',1,'DbQuery']]], + ['getstatsdatabasepath_45',['getStatsDatabasePath',['../classCraplog.html#a1f08bdd3ce8f969684cfb2acccb3a8aa',1,'Craplog']]], + ['getstylesheet_46',['getStyleSheet',['../classStyleSec.html#ac0781d686293b84e935bd29fe5283b14',1,'StyleSec']]], + ['gettotalsize_47',['getTotalSize',['../classCraplog.html#a92dd0b6330bdc32c908e688b7eced812',1,'Craplog::getTotalSize()'],['../classLogOps.html#a669727346faca20c48fe8f00e3c906ec',1,'LogOps::getTotalSize()']]], + ['getwarncounts_48',['getWarnCounts',['../classDbQuery.html#aa3f8d1cdf799287f5aaeb4ae0e848393',1,'DbQuery']]], + ['getwarningsize_49',['getWarningSize',['../classCraplog.html#af79d254595263448fead944f82db8931',1,'Craplog']]], + ['getwarnlist_50',['getWarnlist',['../classCraplog.html#a53df5cc15fdc79c1708aaf002c2f7719',1,'Craplog']]], + ['getwidelinesusage_51',['getWideLinesUsage',['../classTextBrowser.html#a7a62dfd67e7a58f374951272ac13defd',1,'TextBrowser']]], + ['getyears_52',['getYears',['../classCrapview.html#ab3081c678b102b255fa9f32a8f94e052',1,'Crapview']]], + ['grow_53',['grow',['../classSnake.html#a524fb8b522e917f620cfb401f2badabe',1,'Snake']]] ]; diff --git a/docs/html/search/functions_c.js b/docs/html/search/functions_c.js index 583207d2..6088395d 100644 --- a/docs/html/search/functions_c.js +++ b/docs/html/search/functions_c.js @@ -5,7 +5,7 @@ var searchData= ['makeinitialchecks_2',['makeInitialChecks',['../classMainWindow.html#ae459fb4a3966975abe641c11c76e2c03',1,'MainWindow']]], ['makepreview_3',['makePreview',['../classTextBrowser.html#a5b0eb8070202317c6e04534ca417c957',1,'TextBrowser']]], ['makestylesheet_4',['makeStyleSheet',['../classStyleSec.html#a7deedd8236a76bdb8ba050e1fb797f11',1,'StyleSec']]], - ['menu_5factionenglish_5ftriggered_5',['menu_actionEnglish_triggered',['../classMainWindow.html#adffe78de926642168d16bfd8a2522c29',1,'MainWindow']]], + ['menu_5factionenglishgb_5ftriggered_5',['menu_actionEnglishGb_triggered',['../classMainWindow.html#a42ea06a6c166e5c8243944d4e5159514',1,'MainWindow']]], ['move_6',['move',['../classFood.html#a7196aa14ad843820518dc9db03252d21',1,'Food']]], ['msgdatabasecreated_7',['msgDatabaseCreated',['../classDialogSec.html#ae916458257088da13a1a2bc885d5c71d',1,'DialogSec']]] ]; From e81abcbcd942d3bbe9070fdc8e691b21ee4e61d0 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Mon, 23 Jan 2023 00:47:43 +0100 Subject: [PATCH 05/36] Fix Fixed tables' items not displaying when renewing a QTableView having a header's column with the SortIndicator enabled --- logdoctor/mainwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/logdoctor/mainwindow.cpp b/logdoctor/mainwindow.cpp index 051693b7..131974fa 100644 --- a/logdoctor/mainwindow.cpp +++ b/logdoctor/mainwindow.cpp @@ -2965,6 +2965,7 @@ void MainWindow::on_button_StatsWarn_Draw_clicked() } void MainWindow::drawStatsWarn() { + this->ui->table_StatsWarn->horizontalHeader()->setSortIndicator( -1, Qt::SortOrder::AscendingOrder ); this->ui->table_StatsWarn->setRowCount(0); this->crapview.drawWarn( this->ui->table_StatsWarn, this->ui->chart_StatsWarn, @@ -3064,6 +3065,7 @@ void MainWindow::on_button_StatsSpeed_Draw_clicked() } void MainWindow::drawStatsSpeed() { + this->ui->table_StatsSpeed->horizontalHeader()->setSortIndicator( -1, Qt::SortOrder::AscendingOrder ); this->ui->table_StatsSpeed->setRowCount(0); this->crapview.drawSpeed( this->ui->table_StatsSpeed, @@ -3280,6 +3282,7 @@ void MainWindow::on_button_StatsCount_Client_clicked() void MainWindow::drawStatsCount() { + this->ui->table_StatsCount->horizontalHeader()->setSortIndicator( -1, Qt::SortOrder::AscendingOrder ); this->ui->table_StatsCount->setRowCount(0); this->crapview.drawCount( this->ui->table_StatsCount, this->ui->chart_StatsCount, From 357c0f0264e2b5c73dbe5c2882cce74350fac582 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Mon, 23 Jan 2023 00:51:25 +0100 Subject: [PATCH 06/36] Fix Fixed sort by value and not by character for tables' columns holding numbers --- logdoctor/modules/crapview/crapview.cpp | 85 ++++++++++++++----------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/logdoctor/modules/crapview/crapview.cpp b/logdoctor/modules/crapview/crapview.cpp index fa1af295..858c8b1b 100644 --- a/logdoctor/modules/crapview/crapview.cpp +++ b/logdoctor/modules/crapview/crapview.cpp @@ -322,7 +322,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const // build the bars and the table upon data QString date; QColor warn_col = QColor( 255, 140, 0, 255 ); - int norm_count, warn_count, sum_count, max_count=0, aux; + int norm_count, warn_count, sum_count, max_count=0, n_rows=0; if ( hour.size() == 0 ) { // entire day for ( int i=0; i<6; i++ ) { @@ -335,25 +335,34 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const const auto& data = items.at( h ).at( m ); norm_count = warn_count = 0; for ( const std::vector& line : data ) { - aux = table->rowCount(); - table->insertRow( aux ); - table->setItem( aux, 0, new QTableWidgetItem( this->printableWarn( line.at( 0 ).toInt() ))); + table->insertRow( n_rows ); + table->setItem( n_rows, 0, new QTableWidgetItem( this->printableWarn( line.at( 0 ).toInt() ))); if ( line.at( 0 ).toInt() != 0 ) { - table->item( aux, 0 )->setForeground( warn_col ); - table->item( aux, 0 )->setCheckState( Qt::CheckState::Checked ); + table->item( n_rows, 0 )->setForeground( warn_col ); + table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Checked ); } else { - table->item( aux, 0 )->setCheckState( Qt::CheckState::Unchecked ); + table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Unchecked ); } - table->setItem( aux, 1, new QTableWidgetItem( this->printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); - table->setItem( aux, 2, new QTableWidgetItem( this->printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); + table->setItem( n_rows, 1, new QTableWidgetItem( this->printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); + table->setItem( n_rows, 2, new QTableWidgetItem( this->printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); + int col = 3; for ( int i=7; isetItem( aux, i-4, new QTableWidgetItem( line.at( i ) )); + QTableWidgetItem* itm; + if ( (col == 7 || col >= 12) && line.at(i).size() > 0 ) { + itm = new QTableWidgetItem(); + itm->setData( Qt::DisplayRole, line.at( i ).toInt() ); + } else { + itm = new QTableWidgetItem( line.at( i ) ); + } + table->setItem( n_rows, col, itm ); + col ++; } if ( line.at( 0 ) == "0" ) { norm_count ++; } else { warn_count ++; } + n_rows ++; } sets.at( m ).at( 0 )->append( norm_count ); sets.at( m ).at( 1 )->append( warn_count ); @@ -376,19 +385,19 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const const auto& data = items.at( g ).at( m ); norm_count = warn_count = 0; for ( const std::vector& line : data ) { - aux = table->rowCount(); - table->insertRow( aux ); - table->setItem( aux, 0, new QTableWidgetItem( this->printableWarn( line.at( 0 ).toInt() ))); + n_rows = table->rowCount(); + table->insertRow( n_rows ); + table->setItem( n_rows, 0, new QTableWidgetItem( this->printableWarn( line.at( 0 ).toInt() ))); if ( line.at( 0 ).toInt() != 0 ) { - table->item( aux, 0 )->setForeground( warn_col ); - table->item( aux, 0 )->setCheckState( Qt::CheckState::Checked ); + table->item( n_rows, 0 )->setForeground( warn_col ); + table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Checked ); } else { - table->item( aux, 0 )->setCheckState( Qt::CheckState::Unchecked ); + table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Unchecked ); } - table->setItem( aux, 1, new QTableWidgetItem( this->printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); - table->setItem( aux, 2, new QTableWidgetItem( this->printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); + table->setItem( n_rows, 1, new QTableWidgetItem( this->printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); + table->setItem( n_rows, 2, new QTableWidgetItem( this->printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); for ( int i=7; isetItem( aux, i-4, new QTableWidgetItem( line.at( i ) )); + table->setItem( n_rows, i-4, new QTableWidgetItem( line.at( i ) )); } if ( line.at( 0 ) == "0" ) { norm_count ++; @@ -496,8 +505,8 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons QLineSeries *line = new QLineSeries(); // build the line upon data - int i=0, max_i=items.size(), max_t=0, aux; - long long time /* xD */, aux_time, t=0, aux_t, count=1; + int i=0, max_i=items.size(), t=0, aux_t, max_t=0, n_rows=0; + long long time /* xD */, aux_time, count=1; time = std::get<0>(items.at(0)); QDateTime dt; std::vector data; @@ -506,7 +515,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons // append a value to the chart aux_time = std::get<0>(item); data = std::get<1>(item); - aux_t = data.at( 0 ).toLongLong(); + aux_t = data.at( 0 ).toInt(); // append only if the second is different, else sum if ( aux_time > time ) { t = t/count; @@ -547,16 +556,18 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons } // fill the teble with data if ( data.at(0).size() > 0 || data.at(1).size() > 0 || data.at(2).size() > 0 || data.at(3).size() > 0 || data.at(4).size() > 0 || data.at(5).size() > 0 ) { - aux = table->rowCount(); - table->insertRow( aux ); - table->setItem( aux, 0, new QTableWidgetItem( data.at(0) )); - table->setItem( aux, 1, new QTableWidgetItem( data.at(1) )); - table->setItem( aux, 2, new QTableWidgetItem( data.at(2) )); - table->setItem( aux, 3, new QTableWidgetItem( data.at(3) )); - table->setItem( aux, 4, new QTableWidgetItem( data.at(4) )); - table->setItem( aux, 5, new QTableWidgetItem( data.at(5) )); + table->insertRow( n_rows ); + auto tt = new QTableWidgetItem(); + tt->setData( Qt::DisplayRole, aux_t ); + table->setItem( n_rows, 0, tt ); + table->setItem( n_rows, 1, new QTableWidgetItem( data.at(1) )); + table->setItem( n_rows, 2, new QTableWidgetItem( data.at(2) )); + table->setItem( n_rows, 3, new QTableWidgetItem( data.at(3) )); + table->setItem( n_rows, 4, new QTableWidgetItem( data.at(4) )); + table->setItem( n_rows, 5, new QTableWidgetItem( data.at(5) )); dt = QDateTime::fromMSecsSinceEpoch( aux_time ); - table->setItem( aux, 6, new QTableWidgetItem( dt.time().toString("hh:mm:ss") )); + table->setItem( n_rows, 6, new QTableWidgetItem( dt.time().toString("hh:mm:ss") )); + n_rows ++; } } table->verticalHeader()->setVisible( false ); @@ -643,7 +654,7 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons QPieSeries *pie = new QPieSeries(); // cut off exdceeding elements for the chart const int max_items=15; - int aux, count, oth_count=0; + int count, oth_count=0, n_rows=0; QString item; for ( int i=0; i( items.at(i) ); @@ -653,10 +664,12 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons } else { pie->append( item, count ); } - aux = table->rowCount(); - table->insertRow( aux ); - table->setItem( aux, 0, new QTableWidgetItem( QString::fromStdString( std::to_string(count) ))); - table->setItem( aux, 1, new QTableWidgetItem( std::get<0>( items.at(i) ) )); + table->insertRow( n_rows ); + auto ic = new QTableWidgetItem(); + ic->setData( Qt::DisplayRole, count ); + table->setItem( n_rows, 0, ic ); + table->setItem( n_rows, 1, new QTableWidgetItem( std::get<0>( items.at(i) ) )); + n_rows ++; } table->verticalHeader()->setVisible( false ); From 73f4512a45c333ac8e6c644a5cb3edfb65996c4b Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Mon, 23 Jan 2023 19:07:24 +0100 Subject: [PATCH 07/36] Code improvements --- logdoctor/games/crisscross/game.cpp | 4 +- logdoctor/games/crisscross/game.h | 6 +- logdoctor/games/snake/food.cpp | 14 +-- logdoctor/games/snake/food.h | 16 ++-- logdoctor/games/snake/game.cpp | 2 +- logdoctor/games/snake/game.h | 4 +- logdoctor/games/snake/snake.cpp | 30 +++---- logdoctor/games/snake/snake.h | 30 +++---- logdoctor/mainwindow.cpp | 74 ++++++++-------- logdoctor/mainwindow.h | 42 ++++----- logdoctor/modules/craphelp/craphelp.cpp | 4 +- logdoctor/modules/craphelp/craphelp.h | 4 +- logdoctor/modules/crapinfo/crapinfo.cpp | 4 +- logdoctor/modules/crapinfo/crapinfo.h | 4 +- logdoctor/modules/craplog/craplog.cpp | 60 ++++++------- logdoctor/modules/craplog/craplog.h | 61 +++++++------ logdoctor/modules/craplog/modules/datetime.h | 2 +- logdoctor/modules/craplog/modules/donuts.h | 4 +- logdoctor/modules/craplog/modules/formats.cpp | 22 ++--- logdoctor/modules/craplog/modules/formats.h | 24 ++--- logdoctor/modules/craplog/modules/hash.cpp | 12 +-- logdoctor/modules/craplog/modules/hash.h | 32 +++---- logdoctor/modules/craplog/modules/logs.cpp | 16 ++-- logdoctor/modules/craplog/modules/logs.h | 27 +++--- logdoctor/modules/craplog/modules/store.h | 2 +- logdoctor/modules/crapup/crapup.cpp | 4 +- logdoctor/modules/crapup/crapup.h | 7 +- logdoctor/modules/crapview/crapview.cpp | 55 ++++++------ logdoctor/modules/crapview/crapview.h | 75 +++++++++------- logdoctor/modules/crapview/modules/query.cpp | 30 +++---- logdoctor/modules/crapview/modules/query.h | 88 +++++++++++-------- logdoctor/modules/dialogs.h | 2 +- logdoctor/modules/dialogs/dialogbool.h | 2 +- logdoctor/modules/dialogs/dialogdia.h | 2 +- logdoctor/modules/dialogs/dialogmsg.h | 2 +- logdoctor/modules/exceptions.cpp | 8 +- logdoctor/modules/exceptions.h | 12 +-- logdoctor/modules/tb.cpp | 14 +-- logdoctor/modules/tb.h | 14 +-- logdoctor/translations/LogDoctor_es_ES.ts | 46 +++++----- logdoctor/translations/LogDoctor_fr_FR.ts | 46 +++++----- logdoctor/translations/LogDoctor_pt_BR.ts | 46 +++++----- logdoctor/utilities/checks.h | 2 +- logdoctor/utilities/colors.h | 2 +- logdoctor/utilities/gzip.h | 2 +- logdoctor/utilities/io.h | 2 +- logdoctor/utilities/result.cpp | 4 +- logdoctor/utilities/result.h | 8 +- logdoctor/utilities/rtf.cpp | 11 +-- logdoctor/utilities/rtf.h | 5 +- logdoctor/utilities/strings.cpp | 2 +- logdoctor/utilities/strings.h | 4 +- logdoctor/utilities/stylesheets.cpp | 2 +- logdoctor/utilities/stylesheets.h | 4 +- 54 files changed, 516 insertions(+), 485 deletions(-) diff --git a/logdoctor/games/crisscross/game.cpp b/logdoctor/games/crisscross/game.cpp index fa677d44..afebfeb4 100644 --- a/logdoctor/games/crisscross/game.cpp +++ b/logdoctor/games/crisscross/game.cpp @@ -244,7 +244,7 @@ void CrissCross::victory() } -const bool CrissCross::gameDraw() +const bool CrissCross::gameDraw() const { bool result = false; unsigned int empty_tiles = 9; @@ -319,7 +319,7 @@ void CrissCross::AI_updateWeights() } -const unsigned int CrissCross::AI_makeChoice() +const unsigned int CrissCross::AI_makeChoice() const { // get a list of the heaviest tiles std::vector moves; diff --git a/logdoctor/games/crisscross/game.h b/logdoctor/games/crisscross/game.h index 54cc691c..70fa157d 100644 --- a/logdoctor/games/crisscross/game.h +++ b/logdoctor/games/crisscross/game.h @@ -19,7 +19,7 @@ class CrissCross : public QWidget Q_OBJECT public: - CrissCross( const int& theme_id, QWidget* parent=nullptr ); + explicit CrissCross( const int& theme_id, QWidget* parent=nullptr ); ~CrissCross(); @@ -101,7 +101,7 @@ private: const bool checkVictory(); //! Checks whether the game is draw or not - const bool gameDraw(); + const bool gameDraw() const; //! Someone won, process the victory void victory(); @@ -127,7 +127,7 @@ private: \return The tile to select \see AI_playTurn(); */ - const unsigned int AI_makeChoice(); + const unsigned int AI_makeChoice() const; }; diff --git a/logdoctor/games/snake/food.cpp b/logdoctor/games/snake/food.cpp index f21ccfec..62ea4a8d 100644 --- a/logdoctor/games/snake/food.cpp +++ b/logdoctor/games/snake/food.cpp @@ -11,23 +11,23 @@ Food::Food( const bool& can_move ) } -const unsigned int& Food::X() +const unsigned int& Food::X() const { return this->x; } -const unsigned int& Food::Y() +const unsigned int& Food::Y() const { return this->y; } -QGraphicsPixmapItem* Food::getImageItem() +QGraphicsPixmapItem* Food::getImageItem() const { return this->image; } -const bool Food::inTile( const unsigned int& x, const unsigned int& y ) +const bool Food::inTile( const unsigned int x, const unsigned int y ) const { if ( this->x == x && this->y == y ) { return true; @@ -37,14 +37,14 @@ const bool Food::inTile( const unsigned int& x, const unsigned int& y ) } -void Food::update( const unsigned int& new_x, const unsigned int& new_y ) { +void Food::update( const unsigned int new_x, const unsigned int new_y ) { this->x = new_x; this->y = new_y; this->image->setOffset( 16+(new_x*32), 16+(new_y*32) ); } -void Food::spawn( Snake& snake, Snake& snake_ ) +void Food::spawn( const Snake& snake, const Snake& snake_ ) { // pick a new random position unsigned int x, y; @@ -90,7 +90,7 @@ void Food::spawn( Snake& snake, Snake& snake_ ) } -void Food::move( Snake& snake ) +void Food::move( const Snake& snake ) { int move_up = 0, move_down = 0, diff --git a/logdoctor/games/snake/food.h b/logdoctor/games/snake/food.h index 353127eb..9016a796 100644 --- a/logdoctor/games/snake/food.h +++ b/logdoctor/games/snake/food.h @@ -8,27 +8,27 @@ class Food { public: - Food( const bool& can_move=false ); + explicit Food( const bool& can_move=false ); //! Returns the position on the X-axis - const unsigned int& X(); + const unsigned int& X() const; //! Returns the position on the Y-axis - const unsigned int& Y(); + const unsigned int& Y() const; //!< Returns the image - QGraphicsPixmapItem* getImageItem(); + QGraphicsPixmapItem* getImageItem() const; //! Checks whether is there a part of the snake in the given position - const bool inTile( const unsigned int& x, const unsigned int& y ); + const bool inTile( const unsigned int x, const unsigned int y ) const; //! Spawns the egg/rat in a new position - void spawn( Snake& snake, Snake& snake_ ); + void spawn( const Snake& snake, const Snake& snake_ ); //! Moves the rat - void move( Snake& snake ); + void move( const Snake& snake ); //! Updates the position and direction of the entity - void update( const unsigned int& new_x, const unsigned int& new_y ); + void update( const unsigned int new_x, const unsigned int new_y ); private: diff --git a/logdoctor/games/snake/game.cpp b/logdoctor/games/snake/game.cpp index 4478b506..0e7b4a18 100644 --- a/logdoctor/games/snake/game.cpp +++ b/logdoctor/games/snake/game.cpp @@ -319,7 +319,7 @@ void SnakeGame::updateGameScore() } -void SnakeGame::checkCollision( Snake& snake, Snake& adv_snake, const bool& is_adv ) +void SnakeGame::checkCollision( Snake& snake, Snake& adv_snake, const bool is_adv ) { unsigned int x, y, x_, y_; diff --git a/logdoctor/games/snake/game.h b/logdoctor/games/snake/game.h index 2ef7af89..06f0855d 100644 --- a/logdoctor/games/snake/game.h +++ b/logdoctor/games/snake/game.h @@ -26,7 +26,7 @@ class SnakeGame : public QWidget Q_OBJECT public: - SnakeGame( const int& theme_id, const QFont& term_font, QWidget* parent=nullptr ); + explicit SnakeGame( const int& theme_id, const QFont& term_font, QWidget* parent=nullptr ); ~SnakeGame(); @@ -110,7 +110,7 @@ private: void newSnake_(); //! Checks if a snake will collide with another entity - void checkCollision( Snake& snake, Snake& adv_snake, const bool& is_adv ); + void checkCollision( Snake& snake, Snake& adv_snake, const bool is_adv ); ////////////// diff --git a/logdoctor/games/snake/snake.cpp b/logdoctor/games/snake/snake.cpp index d2d4e526..73ab8874 100644 --- a/logdoctor/games/snake/snake.cpp +++ b/logdoctor/games/snake/snake.cpp @@ -2,7 +2,7 @@ #include "snake.h" -Snake::Snake( const bool& is_adversary ) +Snake::Snake( const bool is_adversary ) { this->will_grow = false; this->adversary = is_adversary; @@ -18,7 +18,7 @@ Snake::Snake( const bool& is_adversary ) } -QPixmap& Snake::getHeadImage() +const QPixmap& Snake::getHeadImage() const { if ( this->adversary ) { return this->img_snakeHead_; @@ -28,7 +28,7 @@ QPixmap& Snake::getHeadImage() } -const bool Snake::inTile( const unsigned int& x, const unsigned int& y , const bool& avoid_tail ) +const bool Snake::inTile( const unsigned int x, const unsigned int y , const bool avoid_tail ) const { bool result = false; if ( this->size() > 0 ) { @@ -56,7 +56,7 @@ void Snake::setDirection( const Direction new_direction ) { this->head_direction = new_direction; } -const Direction& Snake::direction() +const Direction& Snake::direction() const { return this->head_direction; } @@ -65,7 +65,7 @@ void Snake::willGrow() { this->will_grow = true; } -void Snake::grow( const bool& is_borning ) +void Snake::grow( const bool is_borning ) { // build from the tail const BodyPart& tail = this->back(); @@ -103,7 +103,7 @@ void Snake::grow( const bool& is_borning ) } -void Snake::update( QGraphicsScene* field_scene, const bool& dry , const bool& is_borning ) +void Snake::update( QGraphicsScene* field_scene, const bool dry , const bool is_borning ) { // grow if planned if ( this->will_grow ) { @@ -367,7 +367,7 @@ void Snake::update( QGraphicsScene* field_scene, const bool& dry , const bool& i } -void Snake::move( Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ) +void Snake::move( const Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ) { std::vector classes = { Direction::UP, @@ -404,7 +404,7 @@ void Snake::move( Snake& adv_snake, const unsigned int& food_x, const unsigned i } -const Direction Snake::predictDirection( std::vector>& data, std::vector weights , std::vector classes ) +const Direction Snake::predictDirection( const std::vector>& data, const std::vector& weights, const std::vector& classes ) const { float results[] = { 1.0, 1.0, 1.0, 1.0 }; bool keep_current = false; @@ -412,7 +412,7 @@ const Direction Snake::predictDirection( std::vector>& data, // process data for ( int i=0; i<4; i++ ) { - std::vector& d = data.at(i); + const std::vector& d = data.at(i); float& r = results[i]; for ( int j=0; j<7; j++ ) { r += d.at(j) * weights.at(j); @@ -461,7 +461,7 @@ const Direction Snake::predictDirection( std::vector>& data, } -void Snake::collectData( std::vector& data, Direction& direction, Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ) +void Snake::collectData( std::vector& data, Direction& direction, const Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ) const { unsigned int blocked_way = 0, @@ -722,7 +722,7 @@ void Snake::collectData( std::vector& data, Direction& direction, Snake& } -void Snake::updateFieldMap( Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ) +void Snake::updateFieldMap( const Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ) { // reset to default state for ( size_t x=0; x<16; x++ ) { @@ -753,7 +753,7 @@ void Snake::updateFieldMap( Snake& adv_snake, const unsigned int& food_x, const } -const bool Snake::inTileAdv(const unsigned int& x, const unsigned int& y ) +const bool Snake::inTileAdv(const unsigned int x, const unsigned int y ) const { bool result = false; if ( x < 16 && y < 16 ) { @@ -766,7 +766,7 @@ const bool Snake::inTileAdv(const unsigned int& x, const unsigned int& y ) return result; } -const bool Snake::inTileMinusSteps(const unsigned int& x, const unsigned int& y, const unsigned int& steps ) +const bool Snake::inTileMinusSteps(const unsigned int x, const unsigned int y, const unsigned int steps ) const { bool result = false; switch ( this->field_map.at(x).at(y).entity ) { @@ -781,7 +781,7 @@ const bool Snake::inTileMinusSteps(const unsigned int& x, const unsigned int& y, } -const std::vector Snake::checkAround( const Direction& direction, const unsigned int& x, const unsigned int& y ) +const std::vector Snake::checkAround( const Direction& direction, const unsigned int& x, const unsigned int& y ) const { std::vector around = { 0, 0, 0, @@ -851,7 +851,7 @@ const std::vector Snake::checkAround( const Direction& direction, } -const unsigned int Snake::isDeadHole( const unsigned int& start_x, const unsigned int& start_y, Direction start_direction ) +const unsigned int Snake::isDeadHole( const unsigned int& start_x, const unsigned int& start_y, Direction start_direction ) const { bool result=false, check=false, check_clockwise=false; int front_step, front_check, side_check; diff --git a/logdoctor/games/snake/snake.h b/logdoctor/games/snake/snake.h index 051f608e..bf1f9272 100644 --- a/logdoctor/games/snake/snake.h +++ b/logdoctor/games/snake/snake.h @@ -25,7 +25,7 @@ struct BodyPart { Direction prev_direction; //!< The previous direction of the part QGraphicsPixmapItem* image; //!< The image which graphically represents the part //! Updates the position and direction of the part - void update( const unsigned int& new_x, const unsigned int& new_y, const Direction& new_direction ) { + void update( const unsigned int new_x, const unsigned int new_y, const Direction& new_direction ) { this->x = new_x; this->y = new_y; this->image->setOffset( 16+(new_x*32), 16+(new_y*32) ); @@ -38,27 +38,27 @@ struct BodyPart { class Snake : public std::vector { public: - Snake( const bool& is_adversary=false ); + explicit Snake( const bool is_adversary=false ); - QPixmap& getHeadImage(); + const QPixmap& getHeadImage() const; //! Checks whether is there a part of the snake in the given position - const bool inTile( const unsigned int& x, const unsigned int& y, const bool& avoid_tail=true ); + const bool inTile( const unsigned int x, const unsigned int y, const bool avoid_tail=true ) const; //! Sets the new direction (of the head) void setDirection( const Direction new_direction ); //! Returns the current direction (of the head) - const Direction& direction(); + const Direction& direction() const; //! Updates the position and direction of the entire snake - void update( QGraphicsScene* field_scene=nullptr, const bool& dry=false, const bool& is_borning=false ); + void update( QGraphicsScene* field_scene=nullptr, const bool dry=false, const bool is_borning=false ); // Schedules to grow the snake on the next update void willGrow(); // [AI] Chooses a new direction for the snake - void move( Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ); + void move( const Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ); private: @@ -78,7 +78,7 @@ private: bool will_grow; //! Increases the length of the body of the snake of 1 part - void grow( const bool& is_borning ); + void grow( const bool is_borning ); bool adversary; @@ -101,25 +101,25 @@ private: std::vector> field_map; // [AI] Updates the map of the field - void updateFieldMap( Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ); + void updateFieldMap( const Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ); // [AI] As inTile(), but works on the field_map and only checks the adersary - const bool inTileAdv( const unsigned int& x, const unsigned int& y ); + const bool inTileAdv( const unsigned int x, const unsigned int y ) const; // [AI] Checks whether is there a snake in the tile, without counting as much trailing BodyParts as the number of steps - const bool inTileMinusSteps( const unsigned int& x, const unsigned int& y, const unsigned int& steps ); + const bool inTileMinusSteps( const unsigned int x, const unsigned int y, const unsigned int steps ) const; // [AI] Checks which of the surrounding positions are blocked - const std::vector checkAround( const Direction& direction, const unsigned int& x, const unsigned int& y ); + const std::vector checkAround( const Direction& direction, const unsigned int& x, const unsigned int& y ) const; // [AI] Checks if a direction is a closed path and should be avoided - const unsigned int isDeadHole( const unsigned int& start_x, const unsigned int& start_y, Direction start_direction ); + const unsigned int isDeadHole( const unsigned int& start_x, const unsigned int& start_y, Direction start_direction ) const; // [AI] Collects data about the possible movements - void collectData( std::vector& data, Direction& direction, Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ); + void collectData( std::vector& data, Direction& direction, const Snake& adv_snake, const unsigned int& food_x, const unsigned int& food_y ) const; // [AI] Processes the collected data to predict the best movement - const Direction predictDirection( std::vector>& data, std::vector weights, std::vector classes ); + const Direction predictDirection( const std::vector>& data, const std::vector& weights, const std::vector& classes ) const; }; #endif // SNAKE_H diff --git a/logdoctor/mainwindow.cpp b/logdoctor/mainwindow.cpp index 131974fa..459a871b 100644 --- a/logdoctor/mainwindow.cpp +++ b/logdoctor/mainwindow.cpp @@ -407,7 +407,7 @@ void MainWindow::readConfigs() this->remember_window = this->s2b.at( val ); } else if ( var == "Geometry" ) { - this->geometryFromString( val ); + this->setGeometryFromString( val ); } else if ( var == "WindowTheme" ) { this->window_theme_id = std::stoi( val ); @@ -687,7 +687,7 @@ void MainWindow::writeConfigs() } } else { // file does not exists, check if at least the folder exists - const std::string base_path = this->basePath( this->configs_path ); + const std::string base_path = this->parentPath( this->configs_path ); if ( IOutils::exists( base_path ) ) { if ( IOutils::isDir( base_path ) ) { if ( ! IOutils::checkDir( base_path, false, true ) ) { @@ -843,7 +843,7 @@ void MainWindow::writeConfigs() } -void MainWindow::backupDatabase() +void MainWindow::backupDatabase() const { bool proceed = true; std::error_code err; @@ -956,7 +956,7 @@ void MainWindow::backupDatabase() } -const std::string MainWindow::geometryToString() +const std::string MainWindow::geometryToString() const { QRect geometry = this->geometry(); std::string string = ""; @@ -971,7 +971,7 @@ const std::string MainWindow::geometryToString() string += this->b2s.at( this->isMaximized() ); return string; } -void MainWindow::geometryFromString( const std::string& geometry ) +void MainWindow::setGeometryFromString( const std::string& geometry ) { std::vector aux; StringOps::splitrip( aux, geometry, "," ); @@ -984,7 +984,7 @@ void MainWindow::geometryFromString( const std::string& geometry ) } -const std::string MainWindow::list2string( const std::vector& list, const bool& user_agent ) +const std::string MainWindow::list2string( const std::vector& list, const bool user_agent ) const { std::string string; if ( user_agent ) { @@ -998,7 +998,7 @@ const std::string MainWindow::list2string( const std::vector& list, } return string; } -const std::vector MainWindow::string2list( const std::string& string, const bool& user_agent ) +const std::vector MainWindow::string2list( const std::string& string, const bool user_agent ) const { std::vector list, aux; StringOps::splitrip( aux, string, " " ); @@ -1582,7 +1582,7 @@ void MainWindow::makeInitialChecks() if ( ok ) { // check LogDoctor's folders paths - for ( const std::string& path : std::vector({this->basePath(this->configs_path), this->logdoc_path, this->db_data_path, this->db_hashes_path}) ) { + for ( const std::string& path : std::vector({this->parentPath(this->configs_path), this->logdoc_path, this->db_data_path, this->db_hashes_path}) ) { if ( IOutils::exists( path ) ) { if ( IOutils::isDir( path ) ) { if ( ! IOutils::checkDir( path, true ) ) { @@ -1723,7 +1723,7 @@ void MainWindow::makeInitialChecks() } -const bool& MainWindow::checkDataDB() +const bool MainWindow::checkDataDB() { if ( ! this->initiating ) { // avoid recursions // check the db @@ -1762,7 +1762,7 @@ const bool& MainWindow::checkDataDB() ///////////////////// //// GENERAL USE //// ///////////////////// -const QString MainWindow::wsFromIndex( const int& index ) +const QString MainWindow::wsFromIndex(const int index ) const { switch (index) { case 0: @@ -1776,7 +1776,7 @@ const QString MainWindow::wsFromIndex( const int& index ) } } -const std::string MainWindow::resolvePath( const std::string& path ) +const std::string MainWindow::resolvePath( const std::string& path ) const { std::string p; try { @@ -1786,14 +1786,14 @@ const std::string MainWindow::resolvePath( const std::string& path ) } return p; } -const std::string MainWindow::basePath( const std::string& path ) +const std::string MainWindow::parentPath( const std::string& path ) const { const int stop = path.rfind( '/' ); return path.substr( 0, stop ); } // printable size with suffix and limited decimals -const QString MainWindow::printableSize( const int& bytes ) +const QString MainWindow::printableSize( const int bytes ) const { std::string size_str, size_sfx=" B"; float size = (float)bytes; @@ -1832,7 +1832,7 @@ const QString MainWindow::printableSize( const int& bytes ) } // printable speed with suffix and limited decimals -const QString MainWindow::printableSpeed( const int& bytes, const int& secs_ ) +const QString MainWindow::printableSpeed( const int bytes, const int secs_ ) const { std::string speed_str, speed_sfx=" B/s"; int secs = secs_; @@ -1874,7 +1874,7 @@ const QString MainWindow::printableSpeed( const int& bytes, const int& secs_ ) return QString::fromStdString( speed_str.substr(0, cut_index ) + speed_sfx ); } -const QString MainWindow::printableTime( const int& secs_ ) +const QString MainWindow::printableTime( const int secs_ ) const { int secs = secs_; int mins = secs / 60; @@ -2046,7 +2046,7 @@ void MainWindow::menu_actionCheckUpdates_triggered() this->window_theme_id, this->icons_theme ); this->crapup->show(); - this->crapup->versionCheck( 1.0 ); + this->crapup->versionCheck( this->version ); } } @@ -2080,7 +2080,7 @@ void MainWindow::menu_actionSnake_triggered() ////////////// //// TABS //// ////////////// -void MainWindow::switchMainTab( const int& new_index ) +void MainWindow::switchMainTab( const int new_index ) { const int old_index = this->ui->stacked_Tabs_Pages->currentIndex(); // turn off the old icon @@ -2152,7 +2152,7 @@ void MainWindow::on_button_Tab_Conf_clicked() //// STATS //// -void MainWindow::switchStatsTab( const int& new_index ) +void MainWindow::switchStatsTab( const int new_index ) { const int old_index = this->ui->stacked_Stats_Pages->currentIndex(); // turn off the old icon @@ -2278,7 +2278,7 @@ void MainWindow::on_button_Tab_StatsGlob_clicked() //////////// //// DB //// //////////// -void MainWindow::setDbWorkingState( const bool& state ) +void MainWindow::setDbWorkingState( const bool state ) { this->db_working = state; if ( ! state ) { @@ -3180,7 +3180,7 @@ void MainWindow::resetStatsCountButtons() } } -void MainWindow::startCountDrawing() +void MainWindow::makeStatsCount() { this->setDbWorkingState( true ); delete this->crapview_timer; @@ -3196,7 +3196,7 @@ void MainWindow::on_button_StatsCount_Protocol_clicked() this->resetStatsCountButtons(); this->ui->button_StatsCount_Protocol->setFlat( false ); this->count_fld = this->ui->button_StatsCount_Protocol->text(); - startCountDrawing(); + makeStatsCount(); } } @@ -3206,7 +3206,7 @@ void MainWindow::on_button_StatsCount_Method_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Method->text(); this->ui->button_StatsCount_Method->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3216,7 +3216,7 @@ void MainWindow::on_button_StatsCount_Uri_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Uri->text(); this->ui->button_StatsCount_Uri->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3226,7 +3226,7 @@ void MainWindow::on_button_StatsCount_Query_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Query->text(); this->ui->button_StatsCount_Query->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3236,7 +3236,7 @@ void MainWindow::on_button_StatsCount_Response_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Response->text(); this->ui->button_StatsCount_Response->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3246,7 +3246,7 @@ void MainWindow::on_button_StatsCount_Referrer_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Referrer->text(); this->ui->button_StatsCount_Referrer->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3256,7 +3256,7 @@ void MainWindow::on_button_StatsCount_Cookie_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Cookie->text(); this->ui->button_StatsCount_Cookie->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3266,7 +3266,7 @@ void MainWindow::on_button_StatsCount_UserAgent_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_UserAgent->text(); this->ui->button_StatsCount_UserAgent->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3276,7 +3276,7 @@ void MainWindow::on_button_StatsCount_Client_clicked() this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Client->text(); this->ui->button_StatsCount_Client->setFlat( false ); - startCountDrawing(); + makeStatsCount(); } } @@ -3776,19 +3776,19 @@ void MainWindow::makeStatsGlobals() } } else { - this->resetStatsGlobals(); + this->resetStatsGlob(); } recur_list.clear(); traffic_list.clear(); perf_list.clear(); work_list.clear(); } else { - this->resetStatsGlobals(); + this->resetStatsGlob(); } // restore this->setDbWorkingState( false ); } -void MainWindow::resetStatsGlobals() +void MainWindow::resetStatsGlob() { this->ui->label_StatsGlob_Recur_Protocol_String->setText( "-" ); this->ui->label_StatsGlob_Recur_Protocol_Count->setText( "0" ); @@ -3828,7 +3828,7 @@ void MainWindow::resetStatsGlobals() -void MainWindow::globalsButtonClicked() +void MainWindow::makeStatsGlob() { this->setDbWorkingState( true ); delete this->crapview_timer; @@ -3842,7 +3842,7 @@ void MainWindow::on_button_StatsGlob_Apache_clicked() { if ( this->checkDataDB() ) { this->glob_ws = "apache"; - this->globalsButtonClicked(); + this->makeStatsGlob(); } } @@ -3851,7 +3851,7 @@ void MainWindow::on_button_StatsGlob_Nginx_clicked() { if ( this->checkDataDB() ) { this->glob_ws = "nginx"; - this->globalsButtonClicked(); + this->makeStatsGlob(); } } @@ -3860,7 +3860,7 @@ void MainWindow::on_button_StatsGlob_Iis_clicked() { if ( this->checkDataDB() ) { this->glob_ws = "iis"; - this->globalsButtonClicked(); + this->makeStatsGlob(); } } @@ -4931,7 +4931,7 @@ void MainWindow::on_button_ConfIis_Path_Save_clicked() } // formats -const int MainWindow::getIisLogsModule() +const int MainWindow::getIisLogsModule() const { int module = 0; if ( this->ui->radio_ConfIis_Format_NCSA->isChecked() ) { diff --git a/logdoctor/mainwindow.h b/logdoctor/mainwindow.h index fa978383..c4fe4aa8 100644 --- a/logdoctor/mainwindow.h +++ b/logdoctor/mainwindow.h @@ -43,7 +43,7 @@ class MainWindow : public QMainWindow public: - MainWindow( QWidget* parent=nullptr ); + explicit MainWindow( QWidget* parent=nullptr ); ~MainWindow(); @@ -512,11 +512,11 @@ private: Ui::MainWindow *ui; // current version of LogDoctor - const float version = 2.01; + const float version = 2.02; // web servers ID constants const unsigned int APACHE_ID=11, NGINX_ID=12, IIS_ID=13; - const QString wsFromIndex( const int& index ); + const QString wsFromIndex( const int index ) const; ////////////////////////// @@ -566,7 +566,7 @@ private: \return The resulting string \see writeConfigs() */ - const std::string list2string( const std::vector& list, const bool& user_agent=false ); + const std::string list2string( const std::vector& list, const bool user_agent=false ) const; //! Retrieves a list of items from the given string /*! @@ -575,7 +575,7 @@ private: \return The resulting list \see readConfigs() */ - const std::vector string2list( const std::string& string, const bool& user_agent=false ); + const std::vector string2list( const std::string& string, const bool user_agent=false ) const; // string to bool and vice versa const std::unordered_map s2b = { {"true",true}, {"false",false} }; @@ -600,13 +600,13 @@ private: /*! \see writeConfigs() */ - const std::string geometryToString(); + const std::string geometryToString() const; //! Retrieves the window geometry from the given string /*! \see readConfigs() */ - void geometryFromString( const std::string& geometry ); + void setGeometryFromString( const std::string& geometry ); ///////////////// @@ -676,20 +676,20 @@ private: ///////////////////// //! Printable size, including suffix - const QString printableSize( const int& bytes ); + const QString printableSize( const int bytes ) const; //! Printable time, including suffix(es) - const QString printableTime( const int& seconds ); + const QString printableTime( const int seconds ) const; //! Printable speed, namely printable size over printable time - const QString printableSpeed( const int& bytes, const int& secs ); + const QString printableSpeed( const int bytes, const int secs ) const; //! Resolves the given path and returns the canonical path - const std::string resolvePath( const std::string& path ); + const std::string resolvePath( const std::string& path ) const; //! Returns the parent folder of the given path - const std::string basePath( const std::string& path ); + const std::string parentPath( const std::string& path ) const; //////////////// @@ -704,7 +704,7 @@ private: void makeInitialChecks(); //! Checks the integrity of the logs data collection database - const bool& checkDataDB(); + const bool checkDataDB(); /////////////////// @@ -718,7 +718,7 @@ private: unsigned db_backups_number = 3; //! Backs-up the logs data collection database - void backupDatabase(); + void backupDatabase() const; std::string db_data_path; std::string db_hashes_path; @@ -727,14 +727,14 @@ private: bool db_working = false; //! Called when a member begins/ends performing operations on the database - void setDbWorkingState( const bool& state ); + void setDbWorkingState( const bool state ); ////////////////// //// CRAPTABS //// ////////////////// - void switchMainTab( const int& new_index ); + void switchMainTab( const int new_index ); ///////////////// @@ -795,7 +795,7 @@ private: QTimer *crapview_timer = new QTimer(); // change tab - void switchStatsTab( const int& new_index ); + void switchStatsTab( const int new_index ); //! Queries the available dates from the db and apply to the tabs /*! @@ -812,13 +812,13 @@ private: // count QString count_fld; - void startCountDrawing(); + void makeStatsCount(); void resetStatsCountButtons(); // globals QString glob_ws; - void globalsButtonClicked(); - void resetStatsGlobals(); + void makeStatsGlob(); + void resetStatsGlob(); ///////////////// @@ -829,7 +829,7 @@ private: void refreshChartsPreview(); - const int getIisLogsModule(); + const int getIisLogsModule() const; ////////////////// diff --git a/logdoctor/modules/craphelp/craphelp.cpp b/logdoctor/modules/craphelp/craphelp.cpp index 442eb940..e4a73fb8 100644 --- a/logdoctor/modules/craphelp/craphelp.cpp +++ b/logdoctor/modules/craphelp/craphelp.cpp @@ -20,7 +20,7 @@ Craphelp::~Craphelp() } -const std::unordered_map Craphelp::getColorScheme( const int& scheme_id ) +const std::unordered_map Craphelp::getColorScheme( const int& scheme_id ) const { switch ( scheme_id ) { case 0: @@ -72,7 +72,7 @@ const std::unordered_map Craphelp::getColorScheme( const i } -void Craphelp::helpLogsFormat( const std::string& path, const QFont& font, const int &color_scheme_id ) +void Craphelp::helpLogsFormat( const std::string& path, const QFont& font, const int &color_scheme_id ) const { std::unordered_map color_scheme = this->getColorScheme( color_scheme_id ); std::string aux; diff --git a/logdoctor/modules/craphelp/craphelp.h b/logdoctor/modules/craphelp/craphelp.h index 97b5d1b1..7fadc1c1 100644 --- a/logdoctor/modules/craphelp/craphelp.h +++ b/logdoctor/modules/craphelp/craphelp.h @@ -28,12 +28,12 @@ public: \param font The font to be used \param color_scheme_id The ID of the color-scheme to be used */ - void helpLogsFormat( const std::string& path, const QFont& font, const int& color_scheme_id ); + void helpLogsFormat( const std::string& path, const QFont& font, const int& color_scheme_id ) const; private: Ui::Craphelp *ui; - const std::unordered_map getColorScheme( const int& scheme_id ); + const std::unordered_map getColorScheme( const int& scheme_id ) const; }; #endif // CRAPHELP_H diff --git a/logdoctor/modules/crapinfo/crapinfo.cpp b/logdoctor/modules/crapinfo/crapinfo.cpp index e76e5711..1599ccff 100644 --- a/logdoctor/modules/crapinfo/crapinfo.cpp +++ b/logdoctor/modules/crapinfo/crapinfo.cpp @@ -4,7 +4,7 @@ #include "modules/exceptions.h" -#include // leave this for OSX +#include // leave this here for OSX #include @@ -47,7 +47,7 @@ Crapinfo::~Crapinfo() } -void Crapinfo::getStyleSheet( QString& stylesheet, const int& theme_id ) +void Crapinfo::getStyleSheet( QString& stylesheet, const int& theme_id ) const { std::unordered_map style; switch ( theme_id ) { diff --git a/logdoctor/modules/crapinfo/crapinfo.h b/logdoctor/modules/crapinfo/crapinfo.h index d3ff4956..df8a3248 100644 --- a/logdoctor/modules/crapinfo/crapinfo.h +++ b/logdoctor/modules/crapinfo/crapinfo.h @@ -27,13 +27,13 @@ public: \param logdoc_path The path of the additional resources folder \param parent The parent Widget */ - Crapinfo( const int& window_theme_id, const QString& version, const QString& exec_path, const QString& conf_path, const QString& logdoc_path, QWidget* parent=nullptr ); + explicit Crapinfo( const int& window_theme_id, const QString& version, const QString& exec_path, const QString& conf_path, const QString& logdoc_path, QWidget* parent=nullptr ); ~Crapinfo(); private: Ui::Crapinfo *ui; - void getStyleSheet( QString& stylesheet, const int& theme_id ); + void getStyleSheet( QString& stylesheet, const int& theme_id ) const; }; #endif // CRAPINFO_H diff --git a/logdoctor/modules/craplog/craplog.cpp b/logdoctor/modules/craplog/craplog.cpp index a476d982..e731b0cb 100644 --- a/logdoctor/modules/craplog/craplog.cpp +++ b/logdoctor/modules/craplog/craplog.cpp @@ -82,7 +82,7 @@ Craplog::Craplog() ////////////////// //// SETTINGS //// -const int& Craplog::getDialogsLevel() +const int& Craplog::getDialogsLevel() const { return this->dialogs_level; } @@ -92,11 +92,11 @@ void Craplog::setDialogsLevel( const int& new_level ) this->hashOps.setDialogLevel( new_level ); } -const std::string& Craplog::getStatsDatabasePath() +const std::string& Craplog::getStatsDatabasePath() const { return this->db_stats_path; } -const std::string& Craplog::getHashesDatabasePath() +const std::string& Craplog::getHashesDatabasePath() const { return this->db_hashes_path; } @@ -110,7 +110,7 @@ void Craplog::setHashesDatabasePath( const std::string& path ) this->db_hashes_path = path + "/hashes.db"; } -const long& Craplog::getWarningSize() +const long& Craplog::getWarningSize() const { return this->warning_size; } @@ -123,11 +123,11 @@ void Craplog::setWarningSize(const long& new_size ) //////////////////// //// WARN/BLACK //// -const bool& Craplog::isBlacklistUsed( const int& web_server_id, const int& log_field_id ) +const bool& Craplog::isBlacklistUsed( const int& web_server_id, const int& log_field_id ) const { return this->blacklists.at( web_server_id ).at( log_field_id ).used; } -const bool& Craplog::isWarnlistUsed( const int& web_server_id, const int& log_field_id ) +const bool& Craplog::isWarnlistUsed( const int& web_server_id, const int& log_field_id ) const { return this->warnlists.at( web_server_id ).at( log_field_id ).used; } @@ -141,11 +141,11 @@ void Craplog::setWarnlistUsed( const int& web_server_id, const int& log_field_id this->warnlists.at( web_server_id ).at( log_field_id ).used = used; } -const std::vector& Craplog::getBlacklist( const int& web_server_id, const int& log_field_id ) +const std::vector& Craplog::getBlacklist( const int& web_server_id, const int& log_field_id ) const { return this->blacklists.at( web_server_id ).at( log_field_id ).list; } -const std::vector& Craplog::getWarnlist( const int& web_server_id, const int& log_field_id ) +const std::vector& Craplog::getWarnlist( const int& web_server_id, const int& log_field_id ) const { return this->warnlists.at( web_server_id ).at( log_field_id ).list; } @@ -259,7 +259,7 @@ const int Craplog::warnlistMoveDown( const int& web_server_id, const int& log_fi return i; } -const std::string Craplog::sanitizeBWitem( const int& log_field_id, const std::string& new_item ) +const std::string Craplog::sanitizeBWitem( const int& log_field_id, const std::string& new_item ) const { std::string sanitized_item; switch ( log_field_id ) { @@ -298,13 +298,13 @@ const std::string Craplog::sanitizeBWitem( const int& log_field_id, const std::s ///////////////// //// FORMATS //// // get the logs format string -const std::string& Craplog::getLogsFormatString( const int& web_server_id ) +const std::string& Craplog::getLogsFormatString( const int& web_server_id ) const { return this->logs_format_strings.at( web_server_id ); } // get the logs format -const FormatOps::LogsFormat& Craplog::getLogsFormat(const int& web_server_id ) +const FormatOps::LogsFormat& Craplog::getLogsFormat(const int& web_server_id ) const { return this->logs_formats.at( web_server_id ); } @@ -363,7 +363,7 @@ const bool Craplog::setIisLogFormat( const std::string& format_string, const int return success; } -const QString Craplog::getLogsFormatSample( const int& web_server_id ) +const QString Craplog::getLogsFormatSample( const int& web_server_id ) const { QString sample; if ( web_server_id == this->APACHE_ID ) { @@ -387,7 +387,7 @@ void Craplog::setCurrentWSID( const int& web_server_id ) this->setCurrentLogFormat(); } -const int& Craplog::getCurrentWSID() +const int& Craplog::getCurrentWSID() const { return this->current_WS; } @@ -399,7 +399,7 @@ void Craplog::setCurrentLogFormat() } // get the current access logs format -const FormatOps::LogsFormat& Craplog::getCurrentLogFormat() +const FormatOps::LogsFormat& Craplog::getCurrentLogFormat() const { return this->current_LF; } @@ -407,7 +407,7 @@ const FormatOps::LogsFormat& Craplog::getCurrentLogFormat() /////////////////// //// LOGS PATH //// -const std::string& Craplog::getLogsPath( const int& web_server ) +const std::string& Craplog::getLogsPath( const int& web_server ) const { return this->logs_paths.at( web_server ); } @@ -420,12 +420,12 @@ void Craplog::setLogsPath( const int& web_server, const std::string& new_path ) /////////////////// //// LOGS LIST //// // return the size of the list -const int Craplog::getLogsListSize() { +const int Craplog::getLogsListSize() const { return this->logs_list.size(); } // return the list. rescan if fresh is true -const std::vector& Craplog::getLogsList( const bool& fresh ) +const std::vector& Craplog::getLogsList( const bool fresh ) { if ( fresh ) { this->scanLogsDir(); @@ -435,7 +435,7 @@ const std::vector& Craplog::getLogsList( const bool& fresh ) // return the path of the file matching the given name -const Craplog::LogFile& Craplog::getLogFileItem( const QString& file_name ) +const Craplog::LogFile& Craplog::getLogFileItem( const QString& file_name ) const { for ( const Craplog::LogFile& item : this->logs_list ) { if ( item.name == file_name ) { @@ -518,7 +518,7 @@ void Craplog::scanLogsDir() continue; } - LogOps::LogType log_type = this->logOps.defineFileType( + const LogOps::LogType log_type = this->logOps.defineFileType( content, this->logs_formats.at( this->current_WS ) ); content.clear(); if ( log_type == LogOps::LogType::Failed ) { @@ -537,7 +537,7 @@ void Craplog::scanLogsDir() std::string hash; try { - hash = this->hashOps.digestFile( path ); + this->hashOps.digestFile( path, hash ); } catch ( GenericException& e ) { // failed to digest DialogSec::errGeneric( e.what() ); @@ -573,7 +573,7 @@ void Craplog::changeIisLogsBaseNames( const int& module_id ) throw GenericException( "Unexpected LogFormatModule ID: "+std::to_string( module_id ), true ); // leave un-catched } } -const bool Craplog::isFileNameValid( const std::string& name ) +const bool Craplog::isFileNameValid( const std::string& name ) const { bool valid = true; if ( this->logs_base_names.at( this->current_WS ).starts != "" ) { @@ -686,21 +686,21 @@ void Craplog::stopWorking() this->working = false; this->parsing = false; } -const bool& Craplog::isWorking() +const bool& Craplog::isWorking() const { return this->working; } -const bool& Craplog::isParsing() +const bool& Craplog::isParsing() const { return this->parsing; } -const bool& Craplog::editedDatabase() +const bool& Craplog::editedDatabase() const { return this->db_edited; } // performances -const unsigned int &Craplog::getPerfSize() +const unsigned int &Craplog::getPerfSize() const { return this->perf_size; } @@ -709,7 +709,7 @@ const unsigned int &Craplog::getPerfSize() this->perf_size += size; this->parsed_size += size; }*/ -const unsigned int &Craplog::getTotalSize() +const unsigned int &Craplog::getTotalSize() const { return this->total_size; } @@ -717,7 +717,7 @@ const unsigned int &Craplog::getTotalSize() { return this->parsed_size; }*/ -const unsigned int &Craplog::getParsedLines() +const unsigned int &Craplog::getParsedLines() const { return this->parsed_lines; } @@ -965,7 +965,7 @@ void Craplog::joinLogLines() void Craplog::parseLogLines() { - if ( this-> proceed && this->logs_lines.size() > 0 ) { + if ( this->proceed && this->logs_lines.size() > 0 ) { this->logOps.parseLines( this->data_collection, this->logs_lines, @@ -1071,7 +1071,7 @@ void Craplog::storeLogLines() } -const QString Craplog::printableSize( const unsigned int& bytes ) +const QString Craplog::printableSize( const unsigned int& bytes ) const { std::string size_str, size_sfx=" B"; float size = (float)bytes; @@ -1116,7 +1116,7 @@ const QString Craplog::printableSize( const unsigned int& bytes ) } -void Craplog::makeChart( const QChart::ChartTheme& theme, const std::unordered_map& fonts, QChartView* size_chart ) +void Craplog::makeChart( const QChart::ChartTheme& theme, const std::unordered_map& fonts, QChartView* size_chart ) const { const QString size_chart_name = TR::tr("Logs Size Breakdown"), diff --git a/logdoctor/modules/craplog/craplog.h b/logdoctor/modules/craplog/craplog.h index 4e4e8ad5..35944915 100644 --- a/logdoctor/modules/craplog/craplog.h +++ b/logdoctor/modules/craplog/craplog.h @@ -19,7 +19,7 @@ class Craplog { public: - Craplog(); + explicit Craplog(); //! Main work method /*! @@ -33,7 +33,7 @@ public: //// DIALOGS //// //! Returns the Dialogs level - const int& getDialogsLevel(); + const int& getDialogsLevel() const; //! Sets the new Dialogs level void setDialogsLevel( const int& new_level ); @@ -42,10 +42,10 @@ public: //// DATABASES //// //! Returns the path of the logs Collection database - const std::string& getStatsDatabasePath(); + const std::string& getStatsDatabasePath() const; //! Returns the path of the log files' Hashes database - const std::string& getHashesDatabasePath(); + const std::string& getHashesDatabasePath() const; //! Sets the new path for the logs Collection database /*! @@ -73,14 +73,14 @@ public: /*! \return The Web Server ID */ - const int& getCurrentWSID(); + const int& getCurrentWSID() const; //! Returns the currently used LogsFormat /*! \return The LogsFormat \see FormatOps::LogsFormat */ - const FormatOps::LogsFormat& getCurrentLogFormat(); + const FormatOps::LogsFormat& getCurrentLogFormat() const; //////////////////// @@ -91,14 +91,17 @@ public: \param web_server The ID of the Web Server \return The path of the logs' folder */ - const std::string& getLogsPath( const int& web_server ); + const std::string& getLogsPath( const int& web_server ) const; //! Sets a new path for the given Web Server to search the logs in /*! \param web_server The ID of the Web Server \param new_path The new path */ - void setLogsPath( const int& web_server, const std::string& new_path ); + void setLogsPath( + const int& web_server, + const std::string& new_path + ); /////////////////// @@ -120,7 +123,7 @@ public: \return Wheter it does respect the criterions or not \see LogName */ - const bool isFileNameValid( const std::string& name ); + const bool isFileNameValid( const std::string& name ) const; /////////////////// @@ -132,14 +135,14 @@ public: \return The list of log files \see LogFile, logs_list, scanLogsDir() */ - const std::vector& getLogsList( const bool& fresh=false ); + const std::vector& getLogsList( const bool fresh=false ); //! Returns the amount of log files in the list /*! \return The number of files actually in the list \see logs_list */ - const int getLogsListSize(); + const int getLogsListSize() const; //! Returns the LogFile instance of the given file /*! @@ -148,7 +151,7 @@ public: \throw GenericException \see LogFile, logs_list */ - const LogFile& getLogFileItem( const QString& file_name ); + const LogFile& getLogFileItem( const QString& file_name ) const; /*const std::string& getLogFilePath( const QString& file_name );*/ @@ -195,7 +198,7 @@ public: \return The format string \see FormatOps::LogsFormat */ - const std::string& getLogsFormatString( const int& web_server_id ); + const std::string& getLogsFormatString( const int& web_server_id ) const; //! Returns the LogsFormat currently set for the given Web Server /*! @@ -203,7 +206,7 @@ public: \return The LogsFormat instance \see FormatOps::LogsFormat */ - const FormatOps::LogsFormat& getLogsFormat( const int& web_server_id ); + const FormatOps::LogsFormat& getLogsFormat( const int& web_server_id ) const; //! Returns a sample log line for the given Web Server using the relative LogsFormat /*! @@ -212,7 +215,7 @@ public: \throw WebServerException \see FormatOps::getApacheLogSample(), FormatOps::getNginxLogSample(), FormatOps::getIisLogSample() */ - const QString getLogsFormatSample( const int& web_server_id ); + const QString getLogsFormatSample( const int& web_server_id ) const; @@ -220,7 +223,7 @@ public: //// WARNING SIZE //// //! Returns the currently set warning size for the log files - const long& getWarningSize(); + const long& getWarningSize() const; //! Sets the new warning size for the log files void setWarningSize( const long& new_size ); @@ -251,7 +254,7 @@ public: \return Whether the list is used or not \see BWlist */ - const bool& isBlacklistUsed( const int& web_server_id, const int& log_field_id ); + const bool& isBlacklistUsed( const int& web_server_id, const int& log_field_id ) const; //! Returns whether the relative warnlist is set to be used or not /*! @@ -260,7 +263,7 @@ public: \return Whether the list is used or not \see BWlist */ - const bool& isWarnlistUsed( const int& web_server_id, const int& log_field_id ); + const bool& isWarnlistUsed( const int& web_server_id, const int& log_field_id ) const; //! Sets the relative blacklist to be used or not /*! @@ -287,7 +290,7 @@ public: \return The list of items in the given blacklist \see BWlist */ - const std::vector& getBlacklist( const int& web_server_id, const int& log_field_id ); + const std::vector& getBlacklist( const int& web_server_id, const int& log_field_id ) const; //! Returns the relative items list /*! @@ -296,7 +299,7 @@ public: \return The list of items in the givenwarnlist \see BWlist */ - const std::vector& getWarnlist( const int& web_server_id, const int& log_field_id ); + const std::vector& getWarnlist( const int& web_server_id, const int& log_field_id ) const; //! Sets the relative items list /*! @@ -393,7 +396,7 @@ public: //// WORK //// //! Returns whether the database has been edited or not during the process - const bool& editedDatabase(); + const bool& editedDatabase() const; //! Various checks to be made before starting a new process /*! @@ -407,10 +410,10 @@ public: void clearDataCollection(); //! Returns whether the process is still running or not - const bool& isWorking(); + const bool& isWorking() const; //! Returns whether the process is still parsing or not - const bool& isParsing(); + const bool& isParsing() const; ////////////////////// @@ -431,13 +434,13 @@ public: /*void sumPerfSize( const unsigned& size );*/ //! Returns the size to be displayed in the main window - const unsigned int& getPerfSize(); + const unsigned int& getPerfSize() const; //! Returns the total logs size - const unsigned int& getTotalSize(); + const unsigned int& getTotalSize() const; //! Returns the parsed logs lines - const unsigned int& getParsedLines(); + const unsigned int& getParsedLines() const; /*const unsigned int& getParsedSize();*/ @@ -448,7 +451,7 @@ public: \param size_chart The widget which will display the chart \see DonutBreakdown */ - void makeChart( const QChart::ChartTheme& theme, const std::unordered_map& fonts, QChartView* size_chart ); + void makeChart( const QChart::ChartTheme& theme, const std::unordered_map& fonts, QChartView* size_chart ) const; @@ -513,7 +516,7 @@ private: \return The string to be displayed \see makeChart() */ - const QString printableSize( const unsigned int& bytes ); + const QString printableSize( const unsigned int& bytes ) const; //////////////////// //// LOGS ITEMS //// @@ -582,7 +585,7 @@ private: \throw BWlistException, GenericException \see BWlist */ - const std::string sanitizeBWitem( const int& log_field_id, const std::string& new_item ); + const std::string sanitizeBWitem( const int& log_field_id, const std::string& new_item ) const; //////////////////// diff --git a/logdoctor/modules/craplog/modules/datetime.h b/logdoctor/modules/craplog/modules/datetime.h index f853e55f..23e29bc6 100644 --- a/logdoctor/modules/craplog/modules/datetime.h +++ b/logdoctor/modules/craplog/modules/datetime.h @@ -12,7 +12,7 @@ class DateTimeOps { public: - DateTimeOps(); + explicit DateTimeOps(); //! Returns a standardized list of items representing the given date and time /*! diff --git a/logdoctor/modules/craplog/modules/donuts.h b/logdoctor/modules/craplog/modules/donuts.h index f76f629d..6d4a12b8 100644 --- a/logdoctor/modules/craplog/modules/donuts.h +++ b/logdoctor/modules/craplog/modules/donuts.h @@ -16,7 +16,7 @@ class DonutBreakdown : public QChart { public: - DonutBreakdown( QGraphicsItem* parent=nullptr, Qt::WindowFlags wFlags={} ); + explicit DonutBreakdown( QGraphicsItem* parent=nullptr, Qt::WindowFlags wFlags={} ); //! Adds a slice to the donut /*! @@ -52,7 +52,7 @@ class MainSlice : public QPieSlice public: - MainSlice( QPieSeries *breakdownSeries, QObject *parent=0 ); + explicit MainSlice( QPieSeries *breakdownSeries, QObject *parent=0 ); //! Returns the series QPieSeries *breakdownSeries() const; diff --git a/logdoctor/modules/craplog/modules/formats.cpp b/logdoctor/modules/craplog/modules/formats.cpp index 8e52fef8..f1fb7cf4 100644 --- a/logdoctor/modules/craplog/modules/formats.cpp +++ b/logdoctor/modules/craplog/modules/formats.cpp @@ -12,7 +12,7 @@ FormatOps::FormatOps() // count the new lines -const int FormatOps::countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ) +const int FormatOps::countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ) const { int nl = 0; nl += StringOps::count( initial, "\n" ); @@ -25,7 +25,7 @@ const int FormatOps::countNewLines( const std::string& initial, const std::strin // process escapes like apache -const std::string FormatOps::parseApacheEscapes( const std::string& string , const bool& strftime ) +const std::string FormatOps::parseApacheEscapes( const std::string& string , const bool strftime ) const { int i = 0, max = string.size()-1; @@ -122,7 +122,7 @@ const std::string FormatOps::parseApacheEscapes( const std::string& string , con } // process escapes like nginx -const std::string FormatOps::parseNginxEscapes( const std::string& string ) +const std::string FormatOps::parseNginxEscapes( const std::string& string ) const { int i = 0, max = string.size()-1; @@ -169,7 +169,7 @@ const std::string FormatOps::parseNginxEscapes( const std::string& string ) } // find where the field ends -const size_t FormatOps::findNginxFieldEnd( const std::string& string, const int& start ) +const size_t FormatOps::findNginxFieldEnd( const std::string& string, const int start ) const { size_t stop=start; const int max=string.size()-1; @@ -187,7 +187,7 @@ const size_t FormatOps::findNginxFieldEnd( const std::string& string, const int& } // check the given format string for unwanted characters -void FormatOps::checkIisString( const std::string& string ) +void FormatOps::checkIisString( const std::string& string ) const { for ( const char& chr : string ) { if ( !(StringOps::isAlnum( chr ) || chr == ' ' || chr == '-' || chr == ',' || chr == ':' || chr == '(' || chr == ')' || chr == '[' || chr == ']') ) { @@ -200,7 +200,7 @@ void FormatOps::checkIisString( const std::string& string ) -const FormatOps::LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) +const FormatOps::LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) const { const auto &f_map = this->APACHE_ALF; const auto &f_map_v = this->APACHE_ALF_V; @@ -482,7 +482,7 @@ const FormatOps::LogsFormat FormatOps::processApacheFormatString( const std::str } // sample -const QString FormatOps::getApacheLogSample( const LogsFormat& log_format ) +const QString FormatOps::getApacheLogSample( const LogsFormat& log_format ) const { QString sample = ""; const std::unordered_map& map = this->APACHE_ALF_SAMPLES; @@ -505,7 +505,7 @@ const QString FormatOps::getApacheLogSample( const LogsFormat& log_format ) -const FormatOps::LogsFormat FormatOps::processNginxFormatString( const std::string& f_str ) +const FormatOps::LogsFormat FormatOps::processNginxFormatString( const std::string& f_str ) const { const auto& f_map = this->NGINX_ALF; @@ -583,7 +583,7 @@ const FormatOps::LogsFormat FormatOps::processNginxFormatString( const std::stri }; } // sample -const QString FormatOps::getNginxLogSample( const LogsFormat& log_format ) +const QString FormatOps::getNginxLogSample( const LogsFormat& log_format ) const { QString sample = ""; const std::unordered_map& map = this->NGINX_ALF_SAMPLES; @@ -606,7 +606,7 @@ const QString FormatOps::getNginxLogSample( const LogsFormat& log_format ) -const FormatOps::LogsFormat FormatOps::processIisFormatString( const std::string& f_str, const int& l_mod ) +const FormatOps::LogsFormat FormatOps::processIisFormatString( const std::string& f_str, const int& l_mod ) const { this->checkIisString( f_str ); std::string initial="", final=""; @@ -683,7 +683,7 @@ const FormatOps::LogsFormat FormatOps::processIisFormatString( const std::string }; } // sample -const QString FormatOps::getIisLogSample( const LogsFormat& log_format ) +const QString FormatOps::getIisLogSample( const LogsFormat& log_format ) const { QString sample = ""; const std::unordered_map& map = this->IIS_ALF_SAMPLES; diff --git a/logdoctor/modules/craplog/modules/formats.h b/logdoctor/modules/craplog/modules/formats.h index 1cb16625..516c6a74 100644 --- a/logdoctor/modules/craplog/modules/formats.h +++ b/logdoctor/modules/craplog/modules/formats.h @@ -15,7 +15,7 @@ class FormatOps { public: - FormatOps(); + explicit FormatOps(); //! Structure which holds informations about a log format struct LogsFormat { @@ -35,7 +35,7 @@ public: \throw LogFormatException \see LogsFormat */ - const LogsFormat processApacheFormatString( const std::string& format_string ); + const LogsFormat processApacheFormatString( const std::string& format_string ) const; //! Processes the given string to extrapolate the format for Nginx /*! @@ -44,7 +44,7 @@ public: \throw LogFormatException \see LogsFormat */ - const LogsFormat processNginxFormatString( const std::string& format_string ); + const LogsFormat processNginxFormatString( const std::string& format_string ) const; //! Processes the given string to extrapolate the format for the IIS /*! @@ -54,7 +54,7 @@ public: \throw LogFormatException \see LogsFormat */ - const LogsFormat processIisFormatString( const std::string& format_string, const int& log_module ); + const LogsFormat processIisFormatString( const std::string& format_string, const int& log_module ) const; ///////////////// @@ -66,7 +66,7 @@ public: \return The sample line \see LogsFormat, Craplog::getLogsFormatSample() */ - const QString getApacheLogSample( const LogsFormat& log_format ); + const QString getApacheLogSample( const LogsFormat& log_format ) const; //! Returns a log line sample based on the given format /*! @@ -74,7 +74,7 @@ public: \return The sample line \see LogsFormat, Craplog::getLogsFormatSample() */ - const QString getNginxLogSample( const LogsFormat& log_format ); + const QString getNginxLogSample( const LogsFormat& log_format ) const; //! Returns a log line sample based on the given format /*! @@ -82,7 +82,7 @@ public: \return The sample line \see LogsFormat, Craplog::getLogsFormatSample() */ - const QString getIisLogSample( const LogsFormat& log_format ); + const QString getIisLogSample( const LogsFormat& log_format ) const; private: @@ -96,7 +96,7 @@ private: \throw LogFormatException \see processApacheFormatString() */ - const std::string parseApacheEscapes( const std::string& string, const bool& strftime=false ); + const std::string parseApacheEscapes( const std::string& string, const bool strftime=false ) const; //! Parses the escapes (backslashes) and returns the resulting string /*! @@ -106,7 +106,7 @@ private: \throw LogFormatException \see processNginxFormatString() */ - const std::string parseNginxEscapes( const std::string& string ); + const std::string parseNginxEscapes( const std::string& string ) const; //! Conuts how many new lines are there in the format /*! @@ -117,7 +117,7 @@ private: \return The number of new lines in a single log line \see LogsFormat, processApacheFormatString(), processNginxFormatString() */ - const int countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ); + const int countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ) const; //! Finds the end of a Nginx log field /*! @@ -126,7 +126,7 @@ private: \return The ending poin of the field in the string \see processNginxFormatString() */ - const size_t findNginxFieldEnd( const std::string& string, const int& start ); + const size_t findNginxFieldEnd( const std::string& string, const int start ) const; //! Checks whether the format string contains invalid characters or not /*! @@ -134,7 +134,7 @@ private: \throw LogFormatException \see processIisFormatString */ - void checkIisString( const std::string& string ); + void checkIisString( const std::string& string ) const; ///////////////// diff --git a/logdoctor/modules/craplog/modules/hash.cpp b/logdoctor/modules/craplog/modules/hash.cpp index 0a7aaf7f..e723f7f1 100644 --- a/logdoctor/modules/craplog/modules/hash.cpp +++ b/logdoctor/modules/craplog/modules/hash.cpp @@ -24,7 +24,7 @@ void HashOps::setDialogLevel( const int& new_level ) // reads the database holding the already used hashes -bool HashOps::loadUsedHashesLists( const std::string& db_path ) +const bool HashOps::loadUsedHashesLists( const std::string& db_path ) { bool successful = true; const QString db_name = QString::fromStdString( db_path.substr( db_path.find_last_of( '/' ) + 1 ) ); @@ -74,7 +74,7 @@ bool HashOps::loadUsedHashesLists( const std::string& db_path ) // returns the hash -std::string HashOps::digestFile( const std::string& file_path ) +void HashOps::digestFile( const std::string& file_path, std::string& hash ) const { std::string content; try { @@ -122,12 +122,12 @@ std::string HashOps::digestFile( const std::string& file_path ) content.clear(); uint8_t * digest = sha.digest(); // return the hex digest - return SHA256::toString(digest); + hash.append( SHA256::toString(digest) ); } // check if the given hash is from a file which has been used already -bool HashOps::hasBeenUsed( const std::string &file_hash, const int& web_server_id) +const bool HashOps::hasBeenUsed( const std::string &file_hash, const int& web_server_id) const { bool found = false; for ( const std::string &hash : this->hashes.at( web_server_id ) ) { @@ -141,7 +141,7 @@ bool HashOps::hasBeenUsed( const std::string &file_hash, const int& web_server_i // insert the given hash/es in the relative list -bool HashOps::insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const int& web_server_id ) +const bool HashOps::insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const int& web_server_id ) { bool successful = true; try { @@ -174,7 +174,7 @@ bool HashOps::insertUsedHash( QSqlQuery& query, const QString& db_name, const st } -bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector &hashes, const int& web_server_id ) +const bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector &hashes, const int& web_server_id ) { bool proceed = true; diff --git a/logdoctor/modules/craplog/modules/hash.h b/logdoctor/modules/craplog/modules/hash.h index 1335c1a9..94b7b9c9 100644 --- a/logdoctor/modules/craplog/modules/hash.h +++ b/logdoctor/modules/craplog/modules/hash.h @@ -18,7 +18,7 @@ class HashOps { public: - HashOps(); + explicit HashOps(); //! Sets the new Dialogs level @@ -30,7 +30,7 @@ public: \return Whether the operation has been successful or not \see hashes */ - bool loadUsedHashesLists( const std::string& db_path ); + const bool loadUsedHashesLists( const std::string& db_path ); //! Returns the hash resulting from the content of the given file /*! @@ -39,7 +39,7 @@ public: \throw GenericException \see SHA256 */ - std::string digestFile( const std::string& file_path ); + void digestFile( const std::string& file_path, std::string& hash ) const; //! Checks if the given hash equals one which is already in the list /*! @@ -48,18 +48,7 @@ public: \return Whether the hash is already in the list or not \see hashes */ - bool hasBeenUsed( const std::string& file_hash, const int& web_server_id ); - - //! Inserts a hashe in the corresponding database table - /*! - \param db_query Query instance, already initialized - \param db_name The name of the database, eventually used by dialogs - \param hash The hash to insert - \param web_server_id The ID of the Web Server which generated the file - \return Whether the operation has been successful or not - \see insertUsedHashes() - */ - bool insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const int& web_server_id ); + const bool hasBeenUsed( const std::string& file_hash, const int& web_server_id ) const; //! Inserts multiple hashes in the corresponding database table /*! @@ -69,7 +58,7 @@ public: \return Whether the operation has been successful or not \see insertUsedHash() */ - bool insertUsedHashes( const std::string& db_path, const std::vector& hashes, const int& web_server_id ); + const bool insertUsedHashes( const std::string& db_path, const std::vector& hashes, const int& web_server_id ); private: @@ -81,12 +70,12 @@ private: const int NGINX_ID = 12; const int IIS_ID = 13; - // List of Web Servers names + // List of Web Servers names for database tables const std::unordered_map ws_names = { {this->APACHE_ID, "apache"}, {this->NGINX_ID, "nginx"}, - {this->IIS_ID, "iis"} }; - + {this->IIS_ID, "iis"} + }; // Lists of used files' hashes // { web_server_id : { hashes } } @@ -96,6 +85,11 @@ private: {this->IIS_ID, {}} }; + + // Called by insertUsedHashes() + // Inserts a hash in the corresponding database table + const bool insertUsedHash( QSqlQuery& query, const QString& db_name, const std::string& hash, const int& web_server_id ); + }; #endif // HASH_H diff --git a/logdoctor/modules/craplog/modules/logs.cpp b/logdoctor/modules/craplog/modules/logs.cpp index e628956f..1b0b734a 100644 --- a/logdoctor/modules/craplog/modules/logs.cpp +++ b/logdoctor/modules/craplog/modules/logs.cpp @@ -13,7 +13,7 @@ LogOps::LogOps() } -LogOps::LogType LogOps::defineFileType( const std::vector& lines, const FormatOps::LogsFormat& format ) +const LogOps::LogType LogOps::defineFileType( const std::vector& lines, const FormatOps::LogsFormat& format ) const { if ( lines.size() == 0 ) { // empty content @@ -24,7 +24,7 @@ LogOps::LogType LogOps::defineFileType( const std::vector& lines, c LogOps::LogType log_type; // real type assignment - log_type = this->LogType::Failed; + log_type = LogOps::LogType::Failed; for ( const std::string& line : lines ) { // scan if ( this->deepTypeCheck( line, format ) ) { @@ -48,7 +48,7 @@ LogOps::LogType LogOps::defineFileType( const std::vector& lines, c } -bool LogOps::deepTypeCheck( const std::string& line, const FormatOps::LogsFormat& format ) +const bool LogOps::deepTypeCheck( const std::string& line, const FormatOps::LogsFormat& format ) const { int n_sep_found=0, n_blank_sep=0, n_sep = format.separators.size(); @@ -138,7 +138,7 @@ bool LogOps::deepTypeCheck( const std::string& line, const FormatOps::LogsFormat } -void LogOps::cleanLines( std::vector &lines ) +void LogOps::cleanLines( std::vector& lines ) const { std::vector aux; for ( const std::string& line : lines ) { @@ -147,7 +147,7 @@ void LogOps::cleanLines( std::vector &lines ) aux.push_back( line ); } } - lines = aux; + lines = std::move( aux ); } @@ -451,15 +451,15 @@ void LogOps::resetPerfData() this->parsed_size = 0; this->parsed_lines = 0; } -const unsigned LogOps::getTotalSize() +const unsigned LogOps::getTotalSize() const { return this->total_size; } -const unsigned LogOps::getParsedSize() +const unsigned LogOps::getParsedSize() const { return this->parsed_size; } -const unsigned LogOps::getParsedLines() +const unsigned LogOps::getParsedLines() const { return this->parsed_lines; } diff --git a/logdoctor/modules/craplog/modules/logs.h b/logdoctor/modules/craplog/modules/logs.h index 3454c70f..3fc9876a 100644 --- a/logdoctor/modules/craplog/modules/logs.h +++ b/logdoctor/modules/craplog/modules/logs.h @@ -15,7 +15,7 @@ class LogOps { public: - LogOps(); + explicit LogOps(); //! Enumerates log file types /*! @@ -35,16 +35,18 @@ public: \return The resulting file type \see LogType, deepTypeCheck(), FormatOps::LogsFormat */ - LogType defineFileType( + const LogType defineFileType( const std::vector& lines, - const FormatOps::LogsFormat& format ); + const FormatOps::LogsFormat& format + ) const; //! Removes commented lines from the given list /*! \param lines The lines to clean */ void cleanLines( - std::vector& lines ); + std::vector& lines + ) const; //! Parses log lines to extract data /*! @@ -57,15 +59,16 @@ public: void parseLines( std::vector>& data, const std::vector& lines, - const FormatOps::LogsFormat& format ); + const FormatOps::LogsFormat& format + ); //! Resets the performances data void resetPerfData(); // share perf data with craplog - const unsigned getTotalSize(); //!< Returns the total size of the logs lines. \see total_size - const unsigned getParsedSize(); //!< Returns the parsed logs size. \see parsed_size - const unsigned getParsedLines(); //!< Returns the number of parsed log lines. \see parsed_lines + const unsigned getTotalSize() const; //!< Returns the total size of the logs lines. \see total_size + const unsigned getParsedSize() const; //!< Returns the parsed logs size. \see parsed_size + const unsigned getParsedLines() const; //!< Returns the number of parsed log lines. \see parsed_lines private: @@ -125,9 +128,10 @@ private: \return Whether the line respects the format or not \see defineFileType(), FormatOps::LogsFormat */ - bool deepTypeCheck( + const bool deepTypeCheck( const std::string& line, - const FormatOps::LogsFormat& format ); + const FormatOps::LogsFormat& format + ) const; //! Parses a line to extract data /*! @@ -139,7 +143,8 @@ private: */ const std::unordered_map parseLine( const std::string& line, - const FormatOps::LogsFormat& format ); + const FormatOps::LogsFormat& format + ); // temporary vars unsigned total_size=0; //!< Total size of the parsed logs. \see getTotalSize() diff --git a/logdoctor/modules/craplog/modules/store.h b/logdoctor/modules/craplog/modules/store.h index 06224fd2..242d7100 100644 --- a/logdoctor/modules/craplog/modules/store.h +++ b/logdoctor/modules/craplog/modules/store.h @@ -11,7 +11,7 @@ class StoreOps { public: - StoreOps(); + explicit StoreOps(); //! Stores the data collection in the logs Collection database /*! diff --git a/logdoctor/modules/crapup/crapup.cpp b/logdoctor/modules/crapup/crapup.cpp index 8503f6d1..441cd376 100644 --- a/logdoctor/modules/crapup/crapup.cpp +++ b/logdoctor/modules/crapup/crapup.cpp @@ -59,7 +59,7 @@ void Crapup::closeEvent( QCloseEvent* event ) } -void Crapup::versionCheck( const float& v ) +void Crapup::versionCheck( const float v ) { bool successful = false; float version = -1; @@ -278,7 +278,7 @@ void Crapup::rotateImg() } -void Crapup::getStyleSheet( QString& stylesheet, const int& theme_id ) +void Crapup::getStyleSheet( QString& stylesheet, const int& theme_id ) const { std::unordered_map style; switch ( theme_id ) { diff --git a/logdoctor/modules/crapup/crapup.h b/logdoctor/modules/crapup/crapup.h index e157a4ad..c3e05054 100644 --- a/logdoctor/modules/crapup/crapup.h +++ b/logdoctor/modules/crapup/crapup.h @@ -19,6 +19,7 @@ namespace Ui { class Crapup : public QWidget { Q_OBJECT + public: //! Class constructor @@ -27,7 +28,7 @@ public: \param icons theme The theme of the icons \param parent The parent Widget */ - Crapup( const int& window_theme_id, const QString& icons_theme, QWidget* parent=nullptr ); + explicit Crapup( const int& window_theme_id, const QString& icons_theme, QWidget* parent=nullptr ); ~Crapup(); @@ -36,7 +37,7 @@ public: \param current_version The running version of LogDoctor \throw GenericException */ - void versionCheck( const float& current_version ); + void versionCheck( const float current_version ); signals: @@ -69,7 +70,7 @@ private: QTimer* img_timer = nullptr; - void getStyleSheet( QString& stylesheet, const int& theme_id ); + void getStyleSheet( QString& stylesheet, const int& theme_id ) const; bool request_aborted; diff --git a/logdoctor/modules/crapview/crapview.cpp b/logdoctor/modules/crapview/crapview.cpp index 858c8b1b..ede95287 100644 --- a/logdoctor/modules/crapview/crapview.cpp +++ b/logdoctor/modules/crapview/crapview.cpp @@ -12,11 +12,11 @@ Crapview::Crapview() } -const int& Crapview::getDialogsLevel() +const int& Crapview::getDialogsLevel() const { return this->dialogs_level; } -void Crapview::setDialogsLevel( const int& new_level ) +void Crapview::setDialogsLevel( const int new_level ) { this->dialogs_level = new_level; } @@ -28,7 +28,7 @@ void Crapview::setDbPath( const std::string& path ) } -const QString Crapview::printableDate( const QString& year, const int& month, const QString& day ) +const QString Crapview::printableDate( const QString& year, const int month, const QString& day ) const { QString date = QString("%1-").arg( year ); if ( month < 10 ) { @@ -45,7 +45,7 @@ const QString Crapview::printableDate( const QString& year, const int& month, co } -const QString Crapview::printableDate( const int& year, const int& month, const int& day ) +const QString Crapview::printableDate( const int year, const int month, const int day ) const { QString date; if ( year < 10 ) { @@ -67,7 +67,7 @@ const QString Crapview::printableDate( const int& year, const int& month, const } -const QString Crapview::printableTime( const int& hour, const int& minute, const int& second ) +const QString Crapview::printableTime( const int hour, const int minute, const int second ) const { QString time; if ( hour < 10 ) { @@ -89,7 +89,7 @@ const QString Crapview::printableTime( const int& hour, const int& minute, const } -const QString Crapview::printableWarn( const int& value ) +const QString Crapview::printableWarn( const int value ) const { if ( value == 0 ) { return TR::tr( BOOLS__FALSE.c_str() ); @@ -99,16 +99,18 @@ const QString Crapview::printableWarn( const int& value ) } -const QString Crapview::parseBooleanFilter( const QString& filter_str ) +const QString Crapview::parseBooleanFilter( const QString& filter_str ) const { QString aux = filter_str; - aux = aux.replace( TR::tr(BOOLS__TRUE.c_str()), "1", Qt::CaseSensitivity::CaseInsensitive ); - aux = aux.replace( TR::tr(BOOLS__FALSE.c_str()),"0", Qt::CaseSensitivity::CaseInsensitive ); + aux = aux.replace( "NOT TRUE", "!= 1", Qt::CaseSensitivity::CaseInsensitive ); + aux = aux.replace( "NOT FALSE", "!= 0", Qt::CaseSensitivity::CaseInsensitive ); + aux = aux.replace( "TRUE", "1", Qt::CaseSensitivity::CaseInsensitive ); + aux = aux.replace( "FALSE", "0", Qt::CaseSensitivity::CaseInsensitive ); return this->parseNumericFilter( aux ); } -const QString Crapview::parseNumericFilter( const QString& filter_str ) +const QString Crapview::parseNumericFilter( const QString& filter_str ) const { QString final_str = ""; if ( filter_str.size() > 0 ) { @@ -157,7 +159,7 @@ const QString Crapview::parseNumericFilter( const QString& filter_str ) } -const QString Crapview::parseTextualFilter( const QString& filter_str ) +const QString Crapview::parseTextualFilter( const QString& filter_str ) const { QString aux = filter_str; if ( filter_str.size() > 0 ) { @@ -188,12 +190,12 @@ void Crapview::clearDates() this->dates.clear(); } -const QString Crapview::getLogFieldString ( const int& field_id ) +const QString Crapview::getLogFieldString ( const int field_id ) const { return TR::tr( this->dbQuery.FIELDS.at( field_id ).c_str() ); } -const int Crapview::getLogFieldID ( const QString& field_str ) +const int Crapview::getLogFieldID ( const QString& field_str ) const { int f=0; for ( const auto& [id,str] : this->dbQuery.FIELDS ) { @@ -206,7 +208,7 @@ const int Crapview::getLogFieldID ( const QString& field_str ) } -const int Crapview::getMonthNumber( const QString& month_str ) +const int Crapview::getMonthNumber( const QString& month_str ) const { int m=0; for ( const auto& [num,str] : this->dbQuery.MONTHS ) { @@ -220,7 +222,7 @@ const int Crapview::getMonthNumber( const QString& month_str ) -const QStringList Crapview::getYears( const QString& web_server ) +const QStringList Crapview::getYears( const QString& web_server ) const { QStringList years; if ( this->dates.size() > 0 ) { @@ -233,7 +235,7 @@ const QStringList Crapview::getYears( const QString& web_server ) } return years; } -const QStringList Crapview::getMonths( const QString& web_server, const QString& year ) +const QStringList Crapview::getMonths( const QString& web_server, const QString& year ) const { QStringList months; if ( this->dates.size() > 0 ) { @@ -249,7 +251,7 @@ const QStringList Crapview::getMonths( const QString& web_server, const QString& } return months; } -const QStringList Crapview::getDays( const QString& web_server, const QString& year, const QString& month ) +const QStringList Crapview::getDays( const QString& web_server, const QString& year, const QString& month ) const { QStringList days; if ( this->dates.size() > 0 ) { @@ -268,12 +270,12 @@ const QStringList Crapview::getDays( const QString& web_server, const QString& y } return days; } -const QStringList Crapview::getHours() +const QStringList Crapview::getHours() const { return QStringList({"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"}); } -const QStringList Crapview::getFields( const std::string& tab ) +const QStringList Crapview::getFields( const std::string& tab ) const { QStringList list; for ( const auto& field : this->fields.at( tab ) ) { @@ -286,7 +288,7 @@ const QStringList Crapview::getFields( const std::string& tab ) //////////////// //// CHARTS //// //////////////// -void Crapview::updateWarn( QTableWidget* table , const QString& web_server ) +void Crapview::updateWarn( QTableWidget* table , const QString& web_server ) const { std::vector> updates; // { (rowid, warn) } for ( int i=0; irowCount(); i++ ) { @@ -300,10 +302,9 @@ void Crapview::updateWarn( QTableWidget* table , const QString& web_server ) } } this->dbQuery.updateWarnings( web_server, updates ); - updates.clear(); } -void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& hour ) +void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& hour ) const { Result result; this->dbQuery.getWarnCounts( @@ -488,7 +489,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const -void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& protocol, const QString& method, const QString& uri, const QString& query, const QString& response ) +void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& protocol, const QString& method, const QString& uri, const QString& query, const QString& response ) const { Result result; this->dbQuery.getSpeedData( @@ -637,7 +638,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons -void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& field ) +void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& field ) const { Result result; this->dbQuery.getItemsCount( @@ -694,7 +695,7 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons -void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, const QString& to_year, const QString& to_month, const QString& to_day, const QString& field , const QString& filter ) +void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, const QString& to_year, const QString& to_month, const QString& to_day, const QString& field , const QString& filter ) const { Result result; this->dbQuery.getDaytimeCounts( @@ -817,7 +818,7 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t -void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, const QString& to_year, const QString& to_month, const QString& to_day, const QString& field_1, const QString& filter_1, const QString& field_2, const QString& filter_2 ) +void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, const QString& to_year, const QString& to_month, const QString& to_day, const QString& field_1, const QString& filter_1, const QString& field_2, const QString& filter_2 ) const { bool period = true; Result result; @@ -940,7 +941,7 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& // calculate global informations -const bool Crapview::calcGlobals( std::vector>& recur_list, std::vector>& traffic_list, std::vector>& perf_list, std::vector& work_list, const QString& web_server ) +const bool Crapview::calcGlobals( std::vector>& recur_list, std::vector>& traffic_list, std::vector>& perf_list, std::vector& work_list, const QString& web_server ) const { bool result = false; diff --git a/logdoctor/modules/crapview/crapview.h b/logdoctor/modules/crapview/crapview.h index cd9fc4c9..bf56be11 100644 --- a/logdoctor/modules/crapview/crapview.h +++ b/logdoctor/modules/crapview/crapview.h @@ -17,17 +17,17 @@ class Crapview { public: - Crapview(); + explicit Crapview(); //! Returns the Dialogs level - const int& getDialogsLevel(); + const int& getDialogsLevel() const; //! Sets the new Dialogs level - void setDialogsLevel( const int& new_level ); + void setDialogsLevel( const int new_level ); - //! Sets the new charts theme to use - void setChartsTheme( const int& new_theme_id ); + /*//! Sets the new charts theme to use + void setChartsTheme( const int& new_theme_id );*/ //! Sets the new path for the logs Collection database @@ -39,24 +39,26 @@ public: //! Parses a filter for a database field with boolean type /*! + Boolean filters are not locale-dependant, + meaning that English syntax must be used (TRUE,FALSE) \param field_str The given filter \return The resulting filter to apply to the query */ - const QString parseBooleanFilter( const QString& filter_str ); + const QString parseBooleanFilter( const QString& filter_str ) const; //! Parses a filter for a log field with integer type /*! \param field_str The given filter \return The resulting filter to apply to the query */ - const QString parseNumericFilter( const QString& filter_str ); + const QString parseNumericFilter( const QString& filter_str ) const; //! Parses a filter for a log field with text type /*! \param field_str The given filter \return The resulting filter to apply to the query */ - const QString parseTextualFilter( const QString& filter_str ); + const QString parseTextualFilter( const QString& filter_str ) const; //! Returns the printable log field corresponding to the given ID @@ -65,14 +67,14 @@ public: \param field_id The ID of the log fiels \return The printable field */ - const QString getLogFieldString ( const int& field_id ); + const QString getLogFieldString ( const int field_id ) const; //! Returns the log field ID corresponding to the given printable field /*! \param field_str The log field \return The ID of the log field */ - const int getLogFieldID ( const QString& field_str ); + const int getLogFieldID ( const QString& field_str ) const; //! Returns the month number corresponding to the given printable month @@ -80,7 +82,7 @@ public: \param month_Str The printable month name \return The month number */ - const int getMonthNumber( const QString& month_str ); + const int getMonthNumber( const QString& month_str ) const; //! Refreshes the list of the dates which are available in the database @@ -95,7 +97,7 @@ public: \param web_server The printable Web Server name \return The list of yearss which are avaliable */ - const QStringList getYears( const QString& web_server ); + const QStringList getYears( const QString& web_server ) const; //! Returns le list of available months in the given year, for the given web server /*! @@ -103,7 +105,7 @@ public: \param year The year \return The list of printable month names which are avaliable */ - const QStringList getMonths( const QString& web_server, const QString& year ); + const QStringList getMonths( const QString& web_server, const QString& year ) const; //! Returns le list of available days in the given month and year, for the given web server /*! @@ -112,13 +114,13 @@ public: \param month The printable month name \return The list of days which are avaliable */ - const QStringList getDays( const QString& web_server, const QString& year, const QString& month ); + const QStringList getDays( const QString& web_server, const QString& year, const QString& month ) const; //! Returns all the hours of the day /*! \return The list of all the hours */ - const QStringList getHours(); + const QStringList getHours() const; //! Returns a list of the fields for the given tab @@ -126,7 +128,7 @@ public: \param tab The stats tab \return The list of fields */ - const QStringList getFields( const std::string& tab ); + const QStringList getFields( const std::string& tab ) const; //! Updates the database applying the changes which have been made to the table @@ -136,7 +138,8 @@ public: */ void updateWarn( QTableWidget* table, - const QString& web_server ); + const QString& web_server + ) const; //! Draws the chart and fills the table for the Warnings stats @@ -156,7 +159,8 @@ public: const QChart::ChartTheme& theme, const std::unordered_map& fonts, const QString& web_server, - const QString& year, const QString& month, const QString& day, const QString& hour ); + const QString& year, const QString& month, const QString& day, const QString& hour + ) const; //! Draws the chart and fills the table for the Speed stats @@ -181,7 +185,8 @@ public: const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, - const QString& protocol, const QString& method, const QString& uri, const QString& query, const QString& response ); + const QString& protocol, const QString& method, const QString& uri, const QString& query, const QString& response + ) const; //! Draws the chart and fills the table for the Counts stats @@ -202,7 +207,8 @@ public: const std::unordered_map& fonts, const QString& web_server, const QString& year, const QString& month, const QString& day, - const QString& field ); + const QString& field + ) const; //! Draws the chart for the Daytime stats @@ -227,7 +233,8 @@ public: const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, const QString& to_year, const QString& to_month, const QString& to_day, - const QString& field, const QString& filter ); + const QString& field, const QString& filter + ) const; //! Draws the chart for the Relational stats @@ -253,9 +260,10 @@ public: const std::unordered_map& fonts, const QString& web_server, const QString& from_year, const QString& from_month, const QString& from_day, - const QString& to_year, const QString& to_month, const QString& to_day, + const QString& to_year, const QString& to_month, const QString& to_day, const QString& field_1, const QString& filter_1, - const QString& field_2, const QString& filter_2 ); + const QString& field_2, const QString& filter_2 + ) const; //! Retrieves the data to fill the Globals stats @@ -272,7 +280,8 @@ public: std::vector>& traffic_list, std::vector>& perf_list, std::vector& work_list, - const QString& web_server ); + const QString& web_server + ) const; private: @@ -300,7 +309,7 @@ private: }; - //! Returns a string of the given date in the format YYY-MM-DD + //! Returns a string of the given date in the format YYYY-MM-DD /*! \overload const QString printableDate(const int& year, const int& month, const int& day) \param year The year @@ -308,16 +317,20 @@ private: \param day The day \return The printable date */ - const QString printableDate( const QString& year, const int& month, const QString& day ); + const QString printableDate( + const QString& year, const int month, const QString& day + ) const; - //! Returns a string of the given date in the format YYY-MM-DD + //! Returns a string of the given date in the format YYYY-MM-DD /*! \param year The year \param month The month \param day The day \return The printable date */ - const QString printableDate( const int& year, const int& month, const int& day ); + const QString printableDate( + const int year, const int month, const int day + ) const; //! Returns a string of the given time in the format HH:MM:SS /*! @@ -326,7 +339,9 @@ private: \param second The second \return The printable time */ - const QString printableTime( const int& hour, const int& minute, const int& second ); + const QString printableTime( + const int hour, const int minute, const int second + ) const; //! Returns a string corresponding to the given value /*! @@ -334,7 +349,7 @@ private: \param value The value to convert \return The corresponding printable string */ - const QString printableWarn( const int& value ); + const QString printableWarn( const int value ) const; // converr Web Servers names to Web Server IDs diff --git a/logdoctor/modules/crapview/modules/query.cpp b/logdoctor/modules/crapview/modules/query.cpp index c24b2902..0ff91842 100644 --- a/logdoctor/modules/crapview/modules/query.cpp +++ b/logdoctor/modules/crapview/modules/query.cpp @@ -18,7 +18,7 @@ DbQuery::DbQuery() } -void DbQuery::setDialogLevel(const int& new_level ) +void DbQuery::setDialogLevel(const int new_level ) { this->dialog_level = new_level; } @@ -30,7 +30,7 @@ void DbQuery::setDbPath( const std::string& path ) } -const int DbQuery::getMinuteGap( const int& minute , const int& gap ) +const int DbQuery::getMinuteGap( const int minute, const int gap ) const { int m = -1; if ( minute < 0 || minute >= 60 ) { @@ -48,7 +48,7 @@ const int DbQuery::getMinuteGap( const int& minute , const int& gap ) return m; } -const int DbQuery::getMonthDays( const int& year, const int& month ) +const int DbQuery::getMonthDays( const int year, const int month ) const { int n_days; switch (month) { @@ -71,7 +71,7 @@ const int DbQuery::getMonthDays( const int& year, const int& month ) return n_days; } -const int DbQuery::getMonthsCount( const QString& from_year, const QString& from_month, const QString& to_year, const QString& to_month ) +const int DbQuery::getMonthsCount( const QString& from_year, const QString& from_month, const QString& to_year, const QString& to_month ) const { int from_year_, from_month_, to_year_, to_month_; try { @@ -86,7 +86,7 @@ const int DbQuery::getMonthsCount( const QString& from_year, const QString& from return this->getMonthsCount( from_year_, from_month_, to_year_, to_month_ ); } -const int DbQuery::getMonthsCount( const int& from_year, const int& from_month, const int& to_year, const int& to_month ) +const int DbQuery::getMonthsCount( const int& from_year, const int& from_month, const int& to_year, const int& to_month ) const { int n_months = 0; if ( from_year == to_year ) { @@ -108,7 +108,7 @@ const int DbQuery::getMonthsCount( const int& from_year, const int& from_month, } -const int DbQuery::getMonthNumber( const QString& month_str ) +const int DbQuery::getMonthNumber( const QString& month_str ) const { int m=0; for ( const auto& [num,str] : this->MONTHS ) { @@ -133,7 +133,7 @@ const int DbQuery::getMonthNumber( const QString& month_str ) return f; }*/ -const QString DbQuery::getDbField( const QString& tr_fld ) +const QString DbQuery::getDbField( const QString& tr_fld ) const { QString f; for ( const auto& [id,str] : this->FIELDS ) { @@ -296,7 +296,7 @@ void DbQuery::refreshDates( Result& result ) // update the values for the warnings -void DbQuery::updateWarnings( const QString& web_server, const std::vector>& updates ) +void DbQuery::updateWarnings( const QString& web_server, const std::vector>& updates ) const { bool successful = true; @@ -349,7 +349,7 @@ void DbQuery::updateWarnings( const QString& web_server, const std::vector& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& hour_ ) +void DbQuery::getWarnCounts( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& hour_ ) const { bool successful = true; stats_warn_items_t items; // std::vector>>> @@ -493,7 +493,7 @@ void DbQuery::getWarnCounts( Result& result, const QString& // get day-time values for the time-taken field -void DbQuery::getSpeedData( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& protocol_f, const QString& method_f, const QString& uri_f, const QString& query_f, const QString& response_f ) +void DbQuery::getSpeedData( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& protocol_f, const QString& method_f, const QString& uri_f, const QString& query_f, const QString& response_f ) const { bool successful = true; stats_speed_items_t data; // std::vector>> @@ -848,7 +848,7 @@ void DbQuery::getSpeedData( Result& result, const QString& // get, group and count identical items of a specific field in a date -void DbQuery::getItemsCount( Result& result, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& log_field ) +void DbQuery::getItemsCount( Result& result, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& log_field ) const { bool successful = true; QHash aux_items; @@ -950,7 +950,7 @@ void DbQuery::getItemsCount( Result& result, const QString& // get and count items with a 10 minutes gap for every hour of the day -void DbQuery::getDaytimeCounts( Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_, const QString& field_filter ) +void DbQuery::getDaytimeCounts( Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_, const QString& field_filter ) const { bool successful = true; stats_day_items_t data = { // std::unordered_map> @@ -1206,7 +1206,7 @@ void DbQuery::getDaytimeCounts( Result& result, const QString // get and count how many times a specific item value brought to another -void DbQuery::getRelationalCountsDay( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) +void DbQuery::getRelationalCountsDay( Result& result, const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) const { bool successful = true; stats_relat_items_t data; // std::vector> @@ -1454,7 +1454,7 @@ void DbQuery::getRelationalCountsDay( Result& result, const -void DbQuery::getRelationalCountsPeriod( Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) +void DbQuery::getRelationalCountsPeriod( Result& result, const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_1_, const QString& field_filter_1, const QString& log_field_2_, const QString& field_filter_2 ) const { bool successful = true; stats_relat_items_t data; // std::vector> @@ -1845,7 +1845,7 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co -const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unordered_map>>& dates, std::vector>& recurs, std::tuple& traf_date, std::unordered_map& traf_day, std::unordered_map& traf_hour, std::vector& perf_time, std::vector& perf_sent, std::vector& perf_receiv, long& req_count ) +const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unordered_map>>& dates, std::vector>& recurs, std::tuple& traf_date, std::unordered_map& traf_day, std::unordered_map& traf_hour, std::vector& perf_time, std::vector& perf_sent, std::vector& perf_receiv, long& req_count ) const { bool successful = true; diff --git a/logdoctor/modules/crapview/modules/query.h b/logdoctor/modules/crapview/modules/query.h index f3b89af0..34704a7f 100644 --- a/logdoctor/modules/crapview/modules/query.h +++ b/logdoctor/modules/crapview/modules/query.h @@ -13,7 +13,7 @@ class DbQuery { public: - DbQuery(); + explicit DbQuery(); // convert log fields IDs to log fields const std::unordered_map FIELDS = { @@ -39,7 +39,7 @@ public: //! Returns the Dialogs level - void setDialogLevel( const int& new_level ); + void setDialogLevel( const int new_level ); //! Sets the path for the logs Collection database @@ -64,7 +64,8 @@ public: const QString& from_year, const QString& from_month, const QString& to_year, - const QString& to_month ); + const QString& to_month + ) const; //! Refreshes the dates which are available in the database @@ -81,7 +82,8 @@ public: */ void updateWarnings( const QString& web_server, - const std::vector>& updates ); + const std::vector>& updates + ) const; //! Retrieves the data needed for the Warnings statistics /*! @@ -98,7 +100,8 @@ public: const QString& year_, const QString& month_, const QString& day_, - const QString& hour_ ); + const QString& hour_ + ) const; //! Retrieves the data needed for the Speed statistics @@ -115,16 +118,17 @@ public: \param response_f The filter for the Response field */ void getSpeedData( - Result& result, - const QString& web_server, - const QString& year_, - const QString& month_, - const QString& day_, - const QString& protocol_f, - const QString& method_f, - const QString& uri_f, - const QString& query_f, - const QString& response_f ); + Result& result, + const QString& web_server, + const QString& year_, + const QString& month_, + const QString& day_, + const QString& protocol_f, + const QString& method_f, + const QString& uri_f, + const QString& query_f, + const QString& response_f + ) const; //! Retrieves the data needed for the Counts statistics @@ -142,7 +146,8 @@ public: const QString& year, const QString& month, const QString& day, - const QString& log_field ); + const QString& log_field + ) const; //! Retrieves the data needed for the Daytime statistics @@ -163,7 +168,8 @@ public: const QString& web_server, const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, - const QString& log_field_, const QString& field_filter ); + const QString& log_field_, const QString& field_filter + ) const; //! Retrieves the data needed for the Relationsl statistics @@ -185,7 +191,8 @@ public: const QString& web_server, const QString& year_, const QString& month_, const QString& day_, const QString& log_field_1_, const QString& field_filter_1, - const QString& log_field_2_, const QString& field_filter_2 ); + const QString& log_field_2_, const QString& field_filter_2 + ) const; //! Retrieves the data needed for the Relational statistics /*! @@ -210,7 +217,8 @@ public: const QString& from_year_, const QString& from_month_, const QString& from_day_, const QString& to_year_, const QString& to_month_, const QString& to_day_, const QString& log_field_1_, const QString& field_filter_1, - const QString& log_field_2_, const QString& field_filter_2 ); + const QString& log_field_2_, const QString& field_filter_2 + ) const; //! Retrieves the data needed for the Global statistics @@ -237,7 +245,8 @@ public: std::vector& perf_time, std::vector& perf_sent, std::vector& perf_receiv, - long& req_count ); + long& req_count + ) const; private: @@ -259,27 +268,27 @@ private: // convert log fields to database fields const std::unordered_map LogFields_to_DbFields = { - {this->FIELDS.at( 0), "warning"}, - {this->FIELDS.at(10), "protocol"}, - {this->FIELDS.at(11), "method"}, - {this->FIELDS.at(12), "uri"}, - {this->FIELDS.at(13), "query"}, - {this->FIELDS.at(14), "response"}, - {this->FIELDS.at(15), "time_taken"}, - {this->FIELDS.at(16), "bytes_sent"}, - {this->FIELDS.at(17), "bytes_received"}, - {this->FIELDS.at(18), "referrer"}, - {this->FIELDS.at(20), "client"}, - {this->FIELDS.at(21), "user_agent"}, - {this->FIELDS.at(22), "cookie"} - }; + {this->FIELDS.at( 0), "warning"}, + {this->FIELDS.at(10), "protocol"}, + {this->FIELDS.at(11), "method"}, + {this->FIELDS.at(12), "uri"}, + {this->FIELDS.at(13), "query"}, + {this->FIELDS.at(14), "response"}, + {this->FIELDS.at(15), "time_taken"}, + {this->FIELDS.at(16), "bytes_sent"}, + {this->FIELDS.at(17), "bytes_received"}, + {this->FIELDS.at(18), "referrer"}, + {this->FIELDS.at(20), "client"}, + {this->FIELDS.at(21), "user_agent"}, + {this->FIELDS.at(22), "cookie"} + }; //! Returns the database field corresponding to the relative log field /*! \param tr_fld The log field, hendles translated text \return The database field */ - const QString getDbField( const QString& tr_fld ); + const QString getDbField( const QString& tr_fld ) const; /*const int getLogFieldID ( const QString& field_str );*/ @@ -291,7 +300,7 @@ private: \return The gap index \throw DateTimeException */ - const int getMinuteGap( const int& minute, const int& gap=10 ); + const int getMinuteGap( const int minute, const int gap=10 ) const; //! Returns the number of days for a given month @@ -301,14 +310,14 @@ private: \return The number of days \throw DateTimeException */ - const int getMonthDays( const int& year, const int& month ); + const int getMonthDays( const int year, const int month ) const; //! Returns the month number in the year /*! \param month_str The month \return The month number */ - const int getMonthNumber( const QString& month_str ); + const int getMonthNumber( const QString& month_str ) const; //! Returns the number of months in a given period @@ -321,7 +330,8 @@ private: */ const int getMonthsCount( const int& from_year, const int& from_month, - const int& to_year, const int& to_month ); + const int& to_year, const int& to_month + ) const; }; #endif // QUERY_H diff --git a/logdoctor/modules/dialogs.h b/logdoctor/modules/dialogs.h index 61b43815..e121af7b 100644 --- a/logdoctor/modules/dialogs.h +++ b/logdoctor/modules/dialogs.h @@ -15,7 +15,7 @@ class DialogSec : public QObject Q_OBJECT public: - DialogSec(); + explicit DialogSec(); ///////////////// //// GENERIC //// diff --git a/logdoctor/modules/dialogs/dialogbool.h b/logdoctor/modules/dialogs/dialogbool.h index 2c69b654..81a05618 100644 --- a/logdoctor/modules/dialogs/dialogbool.h +++ b/logdoctor/modules/dialogs/dialogbool.h @@ -24,7 +24,7 @@ public: \param text The message \param parent The parent Widget */ - DialogBool( const QString& title, const QString& text, QWidget *parent=nullptr ); + explicit DialogBool( const QString& title, const QString& text, QWidget *parent=nullptr ); ~DialogBool(); private slots: diff --git a/logdoctor/modules/dialogs/dialogdia.h b/logdoctor/modules/dialogs/dialogdia.h index b67e37c5..accee7aa 100644 --- a/logdoctor/modules/dialogs/dialogdia.h +++ b/logdoctor/modules/dialogs/dialogdia.h @@ -27,7 +27,7 @@ public: \param abort Whether to show the ABORT button or not \param parent The parent Widget */ - DialogDia( const QString& title, const QString& text, const bool& ignore=true, const bool& discard=true, const bool& abort=true, QWidget *parent=nullptr ); + explicit DialogDia( const QString& title, const QString& text, const bool& ignore=true, const bool& discard=true, const bool& abort=true, QWidget *parent=nullptr ); ~DialogDia(); private slots: diff --git a/logdoctor/modules/dialogs/dialogmsg.h b/logdoctor/modules/dialogs/dialogmsg.h index cc2d1cd5..e6cf228c 100644 --- a/logdoctor/modules/dialogs/dialogmsg.h +++ b/logdoctor/modules/dialogs/dialogmsg.h @@ -25,7 +25,7 @@ public: \param additional Additional informations, usually an error message \param parent The parent Widget */ - DialogMsg( const QString& title, const QString& text, const QString& additional, const int& type, QWidget *parent=nullptr ); + explicit DialogMsg( const QString& title, const QString& text, const QString& additional, const int& type, QWidget *parent=nullptr ); ~DialogMsg(); private slots: diff --git a/logdoctor/modules/exceptions.cpp b/logdoctor/modules/exceptions.cpp index 78dc771e..8b1b96ce 100644 --- a/logdoctor/modules/exceptions.cpp +++ b/logdoctor/modules/exceptions.cpp @@ -6,7 +6,7 @@ ///////////////// //// GENERIC //// -GenericException::GenericException( const std::string& msg, const bool& to_sys ) +GenericException::GenericException( const std::string& msg, const bool to_sys ) { if ( to_sys ) { // when sys, leave un-catched std::cout << "LogDoctor: Exception: " << msg << std::endl; @@ -23,7 +23,7 @@ const QString& GenericException::what() //////////////////// //// WEB SERVER //// -WebServerException::WebServerException(const std::string& msg ) // leave un-catched +WebServerException::WebServerException( const std::string& msg ) // leave un-catched { std::cout << "LogDoctor: WebServerException: " << msg << std::endl; std::cerr << "LogDoctor: WebServerException: " << msg << std::endl; @@ -37,7 +37,7 @@ WebServerException::WebServerException(const std::string& msg ) // leave un-catc //////////////////// //// LOG FORMAT //// -LogFormatException::LogFormatException(const std::string& msg ) +LogFormatException::LogFormatException( const std::string& msg ) { std::cout << "LogDoctor: LogFormatException: " << msg << std::endl; std::cerr << "LogDoctor: LogFormatException: " << msg << std::endl; @@ -67,7 +67,7 @@ const QString& LogParserException::what() /////////////////// //// DATE-TIME //// -DateTimeException::DateTimeException(const std::string& msg ) // leave un-catched +DateTimeException::DateTimeException( const std::string& msg ) // leave un-catched { std::cout << "LogDoctor: DateTimeException: " << msg << std::endl; std::cerr << "LogDoctor: DateTimeException: " << msg << std::endl; diff --git a/logdoctor/modules/exceptions.h b/logdoctor/modules/exceptions.h index d0ee465e..6de1f997 100644 --- a/logdoctor/modules/exceptions.h +++ b/logdoctor/modules/exceptions.h @@ -12,7 +12,7 @@ */ class GenericException : public std::exception { public: - GenericException( const std::string& msg , const bool& to_sys=false ); + explicit GenericException( const std::string& msg, const bool to_sys=false ); const QString& what(); private: @@ -26,7 +26,7 @@ private: */ class WebServerException : public std::exception { public: - WebServerException( const std::string& msg ); + explicit WebServerException( const std::string& msg ); /*const QString& what(); private: @@ -40,7 +40,7 @@ private: */ class LogFormatException : public std::exception { public: - LogFormatException( const std::string& msg ); + explicit LogFormatException( const std::string& msg ); const QString& what(); private: @@ -54,7 +54,7 @@ private: */ class LogParserException : public std::exception { public: - LogParserException( const std::string& txt, const std::string& val ); + explicit LogParserException( const std::string& txt, const std::string& val ); const QString& what(); private: @@ -68,7 +68,7 @@ private: */ class DateTimeException : public std::exception { public: - DateTimeException( const std::string& msg ); + explicit DateTimeException( const std::string& msg ); /*const QString& what(); private: @@ -82,7 +82,7 @@ private: */ class BWlistException : public std::exception { public: - BWlistException( const std::string& msg ); + explicit BWlistException( const std::string& msg ); /*const QString& what(); private: diff --git a/logdoctor/modules/tb.cpp b/logdoctor/modules/tb.cpp index 2edd840a..da2f6517 100644 --- a/logdoctor/modules/tb.cpp +++ b/logdoctor/modules/tb.cpp @@ -9,17 +9,17 @@ TextBrowser::TextBrowser() // getters -const bool& TextBrowser::getWideLinesUsage() +const bool& TextBrowser::getWideLinesUsage() const { return this->wide_lines; } -const int& TextBrowser::getColorSchemeID() +const int& TextBrowser::getColorSchemeID() const { return this->color_scheme_id; } -const std::unordered_map& TextBrowser::getColorScheme() +const std::unordered_map& TextBrowser::getColorScheme() const { return this->color_scheme; } @@ -29,12 +29,12 @@ const std::unordered_map& TextBrowser::getColorScheme() return this->font_size; }*/ -const QString& TextBrowser::getFontFamily() +const QString& TextBrowser::getFontFamily() const { return this->font_family; } -const QFont& TextBrowser::getFont() +const QFont& TextBrowser::getFont() const { return this->font; } @@ -70,7 +70,7 @@ void TextBrowser::setFont( const QFont& font ) // preview -void TextBrowser::makePreview( QString& content ) +void TextBrowser::makePreview( QString& content ) const { content += QString("color_scheme_id > 0 ) { @@ -79,7 +79,7 @@ void TextBrowser::makePreview( QString& content ) this->color_scheme.at("text") ); } content += ">"; - if ( wide_lines ) { + if ( this->wide_lines ) { content += "
    "; } for ( int i=0; i<32; i++ ) { diff --git a/logdoctor/modules/tb.h b/logdoctor/modules/tb.h index 4bc62a4b..60b914c6 100644 --- a/logdoctor/modules/tb.h +++ b/logdoctor/modules/tb.h @@ -14,28 +14,28 @@ class TextBrowser { public: - TextBrowser(); + explicit TextBrowser(); ///////////////// //// GETTERS //// //! Returns whether the wide lines option is set to be used or not - const bool& getWideLinesUsage(); + const bool& getWideLinesUsage() const; //! Returns the ID of the color scheme in use - const int& getColorSchemeID(); + const int& getColorSchemeID() const; //! Returns the color scheme in use - const std::unordered_map& getColorScheme(); + const std::unordered_map& getColorScheme() const; /*const int& getFontSize();*/ //! Returns the family of the font in use - const QString& getFontFamily(); + const QString& getFontFamily() const; //! Returns the font in use - const QFont& getFont(); + const QFont& getFont() const; ///////////////// @@ -61,7 +61,7 @@ public: /*! \param content Will hold the preview string */ - void makePreview( QString& content ); + void makePreview( QString& content ) const; private: diff --git a/logdoctor/translations/LogDoctor_es_ES.ts b/logdoctor/translations/LogDoctor_es_ES.ts index 07db2760..ee13f0f3 100644 --- a/logdoctor/translations/LogDoctor_es_ES.ts +++ b/logdoctor/translations/LogDoctor_es_ES.ts @@ -1997,12 +1997,12 @@ Los campos marcados como 'DISCARDED' se analizaron correctamente, pero blacklist - + copy copia - + copies copias @@ -2010,17 +2010,17 @@ Los campos marcados como 'DISCARDED' se analizaron correctamente, pero RichText - + Select a file from the list Seleccione un archivo de la lista - + to inspect its content para inspeccionar su contenido - + Failed to read Fracaso en la lectura @@ -2145,80 +2145,80 @@ Los campos marcados como 'DISCARDED' se analizaron correctamente, pero VERDADERO - + Log Lines Marked as Warning Líneas Marcadas como Advertencia - + Time Taken to Serve Requests Tiempo Necesario para Atender las Solicitudes - + Others Otros - - + + Time of Day Count Recuento de la Hora del Día - - + + from de - - + + to a - + Unexpected WebServer WebServer inesperdado - + An error occured while processing Ocurrió un error durante el procesamiento - + An error occured while processing dates Ocurrió un error al procesar las fechas - + An error occured while parsing %1 from the database Ocurrió un error al procesar los %1 en la base de datos - + Years Años - + Months Meses - + Days Días - + Value responsible for the error Valor responsable del error - + Database table name Nombre de la tabla de la base de datos diff --git a/logdoctor/translations/LogDoctor_fr_FR.ts b/logdoctor/translations/LogDoctor_fr_FR.ts index bc1a7d1f..e182ba19 100644 --- a/logdoctor/translations/LogDoctor_fr_FR.ts +++ b/logdoctor/translations/LogDoctor_fr_FR.ts @@ -1997,12 +1997,12 @@ Les champs marqués comme 'DISCARDED' ont été analysés correctement blacklist - + copy copie - + copies copies @@ -2010,17 +2010,17 @@ Les champs marqués comme 'DISCARDED' ont été analysés correctement RichText - + Select a file from the list Sélectionnez un fichier dans la liste - + to inspect its content pour inspecter son contenu - + Failed to read Echec en lecture @@ -2145,80 +2145,80 @@ Les champs marqués comme 'DISCARDED' ont été analysés correctement VRAI - + Log Lines Marked as Warning Lignes Marquées comme Avertissement - + Time Taken to Serve Requests Temps Pris pour Traiter les Demandes - + Others Autres - - + + Time of Day Count Compter les Heures de la Journée - - + + from de - - + + to à - + Unexpected WebServer WebServer inattendu - + An error occured while processing Une erreur s'est produite lors du traitement - + An error occured while processing dates Une erreur s'est produite lors du traitement des dates - + An error occured while parsing %1 from the database Erreur lors du traitement de '%1' dans la database - + Years Ans - + Months Mois - + Days Journées - + Value responsible for the error Valeur responsable de l'erreur - + Database table name Nom de la table de la base de données diff --git a/logdoctor/translations/LogDoctor_pt_BR.ts b/logdoctor/translations/LogDoctor_pt_BR.ts index 44014832..41f82465 100644 --- a/logdoctor/translations/LogDoctor_pt_BR.ts +++ b/logdoctor/translations/LogDoctor_pt_BR.ts @@ -1996,12 +1996,12 @@ Campos marcados como 'DISCARDED' analisados ​​corretamente, mas o lista negra - + copy copia - + copies copias @@ -2009,17 +2009,17 @@ Campos marcados como 'DISCARDED' analisados ​​corretamente, mas o RichText - + Select a file from the list Selecione um arquivo da lista - + to inspect its content para inspecionar seu conteúdo - + Failed to read Falha em ler @@ -2144,80 +2144,80 @@ Campos marcados como 'DISCARDED' analisados ​​corretamente, mas o VERDADEIRO - + Log Lines Marked as Warning Linhas Marcadas como Aviso - + Time Taken to Serve Requests Tempo Necessário para Atender às Solicitações - + Others Outros - - + + Time of Day Count Contagem de Horas do Dia - - + + from de - - + + to a - + Unexpected WebServer Servidor Web inesperado - + An error occured while processing Ocorreu um erro durante o processamento - + An error occured while processing dates Ocorreu um erro ao processar as datas - + An error occured while parsing %1 from the database Ocorreu um erro ao processar %1 na base de dados - + Years Anos - + Months Meses - + Days Dias - + Value responsible for the error Valor responsável pelo erro - + Database table name Nome da tabela do banco de dados diff --git a/logdoctor/utilities/checks.h b/logdoctor/utilities/checks.h index 623ca31f..483b1c0c 100644 --- a/logdoctor/utilities/checks.h +++ b/logdoctor/utilities/checks.h @@ -16,7 +16,7 @@ class CheckSec { public: - CheckSec(); + explicit CheckSec(); //! Checks the structure's integrity of the Collection database /*! diff --git a/logdoctor/utilities/colors.h b/logdoctor/utilities/colors.h index 7ad89063..e8024246 100644 --- a/logdoctor/utilities/colors.h +++ b/logdoctor/utilities/colors.h @@ -16,7 +16,7 @@ class ColorSec { public: - ColorSec(); + explicit ColorSec(); //! Provides a map with pre-made colors static const std::unordered_map getColors(); diff --git a/logdoctor/utilities/gzip.h b/logdoctor/utilities/gzip.h index 90ac4465..3a3060bd 100644 --- a/logdoctor/utilities/gzip.h +++ b/logdoctor/utilities/gzip.h @@ -11,7 +11,7 @@ class GZutils { public: - GZutils(); + explicit GZutils(); //! Reads a GZipped file /*! diff --git a/logdoctor/utilities/io.h b/logdoctor/utilities/io.h index c1345734..3bee335c 100644 --- a/logdoctor/utilities/io.h +++ b/logdoctor/utilities/io.h @@ -13,7 +13,7 @@ class IOutils { public: - IOutils(); + explicit IOutils(); //! Checks the existence of a file/folder /*! diff --git a/logdoctor/utilities/result.cpp b/logdoctor/utilities/result.cpp index 3c64d909..eaf4a02c 100644 --- a/logdoctor/utilities/result.cpp +++ b/logdoctor/utilities/result.cpp @@ -17,7 +17,7 @@ Result::Result( const bool ok, const T& data ) } template -Result::operator bool() +Result::operator bool() const { return this->result; } @@ -37,7 +37,7 @@ const bool Result::isErr() */ template -const T& Result::getData() +const T& Result::getData() const { if ( this->result ) { return this->data; diff --git a/logdoctor/utilities/result.h b/logdoctor/utilities/result.h index d477c0e3..8d8c1e07 100644 --- a/logdoctor/utilities/result.h +++ b/logdoctor/utilities/result.h @@ -16,10 +16,10 @@ template class Result { public: - Result(); - Result( const bool ok, const T& data ); + explicit Result(); + explicit Result( const bool ok, const T& data ); - explicit operator bool(); + explicit operator bool() const; /* //! Checks if the operation was successful @@ -30,7 +30,7 @@ public: */ //! Returns the data - const T& getData(); + const T& getData() const; private: diff --git a/logdoctor/utilities/rtf.cpp b/logdoctor/utilities/rtf.cpp index 41a56b8d..02e7c4a4 100644 --- a/logdoctor/utilities/rtf.cpp +++ b/logdoctor/utilities/rtf.cpp @@ -18,9 +18,10 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co // enrich the text rich_content.clear(); rich_content.reserve( content.size() ); - rich_content += QString(" 0 ) { - rich_content += " style=\"background:" + colors.at("background") + "; color:" + colors.at("text") + "\""; + rich_content += QString(" style=\"background:%1; color:%2\"") + .arg( colors.at("background"), colors.at("text") ); } rich_content += ">"; if ( wide_lines == true ) { @@ -41,7 +42,7 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co if ( wide_lines == true ) { rich_line += "
    "; } - rich_content.push_back( rich_line ); + rich_content.append( rich_line ); continue; } i = 0; @@ -203,10 +204,10 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co if ( wide_lines == true ) { rich_line += "
    "; } - rich_content.push_back( rich_line ); + rich_content+= rich_line; } lines.clear(); - rich_content.push_back(""); + rich_content += ""; } diff --git a/logdoctor/utilities/rtf.h b/logdoctor/utilities/rtf.h index 6278d38d..7265babd 100644 --- a/logdoctor/utilities/rtf.h +++ b/logdoctor/utilities/rtf.h @@ -18,7 +18,7 @@ class RichText : public QObject Q_OBJECT public: - RichText(); + explicit RichText(); //! Enriches the content of a log file with HTML/CSS code /*! @@ -31,7 +31,8 @@ public: QString& rich_content, const std::string& content, const FormatOps::LogsFormat& logs_format, - TextBrowser& TB ); + TextBrowser& TB + ); //! Provides the default string /*! diff --git a/logdoctor/utilities/strings.cpp b/logdoctor/utilities/strings.cpp index 3f302756..13546ce2 100644 --- a/logdoctor/utilities/strings.cpp +++ b/logdoctor/utilities/strings.cpp @@ -8,7 +8,7 @@ StringOps::StringOps() } -const int StringOps::count(const std::string& str, const std::string& flag, const bool& consecutives ) +const int StringOps::count( const std::string& str, const std::string& flag, const bool consecutives ) { size_t start=0, aux_start=0, count=0; while (true) { diff --git a/logdoctor/utilities/strings.h b/logdoctor/utilities/strings.h index 4c180543..6a57f5f2 100644 --- a/logdoctor/utilities/strings.h +++ b/logdoctor/utilities/strings.h @@ -12,7 +12,7 @@ class StringOps { public: - StringOps(); + explicit StringOps(); //! Count the occurrences of the given sequence in the given string @@ -20,7 +20,7 @@ public: \param str The target string \return The number of occurrences */ - static const int count( const std::string& str, const std::string& flag, const bool& consecutives=true ); + static const int count( const std::string& str, const std::string& flag, const bool consecutives=true ); //! Checks whether a string only contains numeric characters /*! diff --git a/logdoctor/utilities/stylesheets.cpp b/logdoctor/utilities/stylesheets.cpp index 0ad3b928..49b7e4b6 100644 --- a/logdoctor/utilities/stylesheets.cpp +++ b/logdoctor/utilities/stylesheets.cpp @@ -10,7 +10,7 @@ StyleSec::StyleSec() } -void StyleSec::getStyleSheet( QString& stylesheet, const QString& icons_theme, const int& theme_id ) +void StyleSec::getStyleSheet( QString& stylesheet, const QString& icons_theme, const int theme_id ) { std::unordered_map style_map; switch ( theme_id ) { diff --git a/logdoctor/utilities/stylesheets.h b/logdoctor/utilities/stylesheets.h index ca760b58..8651e944 100644 --- a/logdoctor/utilities/stylesheets.h +++ b/logdoctor/utilities/stylesheets.h @@ -13,7 +13,7 @@ class StyleSec { public: - StyleSec(); + explicit StyleSec(); //! Provides the requested stylesheet /*! @@ -21,7 +21,7 @@ public: \param icons_theme The theme selected for the Icons \param theme_id The theme selected for the Window */ - static void getStyleSheet( QString& stylesheet, const QString& icons_theme, const int& theme_id ); + static void getStyleSheet( QString& stylesheet, const QString& icons_theme, const int theme_id ); private: From d34d122d1f9f94972a2172fc0a66749d8e702a99 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Mon, 23 Jan 2023 21:51:19 +0100 Subject: [PATCH 08/36] Improvements Added shared mutex for Craplog and LogOps --- logdoctor/modules/craplog/craplog.cpp | 30 +++++++++++++++------- logdoctor/modules/craplog/craplog.h | 11 ++++---- logdoctor/modules/craplog/modules/logs.cpp | 28 +++++++++++++++----- logdoctor/modules/craplog/modules/logs.h | 18 ++++++++++--- 4 files changed, 63 insertions(+), 24 deletions(-) diff --git a/logdoctor/modules/craplog/craplog.cpp b/logdoctor/modules/craplog/craplog.cpp index e731b0cb..dd50edf8 100644 --- a/logdoctor/modules/craplog/craplog.cpp +++ b/logdoctor/modules/craplog/craplog.cpp @@ -27,6 +27,8 @@ Craplog::Craplog() //////////////////////// //// INITIALIZATION //// //////////////////////// + // shared mutex + this->logOps.setMutex( &this->mutex ); // blacklists / whitelists for ( int i=this->APACHE_ID; i<=this->IIS_ID; i++ ) { this->warnlists.emplace( i, std::unordered_map() ); @@ -665,6 +667,7 @@ const bool Craplog::isFileNameValid( const std::string& name ) const //// WORKK //// void Craplog::startWorking() { + std::unique_lock lock( this->mutex ); this->working = true; this->parsing = true; this->proceed = true; @@ -683,15 +686,18 @@ void Craplog::startWorking() } void Craplog::stopWorking() { + std::unique_lock lock( this->mutex ); this->working = false; this->parsing = false; } -const bool& Craplog::isWorking() const +const bool& Craplog::isWorking() { + std::unique_lock lock( this->mutex ); return this->working; } -const bool& Craplog::isParsing() const +const bool& Craplog::isParsing() { + std::unique_lock lock( this->mutex ); return this->parsing; } const bool& Craplog::editedDatabase() const @@ -700,39 +706,45 @@ const bool& Craplog::editedDatabase() const } // performances -const unsigned int &Craplog::getPerfSize() const +const unsigned &Craplog::getPerfSize() { + std::unique_lock lock( this->mutex ); return this->perf_size; } /*void Craplog::sumPerfSize( const unsigned& size ) { + std::unique_lock lock( this->mutex ); this->perf_size += size; this->parsed_size += size; }*/ -const unsigned int &Craplog::getTotalSize() const +const unsigned &Craplog::getTotalSize() { + std::unique_lock lock( this->mutex ); return this->total_size; } -/*const unsigned int &Craplog::getParsedSize() +/*const unsigned &Craplog::getParsedSize() { + std::unique_lock lock( this->mutex ); return this->parsed_size; }*/ -const unsigned int &Craplog::getParsedLines() const +const unsigned &Craplog::getParsedLines() { + std::unique_lock lock( this->mutex ); return this->parsed_lines; } -void Craplog::sumWarningsSize( const unsigned int& size ) +void Craplog::sumWarningsSize( const unsigned& size ) { this->warnlisted_size += size; } -void Craplog::sumBlacklistededSize( const unsigned int& size ) +void Craplog::sumBlacklistededSize( const unsigned& size ) { this->blacklisted_size += size; } void Craplog::collectPerfData() { + std::unique_lock lock( this->mutex ); this->parsed_size = this->logOps.getParsedSize(); this->parsed_lines = this->logOps.getParsedLines(); this->perf_size = this->parsed_size; @@ -1071,7 +1083,7 @@ void Craplog::storeLogLines() } -const QString Craplog::printableSize( const unsigned int& bytes ) const +const QString Craplog::printableSize( const unsigned& bytes ) const { std::string size_str, size_sfx=" B"; float size = (float)bytes; diff --git a/logdoctor/modules/craplog/craplog.h b/logdoctor/modules/craplog/craplog.h index 35944915..8511fdc3 100644 --- a/logdoctor/modules/craplog/craplog.h +++ b/logdoctor/modules/craplog/craplog.h @@ -410,10 +410,10 @@ public: void clearDataCollection(); //! Returns whether the process is still running or not - const bool& isWorking() const; + const bool& isWorking(); //! Returns whether the process is still parsing or not - const bool& isParsing() const; + const bool& isParsing(); ////////////////////// @@ -434,13 +434,13 @@ public: /*void sumPerfSize( const unsigned& size );*/ //! Returns the size to be displayed in the main window - const unsigned int& getPerfSize() const; + const unsigned int& getPerfSize(); //! Returns the total logs size - const unsigned int& getTotalSize() const; + const unsigned int& getTotalSize(); //! Returns the parsed logs lines - const unsigned int& getParsedLines() const; + const unsigned int& getParsedLines(); /*const unsigned int& getParsedSize();*/ @@ -485,6 +485,7 @@ private: bool working = false; bool parsing = false; bool proceed = false; + std::mutex mutex; //! Sets the working state /*! diff --git a/logdoctor/modules/craplog/modules/logs.cpp b/logdoctor/modules/craplog/modules/logs.cpp index 1b0b734a..49a731b3 100644 --- a/logdoctor/modules/craplog/modules/logs.cpp +++ b/logdoctor/modules/craplog/modules/logs.cpp @@ -13,6 +13,12 @@ LogOps::LogOps() } +void LogOps::setMutex( std::mutex* craplog_mutex ) +{ + this->mutex = craplog_mutex; +} + + const LogOps::LogType LogOps::defineFileType( const std::vector& lines, const FormatOps::LogsFormat& format ) const { if ( lines.size() == 0 ) { @@ -255,7 +261,10 @@ const std::unordered_map LogOps::parseLine( const std::string& } // process the field - this->parsed_size += fld_str.size(); + { + std::unique_lock lock( *this->mutex ); + this->parsed_size += fld_str.size(); + } if ( fld_str != "" ) { int fld_id = this->field2id.at(fld); @@ -410,9 +419,11 @@ const std::unordered_map LogOps::parseLine( const std::string& // set the default warning mark ( 0=false ) to default status data.emplace( 99, "0" ); - - this->total_size += line_size; - this->parsed_lines ++; + { + std::unique_lock lock( *this->mutex ); + this->total_size += line_size; + this->parsed_lines ++; + } return data; } @@ -451,15 +462,18 @@ void LogOps::resetPerfData() this->parsed_size = 0; this->parsed_lines = 0; } -const unsigned LogOps::getTotalSize() const +const unsigned LogOps::getTotalSize() { + std::unique_lock lock( *this->mutex ); return this->total_size; } -const unsigned LogOps::getParsedSize() const +const unsigned LogOps::getParsedSize() { + std::unique_lock lock( *this->mutex ); return this->parsed_size; } -const unsigned LogOps::getParsedLines() const +const unsigned LogOps::getParsedLines() { + std::unique_lock lock( *this->mutex ); return this->parsed_lines; } diff --git a/logdoctor/modules/craplog/modules/logs.h b/logdoctor/modules/craplog/modules/logs.h index 3fc9876a..eb622a7b 100644 --- a/logdoctor/modules/craplog/modules/logs.h +++ b/logdoctor/modules/craplog/modules/logs.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "modules/craplog/modules/formats.h" @@ -17,6 +18,14 @@ class LogOps public: explicit LogOps(); + + //! Receives the mutex to be shared with Craplog + /*! + \param craplog_mutex The mutex from Craplog + */ + void setMutex( std::mutex* craplog_mutex=nullptr ); + + //! Enumerates log file types /*! File types used to decide whether a file should be considered valid or not @@ -66,9 +75,9 @@ public: void resetPerfData(); // share perf data with craplog - const unsigned getTotalSize() const; //!< Returns the total size of the logs lines. \see total_size - const unsigned getParsedSize() const; //!< Returns the parsed logs size. \see parsed_size - const unsigned getParsedLines() const; //!< Returns the number of parsed log lines. \see parsed_lines + const unsigned getTotalSize(); //!< Returns the total size of the logs lines. \see total_size + const unsigned getParsedSize(); //!< Returns the parsed logs size. \see parsed_size + const unsigned getParsedLines(); //!< Returns the number of parsed log lines. \see parsed_lines private: @@ -146,6 +155,9 @@ private: const FormatOps::LogsFormat& format ); + // a mutex shared with craplog + std::mutex* mutex = nullptr; + // temporary vars unsigned total_size=0; //!< Total size of the parsed logs. \see getTotalSize() unsigned parsed_size=0; //!< Size of the parsed logs. \see getParsedSize() From 6c91de183831a02edf06283e4a23806efa22629d Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Mon, 23 Jan 2023 22:02:07 +0100 Subject: [PATCH 09/36] Code improvements Updated Qt connect syntax. Renamed some slots and methods. Added new slot 'afterCraplogFinished'. Added new method 'dbUsable'. --- logdoctor/mainwindow.cpp | 215 ++++++++++++++++++++------------------- logdoctor/mainwindow.h | 42 ++++---- 2 files changed, 136 insertions(+), 121 deletions(-) diff --git a/logdoctor/mainwindow.cpp b/logdoctor/mainwindow.cpp index 459a871b..a064120a 100644 --- a/logdoctor/mainwindow.cpp +++ b/logdoctor/mainwindow.cpp @@ -224,7 +224,6 @@ MainWindow::MainWindow(QWidget *parent) RichText::richLogsDefault( rich_text ); this->ui->textLogFiles->setText( rich_text ); this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); - rich_text.clear(); } @@ -238,7 +237,7 @@ MainWindow::MainWindow(QWidget *parent) //// START //// // get a fresh list of LogFiles this->waiter_timer = new QTimer(this); - connect(this->waiter_timer, SIGNAL(timeout()), this, SLOT(wait_ActiveWindow())); + connect(this->waiter_timer, &QTimer::timeout, this, &MainWindow::waitActiveWindow); this->waiter_timer->start(250); } @@ -1559,7 +1558,7 @@ void MainWindow::updateUiLanguage() ////////////////////////// //// INTEGRITY CHECKS //// ////////////////////////// -void MainWindow::wait_ActiveWindow() +void MainWindow::waitActiveWindow() { if ( ! this->isActiveWindow() ) { QCoreApplication::processEvents( QEventLoop::AllEvents, 250 ); @@ -1725,11 +1724,13 @@ void MainWindow::makeInitialChecks() const bool MainWindow::checkDataDB() { + bool ok = false; if ( ! this->initiating ) { // avoid recursions // check the db const std::string path = this->db_data_path + "/collection.db"; - bool ok = IOutils::checkFile( path, true ); + ok = IOutils::checkFile( path, true ); if ( ! ok ) { + // database file not found, make a new one ok = CheckSec::checkCollectionDatabase( path ); // update ui stuff if ( ! ok ) { @@ -1755,7 +1756,7 @@ const bool MainWindow::checkDataDB() this->db_ok = ok; } } - return this->db_ok; + return ok; } @@ -2310,6 +2311,15 @@ void MainWindow::setDbWorkingState( const bool state ) } } +const bool MainWindow::dbUsable() +{ + bool ok = false; + if ( !this->db_working ) { + ok = this->checkDataDB(); + } + return ok; +} + ////////////// //// LOGS //// @@ -2331,7 +2341,7 @@ void MainWindow::on_button_Logs_Up_clicked() void MainWindow::checkMakeStats_Makable() { bool state = false; - if ( ! this->db_working ) { + if ( this->dbUsable() ) { // db is not busy if ( this->ui->checkBox_LogFiles_CheckAll->checkState() == Qt::CheckState::Checked ) { // all checked @@ -2364,11 +2374,12 @@ void MainWindow::on_button_LogFiles_Apache_clicked() // set the WebServer this->craplog.setCurrentWSID( 11 ); // reset the log files viewer - QString rich_text; - RichText::richLogsDefault( rich_text ); - this->ui->textLogFiles->setText( rich_text ); - this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); - rich_text.clear(); + { + QString rich_text; + RichText::richLogsDefault( rich_text ); + this->ui->textLogFiles->setText( rich_text ); + this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); + } // load the list this->on_button_LogFiles_RefreshList_clicked(); } @@ -2384,11 +2395,12 @@ void MainWindow::on_button_LogFiles_Nginx_clicked() // set the WebServer this->craplog.setCurrentWSID( 12 ); // reset the log files viewer - QString rich_text; - RichText::richLogsDefault( rich_text ); - this->ui->textLogFiles->setText( rich_text ); - this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); - rich_text.clear(); + { + QString rich_text; + RichText::richLogsDefault( rich_text ); + this->ui->textLogFiles->setText( rich_text ); + this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); + } // load the list this->on_button_LogFiles_RefreshList_clicked(); } @@ -2404,11 +2416,12 @@ void MainWindow::on_button_LogFiles_Iis_clicked() // set the WebServer this->craplog.setCurrentWSID( 13 ); // reset the log files viewer - QString rich_text; - RichText::richLogsDefault( rich_text ); - this->ui->textLogFiles->setText( rich_text ); - this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); - rich_text.clear(); + { + QString rich_text; + RichText::richLogsDefault( rich_text ); + this->ui->textLogFiles->setText( rich_text ); + this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); + } // load the list this->on_button_LogFiles_RefreshList_clicked(); } @@ -2431,12 +2444,12 @@ void MainWindow::on_button_LogFiles_RefreshList_clicked() delete this->craplog_timer; this->craplog_timer = new QTimer(this); this->craplog_timer->setSingleShot( true ); - connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(refreshLogsList())); + connect(this->craplog_timer, &QTimer::timeout, this, &MainWindow::refreshLogsList); this->craplog_timer->start(250); // periodically check if thread finished delete this->waiter_timer; this->waiter_timer = new QTimer(this); - connect(this->waiter_timer, SIGNAL(timeout()), this, SLOT(check_CraplogLLT_Finished())); + connect(this->waiter_timer, &QTimer::timeout, this, &MainWindow::checkRefreshFinished); this->waiter_timer->start(250); } @@ -2485,7 +2498,7 @@ void MainWindow::refreshLogsList() } refreshing_list = false; } -void MainWindow::check_CraplogLLT_Finished() +void MainWindow::checkRefreshFinished() { if ( ! this->refreshing_list ) { this->waiter_timer->stop(); @@ -2626,9 +2639,7 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked() format, this->TB ); this->ui->textLogFiles->setText( rich_content ); this->ui->textLogFiles->setFont( this->TB.getFont() ); - rich_content.clear(); } - content.clear(); } if ( ! proceed ) { // failed @@ -2636,7 +2647,6 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked() RichText::richLogsFailure( rich_text ); this->ui->textLogFiles->setText( rich_text ); this->ui->textLogFiles->setAlignment( Qt::AlignHCenter ); - rich_text.clear(); } } } @@ -2671,7 +2681,7 @@ void MainWindow::on_listLogFiles_itemChanged(QTreeWidgetItem *item, int column) void MainWindow::on_button_MakeStats_Start_clicked() { - if ( ! this->db_working ) { + if ( this->dbUsable() ) { bool proceed = true; // check that the format has been set const FormatOps::LogsFormat& lf = this->craplog.getLogsFormat( this->craplog.getCurrentWSID() ); @@ -2728,13 +2738,13 @@ void MainWindow::on_button_MakeStats_Start_clicked() // periodically update perfs delete this->waiter_timer; this->waiter_timer = new QTimer(this); - connect(this->waiter_timer, SIGNAL(timeout()), this, SLOT(update_Craplog_PerfData())); + connect(this->waiter_timer, &QTimer::timeout, this, &MainWindow::checkCraplogFinished); // run craplog as thread this->waiter_timer_start = std::chrono::system_clock::now(); delete this->craplog_timer; this->craplog_timer = new QTimer(this); this->craplog_timer->setSingleShot( true ); - connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(runCraplog())); + connect(this->craplog_timer, &QTimer::timeout, this, &MainWindow::runCraplog); // start processing this->waiter_timer->start(250); this->craplog_timer->start(100); @@ -2749,7 +2759,7 @@ void MainWindow::runCraplog() this->craplog.run(); } -void MainWindow::reset_MakeStats_labels() +void MainWindow::resetPerfsLabels() { // reset to default this->ui->label_MakeStats_Size->setText( "0 B" ); @@ -2759,7 +2769,7 @@ void MainWindow::reset_MakeStats_labels() this->ui->label_MakeStats_Speed->setText( "0 B/s" ); } -void MainWindow::update_MakeStats_labels() +void MainWindow::updatePerfsLabels() { // update values unsigned size; @@ -2782,10 +2792,10 @@ void MainWindow::update_MakeStats_labels() this->ui->label_MakeStats_Speed->setText( this->printableSpeed( size, secs )); } -void MainWindow::update_Craplog_PerfData() +void MainWindow::checkCraplogFinished() { // craplog is running as thread, update the values meanwhile - this->update_MakeStats_labels(); + this->updatePerfsLabels(); // check if Craplog has finished working if ( ! this->craplog.isWorking() ) { this->waiter_timer->stop(); @@ -2796,7 +2806,7 @@ void MainWindow::update_Craplog_PerfData() void MainWindow::craplogStarted() { // reset perfs - this->reset_MakeStats_labels(); + this->resetPerfsLabels(); this->craplog.logOps.resetPerfData(); // disable the LogFiles section this->ui->stacked_Logs_Pages->setEnabled(false); @@ -2816,7 +2826,7 @@ void MainWindow::craplogStarted() void MainWindow::craplogFinished() { // update the perf data one last time, just in case - this->update_MakeStats_labels(); + this->updatePerfsLabels(); this->craplog.makeChart( this->CHARTS_THEMES.at( this->charts_theme_id ), this->FONTS, this->ui->chart_MakeStats_Size ); @@ -2826,12 +2836,21 @@ void MainWindow::craplogFinished() } if ( this->craplog.getTotalSize() == 0 ) { // no data - this->reset_MakeStats_labels(); + this->resetPerfsLabels(); } // clean up temp vars this->craplog.clearDataCollection(); this->craplog.logOps.resetPerfData(); + // refresh the logs section + delete this->craplog_timer; + this->craplog_timer = new QTimer(this); + this->craplog_timer->setSingleShot( true ); + connect(this->craplog_timer, &QTimer::timeout, this, &MainWindow::afterCraplogFinished); + this->craplog_timer->start(1000); +} +void MainWindow::afterCraplogFinished() +{ // refresh the logs list this->on_button_LogFiles_RefreshList_clicked(); // enable the LogFiles section @@ -2868,7 +2887,7 @@ void MainWindow::refreshStatsDates() //// WARN //// void MainWindow::checkStatsWarnDrawable() { - if ( ! this->db_working ) { + if ( this->dbUsable() ) { if ( this->ui->box_StatsWarn_Year->currentIndex() >= 0 && this->ui->box_StatsWarn_Month->currentIndex() >= 0 && this->ui->box_StatsWarn_Day->currentIndex() >= 0 ) { @@ -2885,13 +2904,11 @@ void MainWindow::checkStatsWarnDrawable() void MainWindow::on_box_StatsWarn_WebServer_currentIndexChanged(int index) { - if ( this->checkDataDB() ) { - this->ui->box_StatsWarn_Year->clear(); - if ( index != -1 ) { - this->ui->box_StatsWarn_Year->addItems( - this->crapview.getYears( this->wsFromIndex( index ) )); - this->ui->box_StatsWarn_Year->setCurrentIndex( 0 ); - } + this->ui->box_StatsWarn_Year->clear(); + if ( index != -1 ) { + this->ui->box_StatsWarn_Year->addItems( + this->crapview.getYears( this->wsFromIndex( index ) )); + this->ui->box_StatsWarn_Year->setCurrentIndex( 0 ); } this->checkStatsWarnDrawable(); } @@ -2954,12 +2971,12 @@ void MainWindow::on_box_StatsWarn_Hour_currentIndexChanged(int index) void MainWindow::on_button_StatsWarn_Draw_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->setDbWorkingState( true ); delete this->crapview_timer; this->crapview_timer = new QTimer(this); this->crapview_timer->setSingleShot( true ); - connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsWarn())); + connect(this->crapview_timer, &QTimer::timeout, this, &MainWindow::drawStatsWarn); this->crapview_timer->start(250); } } @@ -2992,7 +3009,7 @@ void MainWindow::on_button_StatsWarn_Update_clicked() //// SPEED //// void MainWindow::checkStatsSpeedDrawable() { - if ( ! this->db_working ) { + if ( this->dbUsable() ) { if ( this->ui->box_StatsSpeed_Year->currentIndex() >= 0 && this->ui->box_StatsSpeed_Month->currentIndex() >= 0 && this->ui->box_StatsSpeed_Day->currentIndex() >= 0 ) { @@ -3009,13 +3026,11 @@ void MainWindow::checkStatsSpeedDrawable() void MainWindow::on_box_StatsSpeed_WebServer_currentIndexChanged(int index) { - if ( this->checkDataDB() ) { - this->ui->box_StatsSpeed_Year->clear(); - if ( index != -1 ) { - this->ui->box_StatsSpeed_Year->addItems( - this->crapview.getYears( this->wsFromIndex( index ) ) ); - this->ui->box_StatsSpeed_Year->setCurrentIndex( 0 ); - } + this->ui->box_StatsSpeed_Year->clear(); + if ( index != -1 ) { + this->ui->box_StatsSpeed_Year->addItems( + this->crapview.getYears( this->wsFromIndex( index ) ) ); + this->ui->box_StatsSpeed_Year->setCurrentIndex( 0 ); } this->checkStatsSpeedDrawable(); } @@ -3054,12 +3069,12 @@ void MainWindow::on_box_StatsSpeed_Day_currentIndexChanged(int index) void MainWindow::on_button_StatsSpeed_Draw_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->setDbWorkingState( true ); delete this->crapview_timer; this->crapview_timer = new QTimer(this); this->crapview_timer->setSingleShot( true ); - connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsSpeed())); + connect(this->crapview_timer, &QTimer::timeout, this, &MainWindow::drawStatsSpeed); this->crapview_timer->start(250); } } @@ -3088,7 +3103,7 @@ void MainWindow::drawStatsSpeed() //// COUNT //// void MainWindow::checkStatsCountDrawable() { - if ( ! this->db_working ) { + if ( this->dbUsable() ) { if ( this->ui->box_StatsCount_Year->currentIndex() >= 0 && this->ui->box_StatsCount_Month->currentIndex() >= 0 && this->ui->box_StatsCount_Day->currentIndex() >= 0 ) { @@ -3105,14 +3120,12 @@ void MainWindow::checkStatsCountDrawable() void MainWindow::on_box_StatsCount_WebServer_currentIndexChanged(int index) { - if ( this->checkDataDB() ) { - this->ui->box_StatsCount_Year->clear(); - if ( index != -1 ) { - this->ui->box_StatsCount_Year->addItems( - this->crapview.getYears( this->wsFromIndex( index ) )); - this->ui->box_StatsCount_Year->setCurrentIndex( 0 ); - this->resetStatsCountButtons(); - } + this->ui->box_StatsCount_Year->clear(); + if ( index != -1 ) { + this->ui->box_StatsCount_Year->addItems( + this->crapview.getYears( this->wsFromIndex( index ) )); + this->ui->box_StatsCount_Year->setCurrentIndex( 0 ); + this->resetStatsCountButtons(); } this->checkStatsCountDrawable(); } @@ -3186,97 +3199,97 @@ void MainWindow::makeStatsCount() delete this->crapview_timer; this->crapview_timer = new QTimer(this); this->crapview_timer->setSingleShot( true ); - connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsCount())); + connect(this->crapview_timer, &QTimer::timeout, this, &MainWindow::drawStatsCount); this->crapview_timer->start(250); } void MainWindow::on_button_StatsCount_Protocol_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->ui->button_StatsCount_Protocol->setFlat( false ); this->count_fld = this->ui->button_StatsCount_Protocol->text(); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_Method_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Method->text(); this->ui->button_StatsCount_Method->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_Uri_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Uri->text(); this->ui->button_StatsCount_Uri->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_Query_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Query->text(); this->ui->button_StatsCount_Query->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_Response_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Response->text(); this->ui->button_StatsCount_Response->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_Referrer_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Referrer->text(); this->ui->button_StatsCount_Referrer->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_Cookie_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Cookie->text(); this->ui->button_StatsCount_Cookie->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_UserAgent_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_UserAgent->text(); this->ui->button_StatsCount_UserAgent->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } void MainWindow::on_button_StatsCount_Client_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->resetStatsCountButtons(); this->count_fld = this->ui->button_StatsCount_Client->text(); this->ui->button_StatsCount_Client->setFlat( false ); - makeStatsCount(); + this->makeStatsCount(); } } @@ -3300,7 +3313,7 @@ void MainWindow::drawStatsCount() //// DAY //// void MainWindow::checkStatsDayDrawable() { - if ( ! this->db_working ) { + if ( this->dbUsable() ) { bool aux = true; // secondary date (period) if ( this->ui->checkBox_StatsDay_Period->isChecked() ) { @@ -3352,7 +3365,7 @@ void MainWindow::checkStatsDayDrawable() void MainWindow::on_box_StatsDay_WebServer_currentIndexChanged(int index) { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->ui->box_StatsDay_LogsField->clear(); this->ui->box_StatsDay_FromYear->clear(); this->ui->box_StatsDay_ToYear->clear(); @@ -3369,7 +3382,6 @@ void MainWindow::on_box_StatsDay_WebServer_currentIndexChanged(int index) this->ui->box_StatsDay_ToYear->addItems( years ); this->ui->box_StatsDay_ToYear->setCurrentIndex( 0 ); } - years.clear(); } } this->checkStatsDayDrawable(); @@ -3469,12 +3481,12 @@ void MainWindow::on_box_StatsDay_ToDay_currentIndexChanged(int index) void MainWindow::on_button_StatsDay_Draw_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->setDbWorkingState( true ); delete this->crapview_timer; this->crapview_timer = new QTimer(this); this->crapview_timer->setSingleShot( true ); - connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsDay())); + connect(this->crapview_timer, &QTimer::timeout, this, &MainWindow::drawStatsDay); this->crapview_timer->start(250); } } @@ -3509,7 +3521,7 @@ void MainWindow::drawStatsDay() //// RELATIONAL //// void MainWindow::checkStatsRelatDrawable() { - if ( ! this->db_working ) { + if ( this->dbUsable() ) { bool aux = true; if ( this->ui->box_StatsRelat_FromYear->currentIndex() >= 0 && this->ui->box_StatsRelat_FromMonth->currentIndex() >= 0 @@ -3558,7 +3570,7 @@ void MainWindow::checkStatsRelatDrawable() void MainWindow::on_box_StatsRelat_WebServer_currentIndexChanged(int index) { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->ui->box_StatsRelat_LogsField_1->clear(); this->ui->box_StatsRelat_LogsField_2->clear(); if ( index != -1 ) { @@ -3578,7 +3590,6 @@ void MainWindow::on_box_StatsRelat_WebServer_currentIndexChanged(int index) this->ui->box_StatsRelat_ToYear->clear(); this->ui->box_StatsRelat_ToYear->addItems( years ); this->ui->box_StatsRelat_ToYear->setCurrentIndex( 0 ); - years.clear(); } } this->checkStatsRelatDrawable(); @@ -3663,12 +3674,12 @@ void MainWindow::on_box_StatsRelat_ToDay_currentIndexChanged(int index) void MainWindow::on_button_StatsRelat_Draw_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->setDbWorkingState( true ); delete this->crapview_timer; this->crapview_timer = new QTimer(this); this->crapview_timer->setSingleShot( true ); - connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(drawStatsRelat())); + connect(this->crapview_timer, &QTimer::timeout, this, &MainWindow::drawStatsRelat); this->crapview_timer->start(250); } } @@ -3712,9 +3723,9 @@ void MainWindow::drawStatsRelat() //////////////// //// GLOBAL //// // -void MainWindow::makeStatsGlobals() +void MainWindow::drawStatsGlobals() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { std::vector> recur_list; std::vector> traffic_list; std::vector> perf_list; @@ -3778,8 +3789,6 @@ void MainWindow::makeStatsGlobals() } else { this->resetStatsGlob(); } - recur_list.clear(); traffic_list.clear(); - perf_list.clear(); work_list.clear(); } else { this->resetStatsGlob(); @@ -3834,13 +3843,13 @@ void MainWindow::makeStatsGlob() delete this->crapview_timer; this->crapview_timer = new QTimer(this); this->crapview_timer->setSingleShot( true ); - connect(this->crapview_timer, SIGNAL(timeout()), this, SLOT(makeStatsGlobals())); + connect(this->crapview_timer, &QTimer::timeout, this, &MainWindow::drawStatsGlobals); this->crapview_timer->start(250); } void MainWindow::on_button_StatsGlob_Apache_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->glob_ws = "apache"; this->makeStatsGlob(); } @@ -3849,7 +3858,7 @@ void MainWindow::on_button_StatsGlob_Apache_clicked() void MainWindow::on_button_StatsGlob_Nginx_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->glob_ws = "nginx"; this->makeStatsGlob(); } @@ -3858,7 +3867,7 @@ void MainWindow::on_button_StatsGlob_Nginx_clicked() void MainWindow::on_button_StatsGlob_Iis_clicked() { - if ( this->checkDataDB() ) { + if ( this->dbUsable() ) { this->glob_ws = "iis"; this->makeStatsGlob(); } diff --git a/logdoctor/mainwindow.h b/logdoctor/mainwindow.h index c4fe4aa8..67e35b42 100644 --- a/logdoctor/mainwindow.h +++ b/logdoctor/mainwindow.h @@ -49,17 +49,15 @@ public: private slots: + /////////////////// + //// OVERRIDES //// void closeEvent( QCloseEvent *event ) override; - //////////////// - //// CUSTOM //// + ////////////// + //// INIT //// - void wait_ActiveWindow(); - - void update_Craplog_PerfData(); - - void check_CraplogLLT_Finished(); + void waitActiveWindow(); // CUSTOM ////////////// @@ -93,9 +91,15 @@ private slots: void on_button_Logs_Up_clicked(); - void refreshLogsList(); + void refreshLogsList(); // CUSTOM - void runCraplog(); + void checkRefreshFinished(); // CUSTOM + + void runCraplog(); // CUSTOM + + void checkCraplogFinished(); // CUSTOM + + void afterCraplogFinished(); // CUSTOM void on_button_LogFiles_ViewFile_clicked(); @@ -119,17 +123,17 @@ private slots: ////////////////// //// CRAPVIEW //// - void drawStatsWarn(); + void drawStatsWarn(); // CUSTOM - void drawStatsSpeed(); + void drawStatsSpeed(); // CUSTOM - void drawStatsCount(); + void drawStatsCount(); // CUSTOM - void drawStatsDay(); + void drawStatsDay(); // CUSTOM - void drawStatsRelat(); + void drawStatsRelat(); // CUSTOM - void makeStatsGlobals(); + void drawStatsGlobals(); // CUSTOM //// WARNINGS //// @@ -729,6 +733,8 @@ private: //! Called when a member begins/ends performing operations on the database void setDbWorkingState( const bool state ); + const bool dbUsable(); + ////////////////// //// CRAPTABS //// @@ -779,11 +785,11 @@ private: ////////////////////////// //// LOGS PERFORMANCE //// - void update_MakeStats_labels(); + void updatePerfsLabels(); // CUSTOM - void update_MakeStats_graphs(); + /*void update_MakeStats_graphs(); // CUSTOM*/ - void reset_MakeStats_labels(); + void resetPerfsLabels(); // CUSTOM ////////////////// From 9e879513493ec52baf5edf8282a1e18bda1402dd Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Mon, 23 Jan 2023 22:02:55 +0100 Subject: [PATCH 10/36] Code improvements Updated Qt connect syntax --- logdoctor/games/snake/game.cpp | 2 +- logdoctor/modules/crapup/crapup.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/logdoctor/games/snake/game.cpp b/logdoctor/games/snake/game.cpp index 0e7b4a18..632ac7ac 100644 --- a/logdoctor/games/snake/game.cpp +++ b/logdoctor/games/snake/game.cpp @@ -119,7 +119,7 @@ void SnakeGame::on_button_Play_clicked() this->ui->stackedWidget_GameDisplay->setCurrentIndex( 1 ); // start playing this->game_loop = new QTimer(this); - connect(this->game_loop, SIGNAL(timeout()), this, SLOT(processGameLogic())); + connect(this->game_loop, &QTimer::timeout, this, &SnakeGame::processGameLogic); this->game_loop->start(175); this->playing = true; } diff --git a/logdoctor/modules/crapup/crapup.cpp b/logdoctor/modules/crapup/crapup.cpp index 441cd376..9f4fbd3f 100644 --- a/logdoctor/modules/crapup/crapup.cpp +++ b/logdoctor/modules/crapup/crapup.cpp @@ -66,7 +66,7 @@ void Crapup::versionCheck( const float v ) int err = 1; this->img_timer = new QTimer(this); - connect(this->img_timer, SIGNAL(timeout()), this, SLOT(rotateImg())); + connect(this->img_timer, &QTimer::timeout, this, &Crapup::rotateImg); this->img_timer->start(100); QByteArray ua = QByteArray::fromStdString("LogDoctor/"+std::to_string(v)+" (version check)"); @@ -93,7 +93,7 @@ void Crapup::versionCheck( const float v ) } this->request_timer = new QTimer(this); this->request_timer->setSingleShot( true ); - connect(this->request_timer, SIGNAL(timeout()), this, SLOT(requestTimeout())); + connect(this->request_timer, &QTimer::timeout, this, &Crapup::requestTimeout); // set the URL and make the request QNetworkRequest request; From 72113d20530209d332db6f8fb6ba720c0a4be31a Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Tue, 24 Jan 2023 01:22:38 +0100 Subject: [PATCH 11/36] Fix Fixed warnings filter in queries --- logdoctor/modules/crapview/modules/query.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/logdoctor/modules/crapview/modules/query.cpp b/logdoctor/modules/crapview/modules/query.cpp index 0ff91842..d9fa147d 100644 --- a/logdoctor/modules/crapview/modules/query.cpp +++ b/logdoctor/modules/crapview/modules/query.cpp @@ -1042,7 +1042,8 @@ void DbQuery::getDaytimeCounts( Result& result, const QString .arg( log_field.replace("'","''") ); } else { // filter - if ( log_field == "response" + if ( log_field == "warning" + || log_field == "response" || log_field == "time_taken" || log_field == "bytes_sent" || log_field == "bytes_received" ) { @@ -1526,7 +1527,8 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co // apply a filter if present if ( field_filter_1.size() > 0 ) { QString filter = field_filter_1; - if ( log_field_1 == "response" + if ( log_field_1 == "warning" + || log_field_1 == "response" || log_field_1 == "time_taken" || log_field_1 == "bytes_sent" || log_field_1 == "bytes_received" ) { @@ -1551,7 +1553,8 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co // apply a filter if present if ( field_filter_2.size() > 0 ) { QString filter = field_filter_2; - if ( log_field_2 == "response" + if ( log_field_2 == "warning" + || log_field_2 == "response" || log_field_2 == "time_taken" || log_field_2 == "bytes_sent" || log_field_2 == "bytes_received" ) { From 3cfb960fb0a250aad9f1e65c805dd610814c6797 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Tue, 24 Jan 2023 01:27:00 +0100 Subject: [PATCH 12/36] Improvements and fixes --- logdoctor/mainwindow.cpp | 117 +++++++++++++++++++++------------------ logdoctor/mainwindow.h | 2 +- 2 files changed, 63 insertions(+), 56 deletions(-) diff --git a/logdoctor/mainwindow.cpp b/logdoctor/mainwindow.cpp index a064120a..358361d2 100644 --- a/logdoctor/mainwindow.cpp +++ b/logdoctor/mainwindow.cpp @@ -1718,6 +1718,12 @@ void MainWindow::makeInitialChecks() throw WebServerException( "Unexpected WebServer ID: "+std::to_string( this->default_ws ) ); } this->initiating = false; + // effectively check if draw buttons can be enabled + this->checkStatsWarnDrawable(); + this->checkStatsSpeedDrawable(); + this->checkStatsCountDrawable(); + this->checkStatsDayDrawable(); + this->checkStatsRelatDrawable(); } } @@ -2279,10 +2285,10 @@ void MainWindow::on_button_Tab_StatsGlob_clicked() //////////// //// DB //// //////////// -void MainWindow::setDbWorkingState( const bool state ) +void MainWindow::setDbWorkingState( const bool working ) { - this->db_working = state; - if ( ! state ) { + this->db_working = working; + if ( ! working ) { this->checkMakeStats_Makable(); if ( this->ui->table_StatsWarn->rowCount() > 0 ) { this->ui->button_StatsWarn_Update->setEnabled( true ); @@ -2293,20 +2299,20 @@ void MainWindow::setDbWorkingState( const bool state ) this->checkStatsDayDrawable(); this->checkStatsRelatDrawable(); this->ui->button_StatsGlob_Apache->setEnabled( true ); - this->ui->button_StatsGlob_Nginx->setEnabled( true ); - this->ui->button_StatsGlob_Iis->setEnabled( true ); + this->ui->button_StatsGlob_Nginx->setEnabled( true ); + this->ui->button_StatsGlob_Iis->setEnabled( true ); this->ui->page_Tab_Conf->setEnabled( true ); } else { - this->ui->button_MakeStats_Start->setEnabled( false ); + this->ui->button_MakeStats_Start->setEnabled( false ); this->ui->button_StatsWarn_Update->setEnabled( false ); - this->ui->button_StatsWarn_Draw->setEnabled( false ); - this->ui->scrollArea_StatsCount->setEnabled( false ); - this->ui->button_StatsSpeed_Draw->setEnabled( false ); - this->ui->button_StatsDay_Draw->setEnabled( false ); - this->ui->button_StatsRelat_Draw->setEnabled( false ); + this->ui->button_StatsWarn_Draw->setEnabled( false ); + this->ui->scrollArea_StatsCount->setEnabled( false ); + this->ui->button_StatsSpeed_Draw->setEnabled( false ); + this->ui->button_StatsDay_Draw->setEnabled( false ); + this->ui->button_StatsRelat_Draw->setEnabled( false ); this->ui->button_StatsGlob_Apache->setEnabled( false ); - this->ui->button_StatsGlob_Nginx->setEnabled( false ); - this->ui->button_StatsGlob_Iis->setEnabled( false ); + this->ui->button_StatsGlob_Nginx->setEnabled( false ); + this->ui->button_StatsGlob_Iis->setEnabled( false ); this->ui->page_Tab_Conf->setEnabled( false ); } } @@ -2898,7 +2904,8 @@ void MainWindow::checkStatsWarnDrawable() this->ui->button_StatsWarn_Draw->setEnabled( false ); } } else { - this->ui->button_StatsRelat_Draw->setEnabled( false ); + // db busy + this->ui->button_StatsWarn_Draw->setEnabled( false ); } } @@ -3020,7 +3027,8 @@ void MainWindow::checkStatsSpeedDrawable() this->ui->button_StatsSpeed_Draw->setEnabled( false ); } } else { - this->ui->button_StatsRelat_Draw->setEnabled( false ); + // db busy + this->ui->button_StatsSpeed_Draw->setEnabled( false ); } } @@ -3114,7 +3122,8 @@ void MainWindow::checkStatsCountDrawable() this->ui->scrollArea_StatsCount->setEnabled( false ); } } else { - this->ui->button_StatsRelat_Draw->setEnabled( false ); + // db busy + this->ui->scrollArea_StatsCount->setEnabled( false ); } } @@ -3359,29 +3368,27 @@ void MainWindow::checkStatsDayDrawable() } else { // db busy - this->ui->button_StatsRelat_Draw->setEnabled( false ); + this->ui->button_StatsDay_Draw->setEnabled( false ); } } void MainWindow::on_box_StatsDay_WebServer_currentIndexChanged(int index) { - if ( this->dbUsable() ) { - this->ui->box_StatsDay_LogsField->clear(); - this->ui->box_StatsDay_FromYear->clear(); - this->ui->box_StatsDay_ToYear->clear(); - if ( index != -1 ) { - // refresh fields - this->ui->box_StatsDay_LogsField->addItems( - this->crapview.getFields( "Daytime" )); - this->ui->box_StatsDay_LogsField->setCurrentIndex( 0 ); - // refresh dates - QStringList years = this->crapview.getYears( this->wsFromIndex( index ) ); - this->ui->box_StatsDay_FromYear->addItems( years ); - this->ui->box_StatsDay_FromYear->setCurrentIndex( 0 ); - if ( this->ui->checkBox_StatsDay_Period->isChecked() ) { - this->ui->box_StatsDay_ToYear->addItems( years ); - this->ui->box_StatsDay_ToYear->setCurrentIndex( 0 ); - } + this->ui->box_StatsDay_LogsField->clear(); + this->ui->box_StatsDay_FromYear->clear(); + this->ui->box_StatsDay_ToYear->clear(); + if ( index != -1 ) { + // refresh fields + this->ui->box_StatsDay_LogsField->addItems( + this->crapview.getFields( "Daytime" )); + this->ui->box_StatsDay_LogsField->setCurrentIndex( 0 ); + // refresh dates + QStringList years = this->crapview.getYears( this->wsFromIndex( index ) ); + this->ui->box_StatsDay_FromYear->addItems( years ); + this->ui->box_StatsDay_FromYear->setCurrentIndex( 0 ); + if ( this->ui->checkBox_StatsDay_Period->isChecked() ) { + this->ui->box_StatsDay_ToYear->addItems( years ); + this->ui->box_StatsDay_ToYear->setCurrentIndex( 0 ); } } this->checkStatsDayDrawable(); @@ -3570,27 +3577,27 @@ void MainWindow::checkStatsRelatDrawable() void MainWindow::on_box_StatsRelat_WebServer_currentIndexChanged(int index) { - if ( this->dbUsable() ) { - this->ui->box_StatsRelat_LogsField_1->clear(); - this->ui->box_StatsRelat_LogsField_2->clear(); - if ( index != -1 ) { - // refresh fields - QStringList fields = this->crapview.getFields( "Relational" ); - this->ui->box_StatsRelat_LogsField_1->addItems( fields ); - this->ui->box_StatsRelat_LogsField_2->addItems( fields ); - this->ui->box_StatsRelat_LogsField_1->setCurrentIndex( 0 ); - this->ui->box_StatsRelat_LogsField_2->setCurrentIndex( 0 ); - // refresh dates - QStringList years = this->crapview.getYears( this->wsFromIndex( index ) ); - // from - this->ui->box_StatsRelat_FromYear->clear(); - this->ui->box_StatsRelat_FromYear->addItems( years ); - this->ui->box_StatsRelat_FromYear->setCurrentIndex( 0 ); - // to - this->ui->box_StatsRelat_ToYear->clear(); - this->ui->box_StatsRelat_ToYear->addItems( years ); - this->ui->box_StatsRelat_ToYear->setCurrentIndex( 0 ); - } + this->ui->box_StatsRelat_LogsField_1->clear(); + this->ui->box_StatsRelat_LogsField_2->clear(); + this->ui->box_StatsRelat_FromYear->clear(); + this->ui->box_StatsRelat_ToYear->clear(); + if ( index != -1 ) { + // refresh fields + QStringList fields = this->crapview.getFields( "Relational" ); + this->ui->box_StatsRelat_LogsField_1->addItems( fields ); + this->ui->box_StatsRelat_LogsField_2->addItems( fields ); + this->ui->box_StatsRelat_LogsField_1->setCurrentIndex( 0 ); + this->ui->box_StatsRelat_LogsField_2->setCurrentIndex( 0 ); + // refresh dates + QStringList years = this->crapview.getYears( this->wsFromIndex( index ) ); + // from + this->ui->box_StatsRelat_FromYear->clear(); + this->ui->box_StatsRelat_FromYear->addItems( years ); + this->ui->box_StatsRelat_FromYear->setCurrentIndex( 0 ); + // to + this->ui->box_StatsRelat_ToYear->clear(); + this->ui->box_StatsRelat_ToYear->addItems( years ); + this->ui->box_StatsRelat_ToYear->setCurrentIndex( 0 ); } this->checkStatsRelatDrawable(); } diff --git a/logdoctor/mainwindow.h b/logdoctor/mainwindow.h index 67e35b42..5d57f32e 100644 --- a/logdoctor/mainwindow.h +++ b/logdoctor/mainwindow.h @@ -731,7 +731,7 @@ private: bool db_working = false; //! Called when a member begins/ends performing operations on the database - void setDbWorkingState( const bool state ); + void setDbWorkingState( const bool working ); const bool dbUsable(); From b58bd89a9755e32cf1e81312de3f86169823c79c Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Tue, 24 Jan 2023 01:36:29 +0100 Subject: [PATCH 13/36] Polished UI Adjusted stats DayTime and Relational draw buttons width and relative spacer height. Adjusted stats Speed and Count web-server combo boxes width. --- logdoctor/mainwindow.ui | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/logdoctor/mainwindow.ui b/logdoctor/mainwindow.ui index a0097c70..3c42e50d 100644 --- a/logdoctor/mainwindow.ui +++ b/logdoctor/mainwindow.ui @@ -2023,13 +2023,13 @@ li.checked::marker { content: "\2612"; } - 112 + 100 32 - 112 + 16777215 32 @@ -3067,13 +3067,13 @@ Use '!', '=','<' or '>' to declare what to use - 112 + 100 32 - 112 + 16777215 32 @@ -3645,7 +3645,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use - 100 + 16777215 88 @@ -3686,7 +3686,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use 20 - 10 + 6 @@ -3778,7 +3778,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use 20 - 4 + 6 @@ -4066,7 +4066,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use - 100 + 16777215 88 @@ -4539,7 +4539,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use 0 0 - 173 + 317 348 @@ -4895,7 +4895,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use 0 0 - 157 + 317 348 @@ -5150,7 +5150,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use 0 0 - 145 + 429 276 @@ -5415,7 +5415,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use 0 0 - 173 + 429 276 From 224c224e29d383219caa008f5a42beb512abf3ac Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:00:56 +0100 Subject: [PATCH 14/36] Code improvements --- .../modules/craplog/modules/datetime.cpp | 20 ++++++++++------- logdoctor/modules/craplog/modules/formats.cpp | 6 ++--- logdoctor/modules/craplog/modules/formats.h | 8 +++---- logdoctor/modules/craplog/modules/hash.h | 3 --- logdoctor/modules/tb.cpp | 6 ++--- logdoctor/utilities/rtf.cpp | 22 ++++++++++--------- logdoctor/utilities/strings.cpp | 14 +++++++----- 7 files changed, 42 insertions(+), 37 deletions(-) diff --git a/logdoctor/modules/craplog/modules/datetime.cpp b/logdoctor/modules/craplog/modules/datetime.cpp index 203d32d1..492e9dc3 100644 --- a/logdoctor/modules/craplog/modules/datetime.cpp +++ b/logdoctor/modules/craplog/modules/datetime.cpp @@ -113,10 +113,10 @@ const std::vector DateTimeOps::processDateTime( const std::string& // convert to seconds if ( aux == "us" ) { // from microseconds - datetime = datetime.substr( 0, datetime.size()-6 ); + datetime.resize( datetime.size()-6 ); } else if ( aux == "ms" ) { // from milliseconds - datetime = datetime.substr( 0, datetime.size()-3 ); + datetime.resize( datetime.size()-3 ); } else if ( aux == "s.ms" ) { // from seconds.milliseconds datetime = std::to_string( std::stoi( datetime ) ); @@ -140,11 +140,13 @@ const std::vector DateTimeOps::processDateTime( const std::string& day = datetime.substr( 8, 2 ); } else if ( format == "MMDDYY" ) { + int y = std::stoi( datetime.substr( 6, 2 ) ); month = datetime.substr( 0, 2 ); day = datetime.substr( 3, 2 ); - year = "20" + datetime.substr( 6, 2 ); + year = (y<70) ? "20" : "19"; + year += std::to_string( y ); - } else if ( format == "MDYY" ) { + } else if ( format == "MDYYYY" ) { int aux_; if ( datetime.at(2) == '/' ) { month = datetime.substr( 0, 2 ); @@ -158,21 +160,23 @@ const std::vector DateTimeOps::processDateTime( const std::string& aux_ += 3; } else { day = "0" + datetime.substr( aux_, 1 ); - aux_ = +2; + aux_ += 2; } - year = "20" + datetime.substr( aux_ ); + year = datetime.substr( aux_ ); } else if ( StringOps::startsWith( format, "year" ) ) { year = datetime; if ( format == "year_short" ) { - year = "20" + year; + int y = std::stoi( year ); + year = (y<70) ? "20" : "19"; + year += year; } } else if ( StringOps::startsWith( format, "month" ) ) { if ( format.size() <= 5 ) { month = datetime; } else { - datetime = datetime.substr( 0, 3 ); // may be the full name + datetime.resize( 3 ); // may be the full name month = DateTimeOps::convertMonth( datetime ); } diff --git a/logdoctor/modules/craplog/modules/formats.cpp b/logdoctor/modules/craplog/modules/formats.cpp index f1fb7cf4..4270db72 100644 --- a/logdoctor/modules/craplog/modules/formats.cpp +++ b/logdoctor/modules/craplog/modules/formats.cpp @@ -12,9 +12,9 @@ FormatOps::FormatOps() // count the new lines -const int FormatOps::countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ) const +const unsigned FormatOps::countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ) const { - int nl = 0; + unsigned nl = 0; nl += StringOps::count( initial, "\n" ); nl += StringOps::count( final, "\n" ); for ( const std::string& sep : separators ) { @@ -616,7 +616,7 @@ const FormatOps::LogsFormat FormatOps::processIisFormatString( const std::string // IIS logging module final = ","; separators = {", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", ",", "}; - fields = {"client","NONE","date_time_MDYY","date_time_utc_t","NONE","NONE","NONE","time_taken_ms","bytes_received","bytes_sent","response_code","NONE","request_method","request_uri","request_query"}; + fields = {"client","NONE","date_time_MDYYYY","date_time_utc_t","NONE","NONE","NONE","time_taken_ms","bytes_received","bytes_sent","response_code","NONE","request_method","request_uri","request_query"}; break; case 1: // NCSA logging module diff --git a/logdoctor/modules/craplog/modules/formats.h b/logdoctor/modules/craplog/modules/formats.h index 516c6a74..a8f5093a 100644 --- a/logdoctor/modules/craplog/modules/formats.h +++ b/logdoctor/modules/craplog/modules/formats.h @@ -24,7 +24,7 @@ public: std::string final; //!< The final separator std::vector separators; //!< The separators in the middle std::vector fields; //!< The fields - int new_lines; //!< The number of new lines + unsigned new_lines; //!< The number of new lines }; @@ -117,7 +117,7 @@ private: \return The number of new lines in a single log line \see LogsFormat, processApacheFormatString(), processNginxFormatString() */ - const int countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ) const; + const unsigned countNewLines( const std::string& initial, const std::string& final, const std::vector& separators ) const; //! Finds the end of a Nginx log field /*! @@ -437,7 +437,7 @@ private: ///////////// //// IIS //// - //!< Access logs fields formats + //!< Access logs fields formats (W3C) const std::unordered_map IIS_ALF = { {"date", "date_time_utc_d"}, {"time", "date_time_utc_t"}, @@ -468,7 +468,7 @@ private: const std::unordered_map IIS_ALF_SAMPLES = { {"NONE", "DISCARDED"}, {"date_time_ncsa", "01/Jan/2000:23:59:59 +0000"}, - {"date_time_MDYY", "1/1/00"}, + {"date_time_MDYYYY", "1/1/2000"}, {"date_time_utc_d", "2000-01-01"}, {"date_time_utc_t", "23:59:59"}, {"request_full", "GET /index.php?query=x HTTP/1.1"}, diff --git a/logdoctor/modules/craplog/modules/hash.h b/logdoctor/modules/craplog/modules/hash.h index 94b7b9c9..c1433b4a 100644 --- a/logdoctor/modules/craplog/modules/hash.h +++ b/logdoctor/modules/craplog/modules/hash.h @@ -28,7 +28,6 @@ public: /*! \param db_path The path of the log files' Hashes database \return Whether the operation has been successful or not - \see hashes */ const bool loadUsedHashesLists( const std::string& db_path ); @@ -46,7 +45,6 @@ public: \param file_hash The sha256 hash to compare \param web_server_id The ID of the Web Server which generated the file \return Whether the hash is already in the list or not - \see hashes */ const bool hasBeenUsed( const std::string& file_hash, const int& web_server_id ) const; @@ -56,7 +54,6 @@ public: \param hashes The list of hashes to insert \param web_server_id The ID of the Web Server which generated the file \return Whether the operation has been successful or not - \see insertUsedHash() */ const bool insertUsedHashes( const std::string& db_path, const std::vector& hashes, const int& web_server_id ); diff --git a/logdoctor/modules/tb.cpp b/logdoctor/modules/tb.cpp index da2f6517..9867443e 100644 --- a/logdoctor/modules/tb.cpp +++ b/logdoctor/modules/tb.cpp @@ -79,9 +79,9 @@ void TextBrowser::makePreview( QString& content ) const this->color_scheme.at("text") ); } content += ">"; - if ( this->wide_lines ) { + /*if ( this->wide_lines ) { content += "
    "; - } + }*/ for ( int i=0; i<32; i++ ) { content += "

    "; @@ -166,7 +166,7 @@ void TextBrowser::makePreview( QString& content ) const content += ""; content += "

    "; - if ( this->wide_lines ) { + if ( this->wide_lines && i < 31 ) { content += "
    "; } } diff --git a/logdoctor/utilities/rtf.cpp b/logdoctor/utilities/rtf.cpp index 02e7c4a4..b542e87e 100644 --- a/logdoctor/utilities/rtf.cpp +++ b/logdoctor/utilities/rtf.cpp @@ -24,22 +24,24 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co .arg( colors.at("background"), colors.at("text") ); } rich_content += ">"; - if ( wide_lines == true ) { + /*if ( wide_lines == true ) { rich_content += "
    "; - } + }*/ QString rich_line="", class_name=""; std::string sep, fld, fld_str, aux_sep2; - bool missing=false; + bool missing = false; size_t start, stop, i, aux_start, aux_stop, line_size, sep_size; const size_t n_sep = logs_format.separators.size()-1; std::vector lines; StringOps::splitrip( lines, content ); + size_t lines_left = lines.size(); for ( const std::string& line : lines ) { + lines_left --; // check if the line is commented, usually from IIS logs if ( StringOps::startsWith( line, "#" ) && !StringOps::startsWith( logs_format.initial, "#" ) ) { rich_line = QString("

    %1

    ").arg( QString::fromStdString( line ) ); - if ( wide_lines == true ) { + if ( wide_lines ) { rich_line += "
    "; } rich_content.append( rich_line ); @@ -135,7 +137,7 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co } // finally update if needed - if ( ok == true && aux_stop >= stop ) { + if ( ok && aux_stop >= stop ) { stop = aux_stop; fld_str = StringOps::strip( line.substr(start, stop-start), " " ); } @@ -148,7 +150,7 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co fld_str = fld_str.substr( 1, fld_str.size()-1 ); rich_line += "["; if ( StringOps::endsWith( fld_str, "]" ) ) { - fld_str = fld_str.substr( 0, fld_str.size()-1 ); + fld_str.resize( fld_str.size()-1 ); sep = "]" + sep; } } @@ -182,7 +184,7 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co } rich_line += ""; // update the stop for the next start - if ( missing == true ) { + if ( missing ) { stop = aux_stop; } else { stop += sep_size; @@ -193,7 +195,7 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co rich_line += QString::fromStdString( logs_format.final ); break; } - if ( missing == true ) { + if ( missing ) { missing = false; rich_line += QString::fromStdString( aux_sep2 ); } else { @@ -201,10 +203,10 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co } } rich_line += "

    "; - if ( wide_lines == true ) { + if ( wide_lines && lines_left > 0 ) { rich_line += "
    "; } - rich_content+= rich_line; + rich_content += rich_line; } lines.clear(); rich_content += ""; diff --git a/logdoctor/utilities/strings.cpp b/logdoctor/utilities/strings.cpp index 13546ce2..13da8af7 100644 --- a/logdoctor/utilities/strings.cpp +++ b/logdoctor/utilities/strings.cpp @@ -1,6 +1,8 @@ #include "strings.h" +#include + StringOps::StringOps() { @@ -373,17 +375,17 @@ const std::string StringOps::replace( const std::string& str, const std::string& const std::string StringOps::toUpper( const std::string& str ) { std::string up = ""; - for ( const unsigned char& ch : str ) { - up.push_back( (char)std::toupper( ch ) ); - } + std::transform( str.cbegin(), str.cend(), + std::back_inserter( up ), + [](char c){ return std::toupper( c ); } ); return up; } const std::string StringOps::toLower( const std::string& str ) { std::string low = ""; - for ( const unsigned char& ch : str ) { - low.push_back( (char)std::tolower( ch ) ); - } + std::transform( str.cbegin(), str.cend(), + std::back_inserter( low ), + [](char c){ return std::toupper( c ); } ); return low; } From f946f96fdf32afec4a2e105dace517aa5cf678c1 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:02:57 +0100 Subject: [PATCH 15/36] Improvements Added copy-constructor and operator= --- logdoctor/games/snake/food.cpp | 43 +++++++++++++++++++++++++--------- logdoctor/games/snake/food.h | 4 +++- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/logdoctor/games/snake/food.cpp b/logdoctor/games/snake/food.cpp index 62ea4a8d..060acf8c 100644 --- a/logdoctor/games/snake/food.cpp +++ b/logdoctor/games/snake/food.cpp @@ -9,6 +9,26 @@ Food::Food( const bool& can_move ) this->x = 0; this->y = 0; } +Food::Food( const Food& other ) +{ + this->x = other.x; + this->y = other.y; + this->img_egg = other.img_egg; + this->img_rat = other.img_rat; + this->movable = other.movable; + this->image = new QGraphicsPixmapItem( (this->movable) ? this->img_rat : this->img_egg ); +} +const Food& Food::operator=( const Food& other ) +{ + if ( this == &other ) return other; + this->x = other.x; + this->y = other.y; + this->img_egg = other.img_egg; + this->img_rat = other.img_rat; + this->movable = other.movable; + this->image = new QGraphicsPixmapItem( (this->movable) ? this->img_rat : this->img_egg ); + return *this; +} const unsigned int& Food::X() const @@ -37,7 +57,8 @@ const bool Food::inTile( const unsigned int x, const unsigned int y ) const } -void Food::update( const unsigned int new_x, const unsigned int new_y ) { +void Food::update( const unsigned int new_x, const unsigned int new_y ) +{ this->x = new_x; this->y = new_y; this->image->setOffset( 16+(new_x*32), 16+(new_y*32) ); @@ -47,15 +68,15 @@ void Food::update( const unsigned int new_x, const unsigned int new_y ) { void Food::spawn( const Snake& snake, const Snake& snake_ ) { // pick a new random position - unsigned int x, y; + unsigned int new_x, new_y; while (true) { - x = rand() % 16; - y = rand() % 16; + new_x = rand() % 16; + new_y = rand() % 16; // check it's actually inside the field - if ( x < 16 && y < 16 ) { + if ( new_x < 16 && new_y < 16 ) { // check the tile is empty - if ( x != this->x && y != this->y ) { - if ( !(snake.inTile( x, y, false ) || snake_.inTile( x, y, false )) ) { + if ( new_x != this->x && new_y != this->y ) { + if ( !(snake.inTile( new_x, new_y, false ) || snake_.inTile( new_x, new_y, false )) ) { break; } } @@ -63,7 +84,7 @@ void Food::spawn( const Snake& snake, const Snake& snake_ ) } // update to new position - this->update( x, y ); + this->update( new_x, new_y ); // randomly rotate the image int rand_ = rand()%4; @@ -150,17 +171,17 @@ void Food::move( const Snake& snake ) move_up += 30; } else if ( this->y > snake_y ) { move_down += 30; - } else if ( this->y == snake_y ) { + } else /*if ( this->y == snake_y )*/ { move_up += 30; move_down += 30; } - } else if ( this->x > snake_x ) { + } else /*if ( this->x > snake_x )*/ { move_right += 30; if ( this->y < snake_y ) { move_up += 30; } else if ( this->y > snake_y ) { move_down += 30; - } else if ( this->y == snake_y ) { + } else /*if ( this->y == snake_y )*/ { move_up += 30; move_down += 30; } diff --git a/logdoctor/games/snake/food.h b/logdoctor/games/snake/food.h index 9016a796..141b64ac 100644 --- a/logdoctor/games/snake/food.h +++ b/logdoctor/games/snake/food.h @@ -9,6 +9,8 @@ class Food { public: explicit Food( const bool& can_move=false ); + explicit Food( const Food& other ); + const Food& operator =( const Food& other ); //! Returns the position on the X-axis const unsigned int& X() const; @@ -47,7 +49,7 @@ private: unsigned int y; //!< The image which graphically represents the food - QGraphicsPixmapItem* image; + QGraphicsPixmapItem* image = nullptr; }; #endif // FOOD_H From 526dfb41379ffb65c040d553e5b10bf7a92ca17e Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:05:36 +0100 Subject: [PATCH 16/36] Added hard-coded default help Fallback to the default in case help resources are not available --- logdoctor/modules/craphelp/craphelp.cpp | 698 ++++++++++++++++++++++++ logdoctor/modules/craphelp/craphelp.h | 13 + 2 files changed, 711 insertions(+) diff --git a/logdoctor/modules/craphelp/craphelp.cpp b/logdoctor/modules/craphelp/craphelp.cpp index e4a73fb8..997cac76 100644 --- a/logdoctor/modules/craphelp/craphelp.cpp +++ b/logdoctor/modules/craphelp/craphelp.cpp @@ -114,3 +114,701 @@ void Craphelp::helpLogsFormat( const std::string& path, const QFont& font, const // apply the font this->ui->helpBrowser->setFont( font ); } + + +void Craphelp::helpLogsFormatDefault( const std::string& file_name, const QFont& font, const int &color_scheme_id ) const +{ + std::unordered_map color_scheme = this->getColorScheme( color_scheme_id ); + std::string aux; + if ( file_name == "apache_format" ) { + this->defaultApacheFormat( aux ); + } else if ( file_name == "nginx_format" ) { + this->defaultNginxFormat( aux ); + } else if ( file_name == "iis_format" ) { + this->defaultIisFormat( aux ); + } + QString content; + if ( color_scheme_id == 0 ) { + // remove the style for the colors + while (true) { + const int start = aux.find( "background-color:" ); + if ( start < 0 || start > aux.size() ) { + break; + } + const int stop = aux.find( ";", start ) + 1; + aux = aux.substr( 0, start ) + aux.substr( stop ); + } + while (true) { + const int start = aux.find( "color:" ); + if ( start < 0 || start > aux.size() ) { + break; + } + const int stop = aux.find( ";", start ) + 1; + aux = aux.substr( 0, start ) + aux.substr( stop ); + } + content = QString::fromStdString( aux ); + + } else { + // replace with colors + content = QString::fromStdString( aux ) + .replace( "$BG$", color_scheme.at("background") ) + .replace( "$TEXT$", color_scheme.at("text") ) + .replace( "$IT$", color_scheme.at("italic") ) + .replace( "$H1$", color_scheme.at("h1") ) + .replace( "$H3$", color_scheme.at("h3") ) + .replace( "$CODE$", color_scheme.at("code") ) + .replace( "$LINK$", color_scheme.at("link") ); + } + // show the content + this->ui->helpBrowser->setText( content ); + // apply the font + this->ui->helpBrowser->setFont( font ); +} + + + +void Craphelp::defaultApacheFormat( std::string& str ) const +{ + str.append( + "" + "" + " " + " " + " LogDoctor - Help" + " " + " " + " " + "
    " + "

    Apache2

    " + "
    " + "
    " + "
    " + "


    Access logs format string

    " + "
    " + "


    Configuration file

    " + "
    " + "

    The configuration file should be located at:


    " + " /etc/apache2/apache2.conf" + "
    " + "

    The line to configure access logs is the one starting with \"LogFormat\" followed by the list of fields codes.

    " + "
    " + "
    " + "
    " + "

    Common logs formats

    " + "
    " + "

    Most commonly used format strings are:

    " + "
    " + "
      " + "
    • Common log format (CLF)

    • " + " LogFormat \"%h %l %u %t \\\"%r\\\" %>s %O\" common
      " + "
      " + "
    • Combined log format (NCSA standard)

    • " + " LogFormat \"%h %l %u %t \\\"%r\\\" %>s %O \\\"%{Referer}i\\\" \\\"%{User-agent}i\\\"\" combined" + "
    " + "
    " + "
    " + "
    " + "

    Suggested logs formats

    " + "
    " + "

    A suggested format string, to allow using the complete set of functionalities of LogDoctor, is:


    " + " LogFormat \"%{%F %T}t %H %m %U %q %>s %I %O %D \\\"%{Referer}i\\\" \\\"%{Cookie}i\\\" \\\"%{User-agent}i\\\" %{c}h\" combined" + "
    " + "

    The string above should be preferred, but alternatives can be used as well, like:


    " + " LogFormat \"%{sec}t \\\"%r\\\" %q %<s %I %O %D \\\"%{Referer}i\\\" \\\"%{Cookie}i\\\" \\\"%{User-agent}i\\\" %h\" combined" + "
    " + "
    " + "
    " + "

    Note on custom format strings

    " + "
    " + "

    If you're using your own custom string, please keep in mind that parsing is not magic. When you define your own string, think about which characters can be there in a field and use separators accordingly to not conflict with the field itself.
    " + " As an example: an URI (%U) can't contain whitespaces, so it is safe to use a space to separe this field by the previous and next one. Instead, the User-Agent (*%{User-agent}i*) may contain spaces, as well as parenthesis, brackets, dashes, etc, so it's better to pick an appropriate separator (double-quotes are a good choice, since they get escaped while logging).

    " + "
    " + "
    " + "
    " + "

    Note on control-characters

    " + "
    " + "

    Although Apache2 does support some control-characters (aka escape sequences), it is reccomended to not use them inside format strings.
    " + " In particular, the carriage return will most-likely overwrite previous fields data, making it very difficult to understand where the current field ends (specially for fields like URIs, queries, user-agents, etc) and nearly impossible to retrieve the overwritten data, which will lead in having a wasted database, un-realistic statistics and/or crashes during execution.
    " + " About the new line character, it has no sense to use it, if not for testing purposes. The same is true for the horizontal tab, for which is better to use a simple whitespace instead.
    " + " The only control-characters supported by Apache2 are \n, \t and \r. Any other character will be ignored and treated as text.

    " + "
    " + "
    " + "
    " + "
    " + "
    " + "
    " + "


    Access logs format fields

    " + "
    " + "


    Fields considered by LogDoctor

    " + "
    " + "

    Only the following fields will be considered, meaning that only these fields' data will be stored and used for the statistics.

    " + "
    " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
    CodeInformations
    %%The percent sign character, will result in a single percent sign and treated as normal text (from both Apache and LogDoctor).
    %tTime the request was received, in the format [DD/Mon/YYYY:hh:mm:ss ±TZ]. The last number (TZ) indicates the timezone offset from GMT.
    %{FORMAT}tTime the request was received, in the form given by FORMAT, which should be in an extended strftime format.
    " + " The following format tokens are supported (by LogDoctor, any other than the following will be discarded, even if valid):" + "
    " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
    FormatDescription
    sectime since epoch, in seconds
    msectime since epoch, in milliseconds
    usectime since epoch, in microseconds
    %bmonth name, abbreviated (same as %h)
    %Bmonth name
    %cdate and time representation
    %dday number, zero padded
    %Ddate, in the form of MM/DD/YY
    %eday number, space padded
    %Fdate, in the form of YYYY/MM/DD
    %hmonth name, abbreviated (same as %b)
    %Hhour, in 24h format, zero padded
    %mmonth number, zero padded
    %Mminute
    %rtime if the day, in 12h format, in the form of HH:MM:SS AM/PM
    %Rtime of the day, in HH:MM format
    %Ssecond
    %TISO 8601 time, in the form of HH:MM:SS
    %xdate representation
    %Xtime representation
    %yyear, last two digits (YY)
    %Yyear
    " + "
    " + "
    " + " Note: time formats sec, msec and usec can't be mixed together or with other formats." + "
    %rFirst line of request, equivalent to: %m %U?%q %H.
    %HThe request protocol (HTTP/v, HTTPS/v).
    %mThe request method (GET, POST, HEAD, ...).
    %UThe URI path requested, not including any query string.
    %qQuery string (if any).
    %sHTTP Status code at the beginning of the request (exclude redirections statuses).
    %>sFinal HTTP Status code (in case requests have been internally redirected).
    %IBytes received, including request and headers (you need to enable mod_logio to use this).
    %OBytes sent, including headers (you need to enable mod_logio to use this).
    %TThe time taken to serve the request, in seconds.
    %{UNIT}TThe time taken to serve the request, in a time unit given by UNIT (only available in 2.4.13 and later).
    " + " Valid units are:" + "
    " + " " + " " + " " + " " + " " + "
    UnitDescription
    sseconds
    msmilliseconds
    usmicroseconds
    " + "
    %DThe time taken to serve the request, in milliseconds.
    %hIP Address of the client (remote hostname).
    %{c}hLike %h, but always reports on the hostname of the underlying TCP connection and not any modifications to the remote hostname by modules like mod_remoteip.
    %{VARNAME}iThe contents of VARNAME: header line(s) in the request sent to the server.
    " + " Supported varnames (by LogDoctor) are:" + "
    " + " " + " " + " " + " " + " " + "
    VarNameDescription
    Cookiecookie of the request
    Refererreferrer host
    User-agentweb-browser or bot identification string
    " + "
    " + "
    " + "
    " + "
    " + "

    Fields discarded by LogDoctor

    " + "
    " + "

    Any field than the ones above won't be considered by LogDoctor.
    " + " When generating a log sample, these fields will appear as 'DISCARDED'.
    " + " If you aint using logs for any other purpose, please remove unnecessary fields to make the process faster and reduce the possibility of errors.

    " + "
    " + "
    " + "
    " + "
    " + "
    " + "

    References

    " + "
    " + " " + "
    " + "
    " + "
    " + " " + "" + ); +} + +void Craphelp::defaultNginxFormat( std::string& str ) const +{ + str.append( + "" + "" + " " + " " + " LogDoctor - Help" + " " + " " + " " + "
    " + "

    Nginx

    " + "
    " + "
    " + "
    " + "


    Access logs format string

    " + "
    " + "


    Configuration file

    " + "
    " + "

    The configuration file should be located at:


    " + " /usr/local/etc/nginx/nginx.conf" + "
    " + "

    The line to configure access logs is the one starting with \"log_format main\" followed by the list of fields codes.

    " + "
    " + "
    " + "
    " + "

    Default logs formats

    " + "
    " + "

    The default logs format string is:

    " + "
    " + " log_format main '$remote_addr - $remote_user [$time_local] \"$request\" $status $bytes_sent \"$http_referer\" \"$http_user_agent\"'" + "
    " + "
    " + "
    " + "

    Suggested logs format

    " + "
    " + "

    The suggested format string, to allow using the most of the functionalities of LogDoctor, is:


    " + " log_format main '$time_iso8601 \"$request\" $status $request_length $bytes_sent $request_time \"$http_referer\" \"$http_user_agent\" $remote_addr'" + "
    " + "
    " + "
    " + "

    Note the format strings

    " + "
    " + "

    When copy-pasting the format string, please remove any identation (if present) and just paste the resulting format string only.

    " + "
    " + "
    " + "
    " + "

    Note on control-characters

    " + "
    " + "

    Although Nginx does support some control-characters (aka escape sequences), it is reccomended to not use them inside format strings.
    " + " In particular, the carriage return will most-likely overwrite previous fields data, making it very difficult to understand where the current field ends (specially for fields like URIs, queries, user-agents, etc) and nearly impossible to retrieve the overwritten data, which will lead in having a wasted database, un-realistic statistics and/or crashes during execution.
    " + " About the new line character, it has no sense to use it, if not for testing purposes. The same is true for the horizontal tab, for which is better to use a simple whitespace instead.
    " + " The only control-characters supported by Nginx are \n, \t and \r. Any other character will be ignored and treated as text.

    " + "
    " + "
    " + "
    " + "
    " + "
    " + "
    " + "


    Access logs format fields

    " + "
    " + "


    Fields considered by LogDoctor

    " + "
    " + "

    Only the following fields will be considered, meaning that only these fields' data will be stored and used for the statistics.

    " + "
    " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
    CodeInformations
    $time_localDate and time in CLF (NCSA) format.
    $time_iso8601Date and time in ISO 8601 format.
    $msecTime since epoch (in seconds, with a milliseconds resolution) at the time of the log write.
    $requestFirst line of request, equivalent to: $request_method $request_uri $server_protocol.
    $server_protocolThe request protocol (HTTP/v, HTTPS/v).
    $request_methodThe request method (GET, POST, HEAD, ...).
    $request_uriThe requested URI, including the query string (if any).
    $uriThe URI path requested, not including the query string.
    $query_stringQuery string (if any).
    $statusHTTP status code.
    $request_lengthNumber of bytes received (including request line, header, and request body).
    $bytes_sentThe number of bytes sent to a client.
    $request_timeRequest processing time in seconds with a milliseconds resolution: time elapsed between the first bytes were read from the client and the log write after the last bytes were sent to the client.
    $http_refererReferrer hostname.
    $cookie_NAMECookie of the request having the given NAME.
    $http_user_agentWeb-browser or Bot identification string.
    $remote_addrIP Address of the visitor (client).
    $realip_remote_addrOriginal client IP address.
    " + "
    " + "
    " + "
    " + "

    Fields discarded by LogDoctor

    " + "
    " + "

    Any field than the ones above won't be considered by LogDoctor.
    " + " When generating a log sample, these fields will appear as 'DISCARDED'.
    " + " If you aint using logs for any other purpose, please remove unnecessary fields to make the process faster and reduce the possibility of errors.

    " + "
    " + "
    " + "
    " + "
    " + "

    References

    " + "
    " + " " + "
    " + "
    " + "
    " + " " + "" + ); +} + +void Craphelp::defaultIisFormat( std::string& str ) const +{ + str.append( + "" + "" + " " + " " + " LogDoctor - Help" + " " + " " + " " + "
    " + "

    IIS

    " + "
    " + "
    " + "
    " + "


    Access logs format string

    " + "
    " + "


    Configuration

    " + "
    " + "

    The configuration file should be located at:


    " + " C:\\inetpub\\logs\\LogFiles\\<YourSiteName>" + "
    " + "

    Access logs can be configured from the IIS Manager.
    " + " To open the IIS Manager, go to Control panelAdministrative toolsInternet Informations Service (IIS) Manager.
    " + " Once inside, click on Logging to edit the logs settings.

    " + "
    " + "
    " + "
    " + "

    Logs format modules

    " + "
    " + "

    Available logs formats (supported by LogDoctor) are:

    " + "
    " + "
      " + "
    • IIS
    • " + "

      Comma-separated values, can't be customized further. The file name is usually something like u_in<DATE>.log

      " + "
      " + "
    • NCSA
    • " + "

      Whitespace-separated values, can't be customized further. The file name is usually something like u_nc<DATE>.log

      " + "
      " + "
    • W3C
    • " + "

      Whitespace-separated values, can be customized by selecting which fields to log. The file name is usually something like u_ex<DATE>.log

      " + "
    " + "
    " + "
    " + "
    " + "

    Suggested logs format

    " + "
    " + "

    The suggested logs module is the W3C format, which will allow using the complete set of functionalities of LogDoctor.

    " + "

    The suggested fields to use are the following:


    " + " date, time, cs-method, cs-uri-stem, cs-uri-query, c-ip, cs-version, cs(User-Agent), cs(Cookie), cs(Referer), sc-status, sc-bytes, cs-bytes, time-taken" + "
    " + "
    " + "
    " + "

    Logs format strings

    " + "
    " + "

    Both the IIS and NCSA modules are standard, and thus LogDoctor doesn't need the format string to be specified.
    " + " The W3C module can be customized and so a format string must be specified. It can be found insed any log file created using this format module, searching the line starting with #Fields:.

    " + "
    " + "
    " + "
    " + "
    " + "
    " + "
    " + "


    W3C logs format fields

    " + "
    " + "


    Fields considered by LogDoctor

    " + "
    " + "

    Only the following fields will be considered, meaning that only these fields' data will be stored and used for the statistics.

    " + "
    " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "
    CodeInformations
    dateThe date on which the activity occurred (UTC).
    timeThe time at which the activity occurred (UTC).
    cs-versionThe request protocol (HTTP/v, HTTPS/v).
    cs-methodThe request method (GET, POST, HEAD, ...).
    cs-uri-stemThe URI path requested, not including any query string.
    cs-uri-queryQuery string (if any).
    sc-statusHTTP status code.
    cs-bytesThe number of bytes received and processed by the server.
    sc-bytesThe number of bytes sent back by the server.
    time-takenTime taken to serve the request, in milliseconds
    cs(Referer)The site which provided a link to the current site.
    cs(Cookie)The content of the cookie sent or received (if any).
    cs(User-Agent)Web-browser or bot identification string
    c-ipThe IP address of the client that made the request.
    " + "
    " + "
    " + "
    " + "

    Fields discarded by LogDoctor

    " + "
    " + "

    Any field than the ones above won't be considered by LogDoctor.
    " + " When generating a log sample, these fields will appear as 'DISCARDED'.
    " + " If you aint using logs for any other purpose, please remove unnecessary fields to make the process faster and reduce the possibility of errors.

    " + "
    " + "
    " + "
    " + "
    " + "

    References

    " + "
    " + " " + "
    " + "
    " + "
    " + " " + "" + ); +} + diff --git a/logdoctor/modules/craphelp/craphelp.h b/logdoctor/modules/craphelp/craphelp.h index 7fadc1c1..dc6c4c61 100644 --- a/logdoctor/modules/craphelp/craphelp.h +++ b/logdoctor/modules/craphelp/craphelp.h @@ -30,10 +30,23 @@ public: */ void helpLogsFormat( const std::string& path, const QFont& font, const int& color_scheme_id ) const; + //! Provides help about log formats + /*! + Shows the built-in default version in case the file + for the currently selected locale was not found or unreadable + \param font The font to be used + \param color_scheme_id The ID of the color-scheme to be used + */ + void helpLogsFormatDefault( const std::string& path, const QFont& font, const int& color_scheme_id ) const; + private: Ui::Craphelp *ui; const std::unordered_map getColorScheme( const int& scheme_id ) const; + + void defaultApacheFormat( std::string& str ) const; + void defaultNginxFormat( std::string& str ) const; + void defaultIisFormat( std::string& str ) const; }; #endif // CRAPHELP_H From b98c97735ffa2b975b84f8f1c3114d8fba60125a Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:08:41 +0100 Subject: [PATCH 17/36] Fix Fixed Crapup resulting in a crash when no connection is available and it gets launched twice before connection expires --- logdoctor/modules/crapup/crapup.cpp | 44 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/logdoctor/modules/crapup/crapup.cpp b/logdoctor/modules/crapup/crapup.cpp index 9f4fbd3f..6420af25 100644 --- a/logdoctor/modules/crapup/crapup.cpp +++ b/logdoctor/modules/crapup/crapup.cpp @@ -30,32 +30,39 @@ Crapup::Crapup( const int& window_theme_id, const QString& icons_theme, QWidget* Crapup::~Crapup() { - delete this->ui; - if ( this->reply ) { - delete this->reply; + if ( this->ui != nullptr ) { + delete this->ui; + this->ui = nullptr; } - if ( this->img_timer ) { + if ( this->reply != nullptr ) { + this->deleteReply(); + } + if ( this->img_timer != nullptr ) { delete this->img_timer; + this->img_timer = nullptr; } - if ( this->request_timer ) { + if ( this->request_timer != nullptr ) { delete this->request_timer; + this->request_timer = nullptr; } } void Crapup::closeEvent( QCloseEvent* event ) { this->quitting = true; - if ( this->img_timer->isActive() ) { - this->img_timer->stop(); - } - if ( this->request_timer->isActive() ) { - this->request_timer->stop(); - } - if ( this->reply ) { - if ( !this->reply->isFinished() ) { - this->requestTimeout(); + if ( this->img_timer != nullptr ) { + if ( this->img_timer->isActive() ) { + this->img_timer->stop(); } } + if ( this->request_timer != nullptr ) { + if ( this->request_timer->isActive() ) { + this->request_timer->stop(); + } + } + if ( this->reply != nullptr ) { + this->requestTimeout(); + } } @@ -104,8 +111,8 @@ void Crapup::versionCheck( const float v ) // reply waiter loop QEventLoop wait_reply; - connect(this->reply, SIGNAL(readyRead()), &wait_reply, SLOT(quit())); - connect(this, SIGNAL(abortRequest()), &wait_reply, SLOT(quit())); + connect(this->reply, &QNetworkReply::readyRead, &wait_reply, &QEventLoop::quit); + connect(this, &Crapup::abortRequest, &wait_reply, &QEventLoop::quit); // make the request this->request_timer->start( this->timeout_msec+1000 ); @@ -254,11 +261,8 @@ void Crapup::requestTimeout() void Crapup::deleteReply() { - if ( !this->reply->isFinished() ) { - this->reply->abort(); - } if ( this->reply->isOpen() ) { - this->reply->close(); + this->reply->abort(); } delete this->reply; this->reply = nullptr; From 1380d79bc1031095dadb787415964aaf132df1a1 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:10:26 +0100 Subject: [PATCH 18/36] Adjusted parsed logs' chart size --- logdoctor/modules/craplog/modules/donuts.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/logdoctor/modules/craplog/modules/donuts.cpp b/logdoctor/modules/craplog/modules/donuts.cpp index 6c6e5291..a0f3710f 100644 --- a/logdoctor/modules/craplog/modules/donuts.cpp +++ b/logdoctor/modules/craplog/modules/donuts.cpp @@ -44,7 +44,7 @@ DonutBreakdown::DonutBreakdown( QGraphicsItem* parent, Qt::WindowFlags wFlags ) { // create the series for main center pie this->m_mainSeries = new QPieSeries(); - this->m_mainSeries->setPieSize( 0.7 ); + this->m_mainSeries->setPieSize( 0.6 ); QChart::addSeries( this->m_mainSeries ); } @@ -66,8 +66,8 @@ void DonutBreakdown::addBreakdownSeries( QPieSeries* breakdownSeries, const QCol mainSlice->setLabelFont( font ); // position and customize the breakdown series - breakdownSeries->setPieSize( 0.8 ); - breakdownSeries->setHoleSize( 0.7 ); + breakdownSeries->setPieSize( 0.7 ); + breakdownSeries->setHoleSize( 0.6 ); breakdownSeries->setLabelsVisible(); const auto slices = breakdownSeries->slices(); for (QPieSlice *slice : slices) { From 6e8aa9749fb0d4eb0fd1730f089fd0a929d3d56a Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:12:52 +0100 Subject: [PATCH 19/36] Added PrintSec in Utilities Collection of methods for printable stuff --- logdoctor/utilities/printables.cpp | 161 +++++++++++++++++++++++++++++ logdoctor/utilities/printables.h | 86 +++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 logdoctor/utilities/printables.cpp create mode 100644 logdoctor/utilities/printables.h diff --git a/logdoctor/utilities/printables.cpp b/logdoctor/utilities/printables.cpp new file mode 100644 index 00000000..dc529a6c --- /dev/null +++ b/logdoctor/utilities/printables.cpp @@ -0,0 +1,161 @@ + +#include "printables.h" + +#include "modules/shared.h" + + +PrintSec::PrintSec() +{ + +} + + +const QString PrintSec::printableSize( const unsigned bytes ) +{ + std::string size_str, size_sfx=" B"; + float size = (float)bytes; + if (size > 1024) { + size /= 1024; + size_sfx = " KiB"; + if (size > 1024) { + size /= 1024; + size_sfx = " MiB"; + } + } + // cut decimals depending on how big the floor is + size_str = std::to_string( size ); + size_t cut_index = size_str.find('.')+1; + if ( cut_index == 0 ) { // catches the overflow of +1 of the above + cut_index = size_str.find(',')+1; + } + size_t n_decimals = 3; + if ( size >= 100 ) { + n_decimals --; + if ( size >= 1000 ) { + n_decimals --; + if ( size >= 10000 ) { + n_decimals --; + cut_index --; // no decimals, no "dot" + } + } + } + if ( cut_index >= 1 ) { + cut_index += n_decimals; + if ( cut_index >= size_str.size() ) { + cut_index = size_str.size()-1; + } + } + return QString::fromStdString( size_str.substr(0,cut_index) + size_sfx ); +} + + +const QString PrintSec::printableSpeed( const unsigned bytes, const unsigned secs_ ) +{ + std::string speed_str, speed_sfx=" B/s"; + unsigned secs = secs_; + if ( secs == 0 ) { + secs ++; + } + float speed = (float)bytes / (float)secs; + if (speed > 1024) { + speed /= 1024; + speed_sfx = " KiB/s"; + if (speed > 1024) { + speed /= 1024; + speed_sfx = " MiB/s"; + } + } + // cut decimals depending on how big the floor is + speed_str = std::to_string( speed ); + size_t cut_index = speed_str.find('.')+1; + if ( cut_index == 0 ) { // catches the overflow of +1 of the above + cut_index = speed_str.find(',')+1; + } + size_t n_decimals = 3; + if ( speed >= 100 ) { + n_decimals --; + if ( speed >= 1000 ) { + n_decimals --; + if ( speed >= 10000 ) { + n_decimals --; + cut_index --; // no decimals, no "dot" + } + } + } + if ( cut_index >= 1 ) { + cut_index += n_decimals; + if ( cut_index >= speed_str.size() ) { + cut_index = speed_str.size()-1; + } + } + return QString::fromStdString( speed_str.substr(0,cut_index) + speed_sfx ); +} + + +const QString PrintSec::printableTime( const unsigned seconds ) +{ + const unsigned mins = seconds / 60; + const unsigned secs = seconds - (mins*60); + return QString("%1:%2").arg( + (mins<10) + ? QString("0%1").arg( mins ) + : QString::number( mins ), + (secs<10) + ? QString("0%1").arg( secs ) + : QString::number( secs ) + ); +} + + +const QString PrintSec::printableTime( const int hour, const int minute, const int second ) +{ + return QString("%1:%2:%3").arg( + (hour<10) + ? QString("0%1").arg( hour ) + : QString::number( hour ), + (minute<10) + ? QString("0%1").arg( minute ) + : QString::number( minute ), + (second<10) + ? QString("0%1").arg( second ) + : QString::number( second ) + ); +} + + +const QString PrintSec::printableDate( const QString& year, const int month, const QString& day ) +{ + return QString("%1-%2-%3").arg( + year, + (month<10) + ? QString("0%1").arg( month ) + : QString::number( month ), + (day.size()<2) + ? QString("0%1").arg( day ) + : day + ); +} + + +const QString PrintSec::printableDate( const int year, const int month, const int day ) +{ + return QString("%1-%2-%3").arg( + QString::number( year ), + (month<10) + ? QString("0%1").arg( month ) + : QString::number( month ), + (day<10) + ? QString("0%1").arg( day ) + : QString::number( day ) + ); +} + + +const QString PrintSec::printableBool( const int value ) +{ + if ( value == 0 ) { + return TR::tr( BOOLS__FALSE.c_str() ); + } else { + return TR::tr( BOOLS__TRUE.c_str() ); + } +} diff --git a/logdoctor/utilities/printables.h b/logdoctor/utilities/printables.h new file mode 100644 index 00000000..ff3b025f --- /dev/null +++ b/logdoctor/utilities/printables.h @@ -0,0 +1,86 @@ +#ifndef PRINTSEC_H +#define PRINTSEC_H + +#include + + +class PrintSec +{ +public: + explicit PrintSec(); + + + //! Formats the size including the suffix, for display purposes + /*! + \param bytes The size in bytes + \return The string to be displayed + */ + static const QString printableSize( const unsigned bytes ); + + + //! Formats the speed including the suffix, for display purposes + /*! + \param bytes The size in bytes + \param seconds The number of seconds + \return The string to be displayed + */ + static const QString printableSpeed( + const unsigned bytes, const unsigned seconds + ); + + + //! Formats the time, for display purposes + /*! + \param seconds The number of seconds + \return The string to be displayed + */ + static const QString printableTime( const unsigned seconds ); + + + //! Returns a string of the given time in the format HH:MM:SS + /*! + \param hour The hour + \param minut The minute + \param second The second + \return The printable time + */ + static const QString printableTime( + const int hour, const int minute, const int second + ); + + + //! Returns a string of the given date in the format YYYY-MM-DD + /*! + \overload const QString printableDate(const int& year, const int& month, const int& day) + \param year The year + \param month The month + \param day The day + \return The printable date + */ + static const QString printableDate( + const QString& year, const int month, const QString& day + ); + + + //! Returns a string of the given date in the format YYYY-MM-DD + /*! + \param year The year (4 digits number) + \param month The month + \param day The day + \return The printable date + */ + static const QString printableDate( + const int year, const int month, const int day + ); + + + //! Returns a string corresponding to the given value + /*! + Used to convert numeric booleans [0,1] to string [FALSE,TRUE] + \param value The value to convert + \return The corresponding printable string + */ + static const QString printableBool( const int value ); +}; + +#endif // PRINTSEC_H From 21855fe1f679f576c73347dafb17922fdb3da921 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:15:47 +0100 Subject: [PATCH 20/36] Code improvements Enhanced data types for statistic's queries --- logdoctor/utilities/result.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/logdoctor/utilities/result.h b/logdoctor/utilities/result.h index 8d8c1e07..202f59a1 100644 --- a/logdoctor/utilities/result.h +++ b/logdoctor/utilities/result.h @@ -6,6 +6,7 @@ #include #include #include +#include //! Result @@ -41,11 +42,11 @@ private: // data types -typedef std::unordered_map>>> stats_dates_t; +typedef std::map>>> stats_dates_t; typedef std::vector>>> stats_warn_items_t; typedef std::vector>> stats_speed_items_t; typedef std::unordered_map> stats_day_items_t; typedef std::vector> stats_relat_items_t; -typedef std::vector> stats_count_items_t; +typedef std::map stats_count_items_t; #endif // RESULT_H From 9310a852aca639415509f8d177f28c1dc3d8ba5e Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:20:11 +0100 Subject: [PATCH 21/36] Improvements and updates Code and performances improvements. Updated queries data types. Added new method: 'countDays'. Renamed method 'getMonthsCount' to 'countMonths'. --- logdoctor/modules/crapview/modules/query.cpp | 582 ++++++++++--------- logdoctor/modules/crapview/modules/query.h | 23 +- 2 files changed, 326 insertions(+), 279 deletions(-) diff --git a/logdoctor/modules/crapview/modules/query.cpp b/logdoctor/modules/crapview/modules/query.cpp index d9fa147d..fcd1d932 100644 --- a/logdoctor/modules/crapview/modules/query.cpp +++ b/logdoctor/modules/crapview/modules/query.cpp @@ -71,22 +71,57 @@ const int DbQuery::getMonthDays( const int year, const int month ) const return n_days; } -const int DbQuery::getMonthsCount( const QString& from_year, const QString& from_month, const QString& to_year, const QString& to_month ) const + +const int DbQuery::getMonthNumber( const QString& month_str ) const { - int from_year_, from_month_, to_year_, to_month_; - try { - from_year_ = from_year.toInt(); - from_month_ = this->getMonthNumber( from_month ); - to_year_ = ( to_year.size() == 0 ) ? from_year_ : to_year.toInt() ; - to_month_ = ( to_month.size() == 0 ) ? from_month_ : this->getMonthNumber( to_month ) ; - } catch (...) { - // failed to convert to integers - throw DateTimeException( "Failed to convert Month from string to int" ); // leave un-catched + int m=0; + for ( const auto& [num,str] : this->MONTHS ) { + if ( TR::tr(str.c_str()) == month_str ) { + m = num; + break; + } } - return this->getMonthsCount( from_year_, from_month_, to_year_, to_month_ ); + return m; } -const int DbQuery::getMonthsCount( const int& from_year, const int& from_month, const int& to_year, const int& to_month ) const + +const int DbQuery::countDays( const int from_year, const int from_month, const int from_day, const int to_year, const int to_month, const int to_day ) const +{ + int n_days = 1; + if ( from_year == to_year ) { + // 1 year + if ( from_month == to_month ) { + // 1 month + n_days += to_day - from_day + 1; + } else { + n_days += this->getMonthDays( from_year, from_month ) - from_day; // first month's days + for ( int month=from_month+1; monthgetMonthDays( from_year, month ); + } + n_days += to_day; // last month's days + } + } else { + n_days += this->getMonthDays( from_year, from_month ) - from_day; + if ( from_month < 12 ) { + for ( int month=from_month+1; month<=12; month++ ) { + n_days += this->getMonthDays( from_year, month ); + } + } + for ( int year=from_year+1; year<=to_year; year++ ) { + int last_month = 12; + if ( year == to_year ) { + last_month = to_month-1; + n_days += to_day; // last month's days, added in advance + } + for ( int month=1; month<=last_month; month++ ) { + n_days += this->getMonthDays( year, month ); + } + } + } + return n_days; +} + +const int DbQuery::countMonths( const int& from_year, const int& from_month, const int& to_year, const int& to_month ) const { int n_months = 0; if ( from_year == to_year ) { @@ -107,17 +142,19 @@ const int DbQuery::getMonthsCount( const int& from_year, const int& from_month, return n_months; } - -const int DbQuery::getMonthNumber( const QString& month_str ) const +const int DbQuery::countMonths( const QString& from_year, const QString& from_month, const QString& to_year, const QString& to_month ) const { - int m=0; - for ( const auto& [num,str] : this->MONTHS ) { - if ( TR::tr(str.c_str()) == month_str ) { - m = num; - break; - } + int from_year_, from_month_, to_year_, to_month_; + try { + from_year_ = from_year.toInt(); + from_month_ = this->getMonthNumber( from_month ); + to_year_ = ( to_year.size() == 0 ) ? from_year_ : to_year.toInt() ; + to_month_ = ( to_month.size() == 0 ) ? from_month_ : this->getMonthNumber( to_month ) ; + } catch (...) { + // failed to convert to integers + throw DateTimeException( "Failed to convert Month from string to int" ); // leave un-catched } - return m; + return this->countMonths( from_year_, from_month_, to_year_, to_month_ ); } @@ -197,6 +234,7 @@ void DbQuery::refreshDates( Result& result ) } else { int year, month, day; + auto& years = dates.at( ws ); while ( Y_query.next() ) { try { year = Y_query.value(0).toInt(); @@ -214,7 +252,7 @@ void DbQuery::refreshDates( Result& result ) break; } // successfully get the year - dates.at( ws ).emplace( year, std::unordered_map>() ); + years.emplace( year, std::map>() ); // query any available month if ( ! M_query.exec( QString("SELECT DISTINCT \"month\" FROM \"%1\" WHERE \"year\"=%2 ORDER BY \"month\" ASC;").arg(tbl).arg(year) ) ) { // error querying database @@ -223,6 +261,7 @@ void DbQuery::refreshDates( Result& result ) break; } else { + auto& months = years.at( year ); while ( M_query.next() ) { try { month = M_query.value(0).toInt(); @@ -240,7 +279,7 @@ void DbQuery::refreshDates( Result& result ) break; } // successfully get the month - dates.at( ws ).at( year ).emplace( month, std::vector() ); + months[ month ] = std::vector(); // query any available day if ( ! D_query.exec( QString("SELECT DISTINCT \"day\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3 ORDER BY \"day\" ASC;").arg(tbl).arg(year).arg(month) ) ) { // error querying database @@ -248,7 +287,12 @@ void DbQuery::refreshDates( Result& result ) DialogSec::errDatabaseFailedExecuting( this->db_name, D_query.lastQuery(), D_query.lastError().text() ); break; - } else { + } else if ( D_query.last() ) { + auto& days = months.at( month ); + days.reserve( D_query.at() ); + D_query.first(); + D_query.previous(); + while ( D_query.next() ) { try { day = D_query.value(0).toInt(); @@ -266,7 +310,7 @@ void DbQuery::refreshDates( Result& result ) break; } // successfully get the day - dates.at( ws ).at( year ).at( month ).push_back( day ); + days.push_back( day ); } D_query.finish(); // break if something went wrong @@ -402,9 +446,11 @@ void DbQuery::getWarnCounts( Result& result, const QString& if ( hour_.size() == 0 ) { // entire day + items.reserve( 24 ); for ( int h=0; h<24; h++ ) { items.push_back( std::vector>>() ); - std::vector>>& aux = items.at( h ); + auto& aux = items.at( h ); + aux.reserve( 6 ); for ( int m=0; m<60; m+=10 ) { aux.push_back( std::vector>() ); } @@ -421,6 +467,7 @@ void DbQuery::getWarnCounts( Result& result, const QString& // get query data while ( query.next() ) { std::vector aux; + aux.reserve( 20 ); for ( int i=1; i<13; i++ ) { aux.push_back( query.value( i ).toString() ); } @@ -442,9 +489,11 @@ void DbQuery::getWarnCounts( Result& result, const QString& } else { // 1 hour + items.reserve( 6 ); for ( int g=0; g<6; g++ ) { items.push_back( std::vector>>() ); - std::vector>>& aux = items.at( g ); + auto& aux = items.at( g ); + aux.reserve( 10 ); for ( int m=0; m<10; m++ ) { aux.push_back( std::vector>() ); } @@ -461,6 +510,7 @@ void DbQuery::getWarnCounts( Result& result, const QString& // get query data while ( query.next() ) { std::vector aux; + aux.reserve( 20 ); for ( int i=1; i<13; i++ ) { aux.push_back( query.value( i ).toString() ); } @@ -623,13 +673,21 @@ void DbQuery::getSpeedData( Result& result, const QString& DialogSec::errDatabaseFailedExecuting( this->db_name, query.lastQuery(), query.lastError().text() ); } else { + try { + // append the first fictitious count + time.setDate( QDate( year, month, day ) ); + time.setTime( QTime( 0, 0, 0 )); + data.push_back( std::make_tuple( + time.toMSecsSinceEpoch(), + std::vector{"","","","","",""} )); - if ( query.size() == 0 ) { - // no result found - ; + if ( query.last() ) { + data.clear(); + data.reserve( query.at()*2 ); + query.first(); + query.previous(); - } else { // get query data int hour=-1, aux_hour, prev_hour=0, h, minute=0, aux_minute, prev_minute=0, m, @@ -731,7 +789,7 @@ void DbQuery::getSpeedData( Result& result, const QString& std::vector{"","","","","",""} )); } } else { - // append the second 0 of the day, if it is not the next found + // append the second 0 of the day, if it is not the one found if ( aux_hour > 0 || aux_minute > 0 || aux_second > 0 ) { time.setTime( QTime( 0, 0, 0 )); data.push_back( std::make_tuple( @@ -811,22 +869,22 @@ void DbQuery::getSpeedData( Result& result, const QString& time.toMSecsSinceEpoch(), std::vector{"","","","","",""} )); } - // append the real last fictitious count - day ++; - if ( day > this->getMonthDays( year, month ) ) { - day = 1; - month ++; - if ( month > 12 ) { - month = 1; - year ++; - } - } - time.setDate( QDate( year, month , day ) ); - time.setTime( QTime( 0, 0, 0 )); - data.push_back( std::make_tuple( - time.toMSecsSinceEpoch(), - std::vector{"","","","","",""} )); } + // append the last fictitious count + day ++; + if ( day > this->getMonthDays( year, month ) ) { + day = 1; + month ++; + if ( month > 12 ) { + month = 1; + year ++; + } + } + time.setDate( QDate( year, month , day ) ); + time.setTime( QTime( 0, 0, 0 )); + data.push_back( std::make_tuple( + time.toMSecsSinceEpoch(), + std::vector{"","","","","",""} )); } catch (...) { // something failed successful = false; @@ -838,6 +896,8 @@ void DbQuery::getSpeedData( Result& result, const QString& if ( ! successful ) { data.clear(); + } else if ( data.capacity() > data.size() ) { + data.shrink_to_fit(); } if ( db.isOpen() ) { db.close(); @@ -851,8 +911,8 @@ void DbQuery::getSpeedData( Result& result, const QString& void DbQuery::getItemsCount( Result& result, const QString& web_server, const QString& year, const QString& month, const QString& day, const QString& log_field ) const { bool successful = true; - QHash aux_items; - stats_count_items_t items; // std::vector> + QHash aux_items; + stats_count_items_t items; // std::map> QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -893,20 +953,18 @@ void DbQuery::getItemsCount( Result& result, const QString& successful = false; DialogSec::errDatabaseFailedExecuting( this->db_name, query.lastQuery(), query.lastError().text() ); - } else { + } else if ( query.last() ) { + aux_items.reserve( query.at() ); + query.first(); + query.previous(); + try { // get data QString item; while ( query.next() ) { item = query.value(0).toString(); if ( item.size() > 0 ) { - if ( aux_items.find( item ) == aux_items.end() ) { - // not present yet - aux_items.insert( item, 1 ); - } else { - // already in the list, increase the count - aux_items[ item ] ++; - } + aux_items[ item ] ++; } } } catch (...) { @@ -916,23 +974,12 @@ void DbQuery::getItemsCount( Result& result, const QString& } } } - if ( successful ) { - // sort the list - std::tuple item; - // morph tha HashMap into a Vector of Tuples - foreach ( const QString& v, aux_items.keys() ) { - item = std::make_tuple( v, aux_items.value( v ) ); - items.push_back( item ); - } - // sort the vector - for ( int i=0; i(items.at( i )) > std::get<1>(items.at( j )) ) { - item = items.at( i ); - items.at( i ) = items.at( j ); - items.at( j ) = item; - } - } + if ( successful ) { // sort the list + // morph tha QHash into an ordered map + QHashIterator iter( aux_items ); + while ( iter.hasNext() ) { + iter.next(); + items.emplace( iter.value(), iter.key() ); } } aux_items.clear(); @@ -1015,12 +1062,13 @@ void DbQuery::getDaytimeCounts( Result& result, const QString QString log_field = this->getDbField( log_field_ ); int n_days = 0, - n_months = this->getMonthsCount( from_year, from_month, to_year, to_month ); + n_months = this->countMonths( from_year, from_month, to_year, to_month ); int year = from_year, month = from_month, day, hour, minute; - QList days_l; + std::unordered_map days_l; + days_l.reserve( 31 ); if ( n_months == 1 ) { // 1 month, no need to loop @@ -1072,8 +1120,6 @@ void DbQuery::getDaytimeCounts( Result& result, const QString } else { try { - // clear the list of found days - days_l.clear(); // get query data while ( query.next() ) { day = query.value(0).toInt(); @@ -1082,9 +1128,7 @@ void DbQuery::getDaytimeCounts( Result& result, const QString // increase the count data.at( hour ).at( this->getMinuteGap( minute ) ) ++; // append the day as newly found if not found yet - if ( days_l.indexOf( day ) < 0 ) { - days_l.push_back( day ); - } + days_l[ day ] ++; } n_days += days_l.size(); } catch (...) { @@ -1101,7 +1145,7 @@ void DbQuery::getDaytimeCounts( Result& result, const QString .arg( web_server ) .arg( year ).arg( month ); if ( m == 1 ) { - // first month, only get the day from the beginning day + // first month, only get the days starting from the beginning day stmt += QString(" AND \"day\">=%1").arg( from_day ); } else if ( m == n_months ) { // last month, only get the days until the ending day @@ -1163,9 +1207,7 @@ void DbQuery::getDaytimeCounts( Result& result, const QString // increase the count data.at( hour ).at( this->getMinuteGap( minute ) ) ++; // append the day as newly found if not found yet - if ( days_l.indexOf( day ) < 0 ) { - days_l.push_back( day ); - } + days_l[ day ] ++; } n_days += days_l.size(); month ++; @@ -1211,6 +1253,7 @@ void DbQuery::getRelationalCountsDay( Result& result, const { bool successful = true; stats_relat_items_t data; // std::vector> + int gap = 20; QSqlDatabase db; if ( QSqlDatabase::contains("qt_sql_default_connection") ) { @@ -1340,101 +1383,102 @@ void DbQuery::getRelationalCountsDay( Result& result, const successful = false; DialogSec::errDatabaseFailedExecuting( this->db_name, query.lastQuery(), query.lastError().text() ); + } else if ( ! query.last() ) { + // no result found, fill with 0 values + for ( int h=0; h<24; h++ ) { + for ( int m=0; m<60; m+=gap ) { + time.setTime( QTime( h, m ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); + } + } + } else { + query.first(); + query.previous(); + try { + data.reserve( 24*(60/gap) ); // get query data int hour, aux_hour, minute, aux_minute, count; - int gap = 20; hour = -1; minute = count = 0; - if ( query.size() == 0 ) { - // no result found, append missing days with 0 value - for ( int h=0; h<24; h++ ) { - for ( int m=0; m<60; m+=gap ) { - time.setTime( QTime( h, m ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); - } - } - - } else { - while ( query.next() ) { - aux_hour = query.value(0).toInt(); - aux_minute = this->getMinuteGap( query.value(1).toInt(), gap ); - if ( aux_hour == hour && aux_minute == minute ) { - count ++; + while ( query.next() ) { + aux_hour = query.value(0).toInt(); + aux_minute = this->getMinuteGap( query.value(1).toInt(), gap ); + if ( aux_hour == hour && aux_minute == minute ) { + count ++; + } else { + if ( aux_hour == hour ) { + // same hour new minute gap, append the last count + time.setTime( QTime( hour, minute ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); + // and any missing gap + for ( int m=minute+gap; m= 0 ) { + // apend the last minute-gap count if not in the first round of the loop time.setTime( QTime( hour, minute ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); - // and any missing gap - for ( int m=minute+gap; m= 0 ) { - // apend the last minute-gap count if not in the first round of the loop - time.setTime( QTime( hour, minute ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); - // append any missing gap in the current hour - for ( int m=minute+gap; m<60; m+=gap ) { - time.setTime( QTime( hour, m ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); - } - hour ++; - } else { - // prepare to add missing gaps from 00:00 (+gap will be added to the minute) - hour = 0; - } - // append any missing gap in every hour between the current and the next found (aux) - for ( int h=hour; h this->getMonthDays( year, month ) ) { - day = 1; - month ++; - if ( month > 12 ) { - month = 1; - year ++; - } - } - time.setDate( QDate( year, month , day ) ); - time.setTime( QTime( 0, 0 ) ); - //time.setTime( QTime( 23, 59, 59, 999 ) ); + } + // append the last count + time.setTime( QTime( hour, minute ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); + // yet again, append any missing gap + for ( int m=minute+gap; m<60; m+=gap ) { + time.setTime( QTime( hour, m ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } + for ( int h=hour+1; h<24; h++ ) { + for ( int m=0; m<60; m+=gap ) { + time.setTime( QTime( h, m ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); + } + } + // append the real last fictitious count + day ++; + if ( day > this->getMonthDays( year, month ) ) { + day = 1; + month ++; + if ( month > 12 ) { + month = 1; + year ++; + } + } + time.setDate( QDate( year, month , day ) ); + time.setTime( QTime( 0, 0 ) ); + //time.setTime( QTime( 23, 59, 59, 999 ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } catch (...) { // something failed successful = false; @@ -1507,7 +1551,7 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co QString log_field_1 = this->getDbField( log_field_1_ ), log_field_2 = this->getDbField( log_field_2_ ); - int n_months = this->getMonthsCount( from_year, from_month, to_year, to_month ); + int n_months = this->countMonths( from_year, from_month, to_year, to_month ); QDateTime time; int year = from_year, @@ -1580,97 +1624,99 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co successful = false; DialogSec::errDatabaseFailedExecuting( this->db_name, query.lastQuery(), query.lastError().text() ); + } else if ( ! query.last() ) { + // no days found, append missing days with 0 value + for ( int d=from_day; d<=to_day; d++ ) { + time.setDate( QDate( year, month , d ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); + } + } else { + query.first(); + query.previous(); + try { + data.reserve( to_day - from_day ); // get query data day = count = 0; - if ( query.size() == 0 ) { - // no days found, append missing days with 0 value - for ( int d=from_day; d<=to_day; d++ ) { - time.setDate( QDate( year, month , d ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); - } - - } else { - while ( query.next() ) { - aux_day = query.value(0).toInt(); - if ( aux_day == day ) { - count ++; - } else { - if ( day > 0 ) { - // any loop-round except the first - time.setDate( QDate( year, month , day ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); - for ( int d=day+1; dgetMonthDays( y, m ); - } - for ( ; d!=aux_day; d++ ) { - if ( d > this->getMonthDays( y, m ) ) { - d = 1; - m ++; - if ( m > 12 ) { - m = 1; - y ++; - } - } - time.setDate( QDate( y, m , d ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); - } + while ( query.next() ) { + aux_day = query.value(0).toInt(); + if ( aux_day == day ) { + count ++; + } else { + if ( day > 0 ) { + // any loop-round except the first + time.setDate( QDate( year, month , day ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); + for ( int d=day+1; dgetMonthDays( y, m ); + } + for ( ; d!=aux_day; d++ ) { + if ( d > this->getMonthDays( y, m ) ) { + d = 1; + m ++; + if ( m > 12 ) { + m = 1; + y ++; + } + } + time.setDate( QDate( y, m , d ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } - day = aux_day; - count = 1; } + day = aux_day; + count = 1; } - // append the last count - time.setDate( QDate( year, month , day ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); - // append any missing day from the last found until 1 day fater the last one - day++; + } + // append the last count + time.setDate( QDate( year, month , day ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); + // append any missing day from the last found until 1 day fater the last one + day++; + if ( day > this->getMonthDays( year, month ) ) { + month ++; + if ( month > 12 ) { + month = 1; + year ++; + } + day = this->getMonthDays( year, month ); + } + to_day += 2; + if ( to_day > this->getMonthDays( year, month ) ) { + int m = month + 1, + y = year; + if ( m > 12 ) { + m = 1; + y ++; + } + to_day = this->getMonthDays( y, m ); + } + for ( ; day!=to_day; day++ ) { if ( day > this->getMonthDays( year, month ) ) { + day = 1; month ++; if ( month > 12 ) { month = 1; year ++; } - day = this->getMonthDays( year, month ); - } - to_day += 2; - if ( to_day > this->getMonthDays( year, month ) ) { - int m = month + 1, - y = year; - if ( m > 12 ) { - m = 1; - y ++; - } - to_day = this->getMonthDays( y, m ); - } - for ( ; day!=to_day; day++ ) { - if ( day > this->getMonthDays( year, month ) ) { - day = 1; - month ++; - if ( month > 12 ) { - month = 1; - year ++; - } - } - time.setDate( QDate( year, month , day ) ); - data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } + time.setDate( QDate( year, month , day ) ); + data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } } catch (...) { // something failed @@ -1679,7 +1725,9 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co } } + } else { + data.reserve( this->countDays( from_year, from_month, from_day, to_year, to_month, to_day ) ); for ( int m=1; m<=n_months; m++ ) { stmt = QString("SELECT \"day\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3") .arg( web_server ) @@ -1699,7 +1747,8 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co // apply a filter if present if ( field_filter_1.size() > 0 ) { QString filter = field_filter_1; - if ( log_field_1 == "response" + if ( log_field_1 == "warning" + || log_field_1 == "response" || log_field_1 == "time_taken" || log_field_1 == "bytes_sent" || log_field_1 == "bytes_received" ) { @@ -1724,7 +1773,8 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co // apply a filter if present if ( field_filter_2.size() > 0 ) { QString filter = field_filter_2; - if ( log_field_2 == "response" + if ( log_field_2 == "warning" + || log_field_2 == "response" || log_field_2 == "time_taken" || log_field_2 == "bytes_sent" || log_field_2 == "bytes_received" ) { @@ -1753,9 +1803,7 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co } else { try { - // get query data - day = count = 0; - if ( query.size() == 0 ) { + if ( ! query.last() ) { // no days found, append missing days with 0 value int f_d = 1, t_d = this->getMonthDays( year, month ); @@ -1772,6 +1820,10 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co } } else { + query.first(); + query.previous(); + // get query data + day = count = 0; while ( query.next() ) { aux_day = query.value(0).toInt(); if ( aux_day == day ) { @@ -1839,6 +1891,8 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co if ( ! successful ) { data.clear(); + } else if ( data.capacity() > data.size() ) { + data.shrink_to_fit(); } if ( db.isOpen() ) { db.close(); @@ -1848,7 +1902,7 @@ void DbQuery::getRelationalCountsPeriod( Result& result, co -const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unordered_map>>& dates, std::vector>& recurs, std::tuple& traf_date, std::unordered_map& traf_day, std::unordered_map& traf_hour, std::vector& perf_time, std::vector& perf_sent, std::vector& perf_receiv, long& req_count ) const +const bool DbQuery::getGlobalCounts( const QString& web_server, const std::map>>& dates, std::vector>& recurs, std::tuple& traf_date, std::unordered_map& traf_day, std::unordered_map& traf_hour, std::vector& perf_time, std::vector& perf_sent, std::vector& perf_receiv, long& req_count ) const { bool successful = true; @@ -1881,12 +1935,11 @@ const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unord QSqlQuery query = QSqlQuery( db ); int d, h, tt, bs, br, day, hour, week_day, - day_count, hour_count, - max_date_count=0, max_tt=0, tot_tt=0, num_tt=0, max_bs=0, tot_bs=0, num_bs=0, max_br=0, tot_br=0, num_br=0, n_days=0; + unsigned day_count, hour_count, max_date_count=0; QString protocol, method, uri, user_agent, max_date_str=""; std::unordered_map num_day_count = { {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}, {7,0} }; @@ -1905,7 +1958,10 @@ const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unord DialogSec::errDatabaseFailedExecuting( this->db_name, query.lastQuery(), query.lastError().text() ); break; - } else { + } else if ( query.last() ) { + query.first(); + query.previous(); + while ( query.next() ) { try { // day @@ -2044,46 +2100,22 @@ const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unord // process the protocol if ( protocol.size() > 0 ) { - if ( recurs.at(0).find( protocol ) != recurs.at(0).end() ) { - // sum - recurs.at(0).at( protocol ) ++; - } else { - // new - recurs.at(0).emplace( protocol, 1 ); - } + recurs.at( 0 )[ protocol ] ++; } // process the method if ( method.size() > 0 ) { - if ( recurs.at(1).find( method ) != recurs.at(1).end() ) { - // sum - recurs.at(1).at( method ) ++; - } else { - // new - recurs.at(1).emplace( method, 1 ); - } + recurs.at( 1 )[ method ] ++; } // process the uri if ( uri.size() > 0 ) { - if ( recurs.at(2).find( uri ) != recurs.at(2).end() ) { - // sum - recurs.at(2).at( uri ) ++; - } else { - // new - recurs.at(2).emplace( uri, 1 ); - } + recurs.at( 2 )[ uri ] ++; } // process the user-agent if ( user_agent.size() > 0 ) { - if ( recurs.at(3).find( user_agent ) != recurs.at(3).end() ) { - // sum - recurs.at(3).at( user_agent ) ++; - } else { - // new - recurs.at(3).emplace( user_agent, 1 ); - } + recurs.at( 3 )[ user_agent ] ++; } } } diff --git a/logdoctor/modules/crapview/modules/query.h b/logdoctor/modules/crapview/modules/query.h index 34704a7f..c619fb1a 100644 --- a/logdoctor/modules/crapview/modules/query.h +++ b/logdoctor/modules/crapview/modules/query.h @@ -6,6 +6,7 @@ #include +#include #include #include @@ -60,7 +61,7 @@ public: \return The number of months in the period \throw DateTimeException */ - const int getMonthsCount( + const int countMonths( const QString& from_year, const QString& from_month, const QString& to_year, @@ -237,8 +238,8 @@ public: */ const bool getGlobalCounts( const QString& web_server, - const std::unordered_map>>& dates, - std::vector>& recurs, + const std::map>>& dates, + std::vector>& recurs, std::tuple& traf_date, std::unordered_map& traf_day, std::unordered_map& traf_hour, @@ -320,6 +321,20 @@ private: const int getMonthNumber( const QString& month_str ) const; + //! Returns the number of days in a given period + /*! + \param from_year The initial year + \param from_month The initial month + \param from_day The initial day + \param to_year The final Year + \param to_month The final month + \param to_day The final day + \return The number of days + \throw DateTimeException + */ + const int countDays( const int from_year, const int from_month, const int from_day, const int to_year, const int to_month, const int to_day ) const; + + //! Returns the number of months in a given period /*! \param from_year The initial year @@ -328,7 +343,7 @@ private: \param to_month The final month \return The number of months in the period */ - const int getMonthsCount( + const int countMonths( const int& from_year, const int& from_month, const int& to_year, const int& to_month ) const; From a2d6aa827cc0ecbccd647accbc4a7371345e8964 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:27:25 +0100 Subject: [PATCH 22/36] Improvements and updates Code and performances improvements. Updated queries' data types. Removed printable stuff methods. Improved Counts statistics' chart. --- logdoctor/modules/crapview/crapview.cpp | 223 +++++++++--------------- logdoctor/modules/crapview/crapview.h | 52 +----- 2 files changed, 87 insertions(+), 188 deletions(-) diff --git a/logdoctor/modules/crapview/crapview.cpp b/logdoctor/modules/crapview/crapview.cpp index ede95287..0e4f5497 100644 --- a/logdoctor/modules/crapview/crapview.cpp +++ b/logdoctor/modules/crapview/crapview.cpp @@ -1,6 +1,7 @@ #include "crapview.h" +#include "utilities/printables.h" #include "utilities/strings.h" #include @@ -28,77 +29,6 @@ void Crapview::setDbPath( const std::string& path ) } -const QString Crapview::printableDate( const QString& year, const int month, const QString& day ) const -{ - QString date = QString("%1-").arg( year ); - if ( month < 10 ) { - date += QString("0%1-").arg( month ); - } else { - date += QString("%1-").arg( month ); - } - if ( day.size() < 2 ) { - date += QString("0%1").arg( day ); - } else { - date += day; - } - return date; -} - - -const QString Crapview::printableDate( const int year, const int month, const int day ) const -{ - QString date; - if ( year < 10 ) { - date += QString("0%1-").arg( year ); - } else { - date += QString("%1-").arg( year ); - } - if ( month < 10 ) { - date += QString("0%1-").arg( month ); - } else { - date += QString("%1-").arg( month ); - } - if ( day < 10 ) { - date += QString("0%1").arg( day ); - } else { - date += QString("%1").arg( day ); - } - return date; -} - - -const QString Crapview::printableTime( const int hour, const int minute, const int second ) const -{ - QString time; - if ( hour < 10 ) { - time += QString("0%1:").arg( hour ); - } else { - time += QString("%1:").arg( hour ); - } - if ( minute < 10 ) { - time += QString("0%1:").arg( minute ); - } else { - time += QString("%1:").arg( minute ); - } - if ( second < 10 ) { - time += QString("0%1").arg( second ); - } else { - time += QString("%1").arg( second ); - } - return time; -} - - -const QString Crapview::printableWarn( const int value ) const -{ - if ( value == 0 ) { - return TR::tr( BOOLS__FALSE.c_str() ); - } else { - return TR::tr( BOOLS__TRUE.c_str() ); - } -} - - const QString Crapview::parseBooleanFilter( const QString& filter_str ) const { QString aux = filter_str; @@ -174,21 +104,6 @@ const QString Crapview::parseTextualFilter( const QString& filter_str ) const } -void Crapview::refreshDates() -{ - Result result; - this->dbQuery.refreshDates( result ); - if ( result ) { - this->dates.clear(); - // std::unordered_map>>> - // { web_server_id : { year : { month : [ days ] } } } - this->dates = std::move( result.getData() ); - } -} -void Crapview::clearDates() -{ - this->dates.clear(); -} const QString Crapview::getLogFieldString ( const int field_id ) const { @@ -221,6 +136,21 @@ const int Crapview::getMonthNumber( const QString& month_str ) const } +void Crapview::refreshDates() +{ + Result result; + this->dbQuery.refreshDates( result ); + if ( result ) { + this->dates.clear(); + // std::unordered_map>>> + // { web_server_id : { year : { month : [ days ] } } } + this->dates = std::move( result.getData() ); + } +} +void Crapview::clearDates() +{ + this->dates.clear(); +} const QStringList Crapview::getYears( const QString& web_server ) const { @@ -229,7 +159,7 @@ const QStringList Crapview::getYears( const QString& web_server ) const const int ws = this->WebServer_s2i.value( web_server ); if ( this->dates.at( ws ).size() > 0 ) { for ( const auto& [year, data] : this->dates.at( ws ) ) { - years.push_back( QString::fromStdString( std::to_string( year ) ) ); + years.push_back( QString::number( year ) ); } } } @@ -261,9 +191,10 @@ const QStringList Crapview::getDays( const QString& web_server, const QString& y if ( this->dates.at( ws ).at( y ).size() ) { const int m = this->getMonthNumber( month ); if ( this->dates.at( ws ).at( y ).at( m ).size() > 0 ) { - for ( const int day : this->dates.at( ws ).at( y ).at( m ) ) { - days.push_back( QString::fromStdString( std::to_string( day ) ) ); - } + const auto& d = this->dates.at( ws ).at( y ).at( m ); + std::transform( d.cbegin(), d.cend(), + std::back_inserter( days ), + [](int day){ return QString::number( day ); } ); } } } @@ -288,6 +219,13 @@ const QStringList Crapview::getFields( const std::string& tab ) const //////////////// //// CHARTS //// //////////////// +void Crapview::sliceClicked( QtCharts::QPieSlice* slice ) +{ + slice->setExploded( !slice->isExploded() ); + slice->setLabelVisible( !slice->isLabelVisible() ); +} + + void Crapview::updateWarn( QTableWidget* table , const QString& web_server ) const { std::vector> updates; // { (rowid, warn) } @@ -337,15 +275,15 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const norm_count = warn_count = 0; for ( const std::vector& line : data ) { table->insertRow( n_rows ); - table->setItem( n_rows, 0, new QTableWidgetItem( this->printableWarn( line.at( 0 ).toInt() ))); + table->setItem( n_rows, 0, new QTableWidgetItem( PrintSec::printableBool( line.at( 0 ).toInt() ))); if ( line.at( 0 ).toInt() != 0 ) { table->item( n_rows, 0 )->setForeground( warn_col ); table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Checked ); } else { table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Unchecked ); } - table->setItem( n_rows, 1, new QTableWidgetItem( this->printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); - table->setItem( n_rows, 2, new QTableWidgetItem( this->printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); + table->setItem( n_rows, 1, new QTableWidgetItem( PrintSec::printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); + table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); int col = 3; for ( int i=7; iprintableDate( year, this->getMonthNumber( month ), day ); + date = PrintSec::printableDate( year, this->getMonthNumber( month ), day ); } else { // 1 hour for ( int i=0; i<10; i++ ) { @@ -388,15 +326,15 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const for ( const std::vector& line : data ) { n_rows = table->rowCount(); table->insertRow( n_rows ); - table->setItem( n_rows, 0, new QTableWidgetItem( this->printableWarn( line.at( 0 ).toInt() ))); + table->setItem( n_rows, 0, new QTableWidgetItem( PrintSec::printableBool( line.at( 0 ).toInt() ))); if ( line.at( 0 ).toInt() != 0 ) { table->item( n_rows, 0 )->setForeground( warn_col ); table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Checked ); } else { table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Unchecked ); } - table->setItem( n_rows, 1, new QTableWidgetItem( this->printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); - table->setItem( n_rows, 2, new QTableWidgetItem( this->printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); + table->setItem( n_rows, 1, new QTableWidgetItem( PrintSec::printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); + table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); for ( int i=7; isetItem( n_rows, i-4, new QTableWidgetItem( line.at( i ) )); } @@ -414,7 +352,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const } } } - date = this->printableDate( year, this->getMonthNumber( month ), day ) + ", h " + hour; + date = PrintSec::printableDate( year, this->getMonthNumber( month ), day ) + ", h " + hour; } table->verticalHeader()->setVisible( false ); @@ -506,7 +444,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons QLineSeries *line = new QLineSeries(); // build the line upon data - int i=0, max_i=items.size(), t=0, aux_t, max_t=0, n_rows=0; + int i=0, max_i=items.size(), value=0, aux_value, max_value=0, n_rows=0; long long time /* xD */, aux_time, count=1; time = std::get<0>(items.at(0)); QDateTime dt; @@ -516,42 +454,33 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons // append a value to the chart aux_time = std::get<0>(item); data = std::get<1>(item); - aux_t = data.at( 0 ).toInt(); + aux_value = data.at( 0 ).toInt(); // append only if the second is different, else sum if ( aux_time > time ) { - t = t/count; - if ( t == 0 ) { - t = 1; - } - line->append( time, t ); - if ( t > max_t ) { - max_t = t; + value = value/count; + line->append( time, value ); + if ( value > max_value ) { + max_value = value; } time = aux_time; - t = aux_t; + value = aux_value; count = 1; if ( i == max_i ) { // final - if ( t == 0 ) { - t = 1; - } - line->append( time, t ); - if ( t > max_t ) { - max_t = t; + line->append( time, value ); + if ( value > max_value ) { + max_value = value; } } } else { count ++; - t += aux_t; + value += aux_value; if ( i == max_i ) { // final - t = t/count; - if ( t == 0 ) { - t = 1; - } - line->append( aux_time, t ); - if ( t > max_t ) { - max_t = t; + value = value/count; + line->append( aux_time, value ); + if ( value > max_value ) { + max_value = value; } } } @@ -559,7 +488,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons if ( data.at(0).size() > 0 || data.at(1).size() > 0 || data.at(2).size() > 0 || data.at(3).size() > 0 || data.at(4).size() > 0 || data.at(5).size() > 0 ) { table->insertRow( n_rows ); auto tt = new QTableWidgetItem(); - tt->setData( Qt::DisplayRole, aux_t ); + tt->setData( Qt::DisplayRole, aux_value ); table->setItem( n_rows, 0, tt ); table->setItem( n_rows, 1, new QTableWidgetItem( data.at(1) )); table->setItem( n_rows, 2, new QTableWidgetItem( data.at(2) )); @@ -613,7 +542,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons axisX->setLabelsFont( fonts.at( "main_small" ) ); axisX->setFormat( "hh:mm" ); axisX->setTickCount( 25 ); - axisX->setTitleText( this->printableDate( year, this->getMonthNumber(month), day ) ); + axisX->setTitleText( PrintSec::printableDate( year, this->getMonthNumber(month), day ) ); axisX->setTitleFont( fonts.at( "main_small" ) ); l_chart->addAxis( axisX, Qt::AlignBottom ); line->attachAxis( axisX ); @@ -621,11 +550,12 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons // set-up the count values axis (Y) QValueAxis *axisY = new QValueAxis(); axisY->setLabelFormat( "%d" ); - axisY->setTickCount( ( max_t < 8 ) ? max_t : 8 ); - if ( max_t == 1 ) { - max_t = 0; + axisY->setTickCount( ( max_value < 8 ) ? max_value : 8 ); + axisY->setMinorTickCount( 4 ); + if ( max_value == 1 ) { + max_value = 0; } - axisY->setRange( 0, max_t ); + axisY->setRange( 0, max_value ); axisY->setLabelsFont( fonts.at( "main_small" ) ); l_chart->addAxis( axisY, Qt::AlignLeft ); line->attachAxis( axisY) ; @@ -657,10 +587,13 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons const int max_items=15; int count, oth_count=0, n_rows=0; QString item; - for ( int i=0; i( items.at(i) ); - count = std::get<1>( items.at(i) ); - if ( i >= max_items ) { + // bring items in reverse order + stats_count_items_t::const_reverse_iterator iter = items.rbegin(); + while ( iter != items.rend() ) { + item = iter->second; + count = iter->first; + ++iter; + if ( n_rows >= max_items ) { oth_count += count; } else { pie->append( item, count ); @@ -669,7 +602,7 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons auto ic = new QTableWidgetItem(); ic->setData( Qt::DisplayRole, count ); table->setItem( n_rows, 0, ic ); - table->setItem( n_rows, 1, new QTableWidgetItem( std::get<0>( items.at(i) ) )); + table->setItem( n_rows, 1, new QTableWidgetItem( item )); n_rows ++; } table->verticalHeader()->setVisible( false ); @@ -679,7 +612,9 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons QPieSlice *slice = pie->slices().at( pie->count()-1 ); slice->setBrush( Qt::gray ); } - pie->setLabelsVisible(); + pie->setPieSize( 0.65 ); + pie->setLabelsVisible( false ); + connect( pie, &QPieSeries::clicked, this, &Crapview::sliceClicked ); QChart *p_chart = new QChart(); p_chart->setTheme( theme ); @@ -718,13 +653,13 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t b_20->setColor( col ); QBarSet *b_30 = new QBarSet( "" ); if ( to_year.size() == 0 || to_month.size() == 0 || to_day.size() == 0 ) { - date = this->printableDate( from_year, this->getMonthNumber(from_month), from_day ); + date = PrintSec::printableDate( from_year, this->getMonthNumber(from_month), from_day ); } else { date = QString("%1 %2 %3 %4") .arg( TR::tr( "from" ), - this->printableDate( from_year, this->getMonthNumber(from_month), from_day ), + PrintSec::printableDate( from_year, this->getMonthNumber(from_month), from_day ), TR::tr( "to" ), - this->printableDate( to_year, this->getMonthNumber(to_month), to_day ) ); + PrintSec::printableDate( to_year, this->getMonthNumber(to_month), to_day ) ); } b_30->setColor( col ); QBarSet *b_40 = new QBarSet( "" ); @@ -865,13 +800,13 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& QString date; QAreaSeries *area = new QAreaSeries( line ); if ( ! period ) { - date = this->printableDate( from_year, this->getMonthNumber(from_month), from_day ); + date = PrintSec::printableDate( from_year, this->getMonthNumber(from_month), from_day ); } else { date = QString("%1 %2 %3 %4") .arg( TR::tr( "from" ), - this->printableDate( from_year, this->getMonthNumber(from_month), from_day ), + PrintSec::printableDate( from_year, this->getMonthNumber(from_month), from_day ), TR::tr( "to" ), - this->printableDate( to_year, this->getMonthNumber(to_month), to_day )); + PrintSec::printableDate( to_year, this->getMonthNumber(to_month), to_day )); } // color the area @@ -909,7 +844,7 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme& if ( period ) { //axisX->setLabelsVisible( false ); axisX->setFormat( "yyyy-MM" ); - int ticks = this->dbQuery.getMonthsCount( from_year, from_month, to_year, to_month ); + int ticks = this->dbQuery.countMonths( from_year, from_month, to_year, to_month ); if ( ticks == 1 ) { axisX->setFormat( "yyyy-MM-dd" ); ticks = to_day.toInt() - from_day.toInt() +2; @@ -948,7 +883,7 @@ const bool Crapview::calcGlobals( std::vector>& recu if ( this->dates.at( this->WebServer_s2i.value( web_server ) ).size() > 0 ) { // { { item, count } } // 0:protocol, 1:method, 1:uri, 3:user-agent - std::vector> recurs = { {}, {}, {}, {} }; + std::vector> recurs = { {}, {}, {}, {} }; // ( date_str, count ) std::tuple traf_date; // { day_name : total_count } @@ -978,8 +913,8 @@ const bool Crapview::calcGlobals( std::vector>& recu // max request elements for ( int i=0; i<4; i++ ) { - int max=0; - QString max_str=""; + unsigned max=0; + QString max_str="-"; const auto& aux = recurs.at( i ); for ( const auto& [s,c] : aux ) { if ( c > max ) { diff --git a/logdoctor/modules/crapview/crapview.h b/logdoctor/modules/crapview/crapview.h index bf56be11..a856504a 100644 --- a/logdoctor/modules/crapview/crapview.h +++ b/logdoctor/modules/crapview/crapview.h @@ -14,8 +14,10 @@ /*! Performs operations related to the visualization of the statistics */ -class Crapview +class Crapview : public QObject { + Q_OBJECT + public: explicit Crapview(); @@ -284,6 +286,11 @@ public: ) const; +private slots: + + void sliceClicked( QtCharts::QPieSlice* slice ); + + private: // quantity of information to display throught dialogs @@ -309,49 +316,6 @@ private: }; - //! Returns a string of the given date in the format YYYY-MM-DD - /*! - \overload const QString printableDate(const int& year, const int& month, const int& day) - \param year The year - \param month The month - \param day The day - \return The printable date - */ - const QString printableDate( - const QString& year, const int month, const QString& day - ) const; - - //! Returns a string of the given date in the format YYYY-MM-DD - /*! - \param year The year - \param month The month - \param day The day - \return The printable date - */ - const QString printableDate( - const int year, const int month, const int day - ) const; - - //! Returns a string of the given time in the format HH:MM:SS - /*! - \param hour The hour - \param minut The minute - \param second The second - \return The printable time - */ - const QString printableTime( - const int hour, const int minute, const int second - ) const; - - //! Returns a string corresponding to the given value - /*! - Used to convert numeric booleans [0,1] to string [FALSE,TRUE] - \param value The value to convert - \return The corresponding printable string - */ - const QString printableWarn( const int value ) const; - - // converr Web Servers names to Web Server IDs const QHash WebServer_s2i = { {"apache",11}, {"nginx",12}, {"iis",13} }; From ad77b21379b635814e6500011adb67a7e77c2896 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:29:53 +0100 Subject: [PATCH 23/36] Introduced Craplog's worker Worker to parse logs in a QThread --- logdoctor/modules/craplog/modules/worker.cpp | 832 +++++++++++++++++++ logdoctor/modules/craplog/modules/worker.h | 200 +++++ 2 files changed, 1032 insertions(+) create mode 100644 logdoctor/modules/craplog/modules/worker.cpp create mode 100644 logdoctor/modules/craplog/modules/worker.h diff --git a/logdoctor/modules/craplog/modules/worker.cpp b/logdoctor/modules/craplog/modules/worker.cpp new file mode 100644 index 00000000..0256aa41 --- /dev/null +++ b/logdoctor/modules/craplog/modules/worker.cpp @@ -0,0 +1,832 @@ + +#include "worker.h" + +#include "utilities/gzip.h" +#include "utilities/io.h" +#include "utilities/strings.h" + +#include "modules/dialogs.h" +#include "modules/exceptions.h" + +#include "modules/craplog/modules/datetime.h" + + +CraplogWorker::CraplogWorker( const unsigned web_server_id, const unsigned dialogs_level, const std::string& db_data_path, const std::string& db_hashes_path, const FormatOps::LogsFormat& logs_format, const bw_lists_t& blacklists, const bw_lists_t& warnlists, const worker_files_t& log_files, QObject* parent ) + : QObject{parent} +{ + this->wsID = web_server_id; + this->dialogs_level = dialogs_level; + this->db_data_path = db_data_path; + this->db_hashes_path = db_hashes_path; + this->logs_format = logs_format; + this->blacklists = blacklists; + this->warnlists = warnlists; + this->files_to_use = log_files; +} + + +void CraplogWorker::sendPerfData() +{ + emit this->perfData( + this->parsed_size, + this->parsed_lines + ); +} + +void CraplogWorker::sendChartData() +{ + emit this->chartData( + this->total_size, + this->total_lines, + this->warnlisted_size, + this->blacklisted_size + ); +} + + +void CraplogWorker::work() +{ + this->proceed |= true; + this->db_edited &= false; + try { + if ( this->proceed ) { + // collect log lines + this->joinLogLines(); + } + if ( this->proceed ) { + // parse the log lines to fill the collection + emit this->startedParsing(); + this->parseLogLines(); + emit this->finishedParsing(); + } + // clear log lines data + this->logs_lines.clear(); + + if ( this->proceed && this->parsed_size > 0 ) { + // store the new data + this->storeLogLines(); + this->db_edited |= this->proceed; + } + + } catch ( GenericException& e ) { + DialogSec::errGeneric( e.what() ); + this->proceed &= false; + + } catch ( LogParserException& e ) { + DialogSec::errFailedParsingLogs( e.what() ); + this->proceed &= false; + } + // send the final data + if ( ! this->proceed ) { + this->total_lines = 0; + this->parsed_lines = 0; + this->total_size = 0; + this->parsed_size = 0; + this->warnlisted_size = 0; + this->blacklisted_size = 0; + } + this->sendPerfData(); + this->sendChartData(); + emit this->done( this->db_edited ); + emit this->retire(); +} + + +void CraplogWorker::joinLogLines() +{ + std::function&)> + cleanLines = [&](std::vector& lines) { + std::vector aux; + for ( const std::string& line : lines ) { + if ( !StringOps::startsWith( line, "#" ) ) { + // not a commented line + aux.push_back( line ); + } + } + lines = std::move( aux ); + }; + + + std::string aux; + std::vector content; + for ( auto file : this->files_to_use ) { + + if ( ! this->proceed ) { break; } + + const std::string& file_path = std::get<0>( file ); + + // collect lines + try { + // try reading + content.clear(); + aux.clear(); + try { + // try as gzip compressed archive first + GZutils::readFile( file_path, aux ); + + } catch ( const GenericException& ) { + // failed closing file pointer + throw; + + } catch (...) { + // fallback on reading as normal file + if ( aux.size() > 0 ) { + aux.clear(); + } + IOutils::readFile( file_path, aux ); + } + StringOps::splitrip( content, aux ); + + this->total_lines += content.size(); + this->total_size += aux.size(); + + if ( this->wsID == this->IIS_ID ) { + cleanLines( content ); + } + + // re-catched in run() + } catch ( const GenericException& ) { + // failed closing gzip file pointer + throw GenericException( QString("%1:\n%2").arg( + DialogSec::tr("An error accured while reading the gzipped file"), + QString::fromStdString( file_path ) + ).toStdString() ); + + } catch ( const std::ios_base::failure& ) { + // failed reading as text + throw GenericException( QString("%1:\n%2").arg( + DialogSec::tr("An error accured while reading the file"), + QString::fromStdString( file_path ) + ).toStdString() ); + + } catch (...) { + // failed somehow + throw GenericException( QString("%1:\n%2").arg( + DialogSec::tr("Something failed while handling the file"), + QString::fromStdString( file_path ) + ).toStdString() ); + } + + // append to the relative list + this->logs_lines.insert( this->logs_lines.end(), content.begin(), content.end() ); + } + this->files_to_use.clear(); + if ( this->logs_lines.size() == 0 ) { + this->proceed &= false; + } +} + + +void CraplogWorker::parseLogLines() +{ + const std::function + parseLine = [&]( const std::string& line ) { + log_line_data_t data; + std::string sep, fld, fld_str; + bool add_pm=false, ok=true; + size_t start, stop=0, aux_start, aux_stop, + line_size = line.size()-1; + int i=0, n_sep=this->logs_format.separators.size()-1; + + // add the initial chars + stop = this->logs_format.initial.size(); + + while (true) { + // split fields + start = stop; // stop updated at the end of the loop + if ( i <= n_sep ) { + sep = this->logs_format.separators.at( i ); + stop = line.find( sep, start ); + } else if ( i == n_sep+1 ) { + // final separator + sep = this->logs_format.final; + if ( sep == "" ) { + stop = line_size+1; + } else { + stop = line.find( sep, start ); + if ( stop == std::string::npos ) { + stop = line_size +1; + } + } + } else { + // no more separators + break; + } + if ( stop == std::string::npos ) { + // separator not found, abort + throw LogParserException( "Separator not found", sep ); + } + + // get the field + fld = this->logs_format.fields.at( i ); + if ( fld != "NONE" ) { + // only parse the considered fields + fld_str = StringOps::strip( line.substr(start, stop-start), " " ); + + if ( i+1 <= n_sep ) { + // not the last separator, check for mistakes + ok |= true; + aux_stop = stop; + + if ( sep == " " ) { + // whitespace-separated-values fields + int c = StringOps::count( fld_str, sep ), + n = 0; + if ( fld == "request_full" ) { + n = 2; + } else if ( fld == "date_time_mcs" ) { + n = 4; + } else if ( fld == "date_time_ncsa" ) { + n = 1; + } else if ( fld == "date_time_gmt" ) { + n = 3; + } + if ( n > 0 && c < n ) { + // loop until the correct number of whitespaces is reached + aux_start = stop + 1; + while ( c < n ) { + aux_stop = line.find( sep, aux_start ); + if ( aux_stop == std::string::npos ) { + // not found + ok &= false; + break; + } + aux_start = aux_stop + 1; + c++; + } + } + + } else if ( fld == "user_agent" && StringOps::startsWith( sep, "\"" ) ) { + // atm the only support is for escaped quotes + if ( fld_str.back() == '\\' ) { + aux_start = stop + sep.size(); + while (true) { + aux_stop = line.find( sep, aux_start ); + if ( aux_stop == std::string::npos ) { + // not found + break; + } else if ( line.at( aux_stop-1 ) != '\\' ) { + // non-backslashed quotes + break; + } + aux_start = aux_stop + sep.size(); + } + } + } + + // finally update if needed + if ( ok && aux_stop >= stop ) { + stop = aux_stop; + fld_str = StringOps::strip( line.substr(start, stop-start), " " ); + } + } + + if ( fld_str.size() > 0 ) { + // process the field + int fld_id = this->field2id.at(fld); + if ( fld_id > 0 ) { + // no need to process, append directly if non-empty + if ( fld_id == 13 && fld_str == "-" ) { + continue; + } + data.emplace( fld_id, fld_str ); + + } else { + // process the field + + // process the date to get year, month, day, hour and minute + if ( StringOps::startsWith( fld, "date_time" ) ) { + const std::vector dt = DateTimeOps::processDateTime( fld_str, fld.substr( 10 ) ); // cut away the "date_time_" part which is useless from now on + if ( dt.at( 0 ) != "" ) { + // year + data.emplace( this->field2id.at("date_time_year"), dt.at( 0 ) ); + } + if ( dt.at( 1 ) != "" ) { + // month + data.emplace( this->field2id.at("date_time_month"), dt.at( 1 ) ); + } + if ( dt.at( 2 ) != "" ) { + // day + data.emplace( this->field2id.at("date_time_day"), dt.at( 2 ) ); + } + if ( dt.at( 3 ) != "" ) { + // hour + if ( dt.at( 3 ) == "PM" ) { + add_pm |= true; + } else { + data.emplace( this->field2id.at("date_time_hour"), dt.at( 3 ) ); + } + } + if ( dt.at( 4 ) != "" ) { + // minute + data.emplace( this->field2id.at("date_time_minute"), dt.at( 4 ) ); + } + if ( dt.at( 5 ) != "" ) { + // second + data.emplace( this->field2id.at("date_time_second"), dt.at( 5 ) ); + } + + + // process the request to get the protocol, method, resource and query + } else if ( fld == "request_full" ) { + size_t aux; + std::string aux_fld, protocol="", method="", uri="", query=""; + aux_fld = fld_str; + // method + aux = aux_fld.find( ' ' ); + if ( aux != std::string::npos ) { + method = aux_fld.substr( 0, aux ); + aux_fld = StringOps::lstrip( aux_fld.substr( aux ) ); + + // page & query + aux = aux_fld.find( ' ' ); + if ( aux != std::string::npos ) { + std::string aux_str = aux_fld.substr( 0, aux ); + // search for the query + int aux_ = aux_str.find( '?' ); + if ( aux_ != std::string::npos ) { + uri = aux_str.substr( 0, aux_ ); + query = aux_str.substr( aux_+1 ); + } else { + // query not found + uri = aux_str; + } + aux_fld = StringOps::lstrip( aux_fld.substr( aux ) ); + + // protocol + protocol = aux_fld; + } + } + // append non-empty data + if ( protocol != "" ) { + data.emplace( this->field2id.at("request_protocol"), protocol ); + } + if ( method != "" ) { + data.emplace( this->field2id.at("request_method"), method ); + } + if ( uri != "" ) { + data.emplace( this->field2id.at("request_uri"), uri ); + } + if ( query != "" ) { + data.emplace( this->field2id.at("request_query"), query ); + } + + + + // process the request to get uri and query + } else if ( fld == "request_uri_query" ) { + // search for the query + std::string uri, query; + size_t aux_ = fld_str.find( '?' ); + if ( aux_ != std::string::npos ) { + uri = fld_str.substr( 0, aux_ ); + query = fld_str.substr( aux_+1 ); + } else { + // query not found + uri = fld_str; + } + if ( uri != "" ) { + data.emplace( this->field2id.at("request_uri"), uri ); + } + if ( query != "" ) { + data.emplace( this->field2id.at("request_query"), query ); + } + + + + // process the time taken to convert to milliseconds + } else if ( StringOps::startsWith( fld, "time_taken_" ) ) { + float t = std::stof( fld_str ); + fld = fld.substr( 11 ); + if ( fld == "us" ) { + // from microseconds + t /= 1000; + } else if ( fld == "s" || fld == "s.ms" ) { + // from seconds + t *= 1000; + } + data.emplace( this->field2id.at("time_taken"), std::to_string( (int)t ) ); + + + // something went wrong + } else { + // hmmm.. no... + throw LogParserException( "Unexpected LogField", fld ); + } + } + } + } + + // update the stop for the next start + stop += sep.size(); + i++; + if ( stop > line_size ) { + // this was the final separator + break; + } + + } + + if ( add_pm ) { + try { + // add +12 hours for PM + data.at( 4 ) = std::to_string( 12 + std::stoi(data.at( 4 )) ); + } catch (...) { + // no hour data + } + } + + // set the default warning mark ( 0=false ) to default status + data.emplace( 99, "0" ); + { + std::unique_lock lock( this->mutex ); + this->parsed_size += line_size; + this->parsed_lines ++; + } + this->data_collection.push_back( data ); + this->sendPerfData(); + }; + + + // parse all the lines + if ( this->proceed ) { + const unsigned n_lines = this->logs_lines.size(); + const unsigned nl = this->logs_format.new_lines; + if ( nl == 0 ) { + this->data_collection.reserve( n_lines ); + for ( const std::string& line : this->logs_lines ) { + parseLine( line ); + } + } else { + this->data_collection.reserve( n_lines / (nl+1) ); + for ( int i=0; ilogs_lines.at( i ); + for ( int n=0; nlogs_lines.at( i ); + } + parseLine( line ); + } + } + } +} + + + +void CraplogWorker::storeLogLines() +{ + QString db_path = QString::fromStdString( this->db_data_path ); + QString db_name = QString::fromStdString( this->db_data_path.substr( this->db_data_path.find_last_of( '/' ) + 1 ) ); + + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); + db.setDatabaseName( db_path ); + + if ( ! db.open() ) { + // error opening database + this->proceed &= false; + QString err_msg = ""; + if ( this->dialogs_level == 2 ) { + err_msg = db.lastError().text(); + } + DialogSec::errDatabaseFailedOpening( db_name, err_msg ); + + } else { + + try { + // ACID transaction + if ( ! db.transaction() ) { + // error opening database + this->proceed &= false; + QString stmt_msg="", err_msg = ""; + if ( this->dialogs_level > 0 ) { + stmt_msg = "db.transaction()"; + if ( this->dialogs_level == 2 ) { + err_msg = db.lastError().text(); + } + } + DialogSec::errDatabaseFailedExecuting( db_name, stmt_msg, err_msg ); + } + + if ( this->proceed && this->data_collection.size() > 0 ) { + this->proceed &= this->storeData( db ); + } + + if ( this->proceed ) { + // commit the transaction + if ( ! db.commit() ) { + // error opening database + this->proceed &= false; + QString stmt_msg="", err_msg = ""; + if ( this->dialogs_level > 0 ) { + stmt_msg = "db.commit()"; + if ( this->dialogs_level == 2 ) { + err_msg= db.lastError().text(); + } + } + DialogSec::errDatabaseFailedExecuting( db_name, stmt_msg, err_msg ); + } + } + if ( ! proceed ) { + // rollback + throw (std::exception()); + } + + } catch (...) { + // wrongthing w3nt some.,. + this->proceed &= false; + bool err_shown = false; + // rollback the transaction + if ( ! db.rollback() ) { + // error rolling back commits + QString stmt_msg="", err_msg = ""; + if ( this->dialogs_level > 0 ) { + stmt_msg = "db.rollback()"; + if ( this->dialogs_level == 2 ) { + err_msg = db.lastError().text(); + } + } + DialogSec::errDatabaseFailedExecuting( db_name, stmt_msg, err_msg ); + err_shown = true; + } + if ( ! err_shown ) { + // show a message + DialogSec::errGeneric( QString("%1\n\n%2").arg( + DialogSec::tr("An error occured while working on the database"), + DialogSec::tr("Aborting") ) ); + } + } + + db.close(); + } + +} + +const bool CraplogWorker::storeData( QSqlDatabase& db ) +{ + bool successful = true; + + const QString db_name = QString::fromStdString( + this->db_data_path.substr( + this->db_data_path.find_last_of( '/' ) + 1 ) ); + + // get blacklist/warnlist items + bool check_bl_cli, + check_wl_cli, check_wl_ua, check_wl_met, check_wl_req; + check_bl_cli = this->blacklists.at( 20 ).used; + check_wl_met = this->warnlists.at( 11 ).used; + check_wl_req = this->warnlists.at( 12 ).used; + check_wl_cli = this->warnlists.at( 20 ).used; + check_wl_ua = this->warnlists.at( 21 ).used; + + const std::vector empty; + const std::vector& bl_cli_list = (check_bl_cli) + ? this->blacklists.at( 20 ).list + : empty; + + const std::vector& wl_met_list = (check_wl_met) + ? this->warnlists.at( 11 ).list + : empty; + + const std::vector& wl_req_list = (check_wl_req) + ? this->warnlists.at( 12 ).list + : empty; + + const std::vector& wl_cli_list = (check_wl_cli) + ? this->warnlists.at( 20 ).list + : empty; + + const std::vector& wl_ua_list = (check_wl_ua) + ? this->warnlists.at( 21 ).list + : empty; + + // prepare the database related studd + QString table; + switch ( this->wsID ) { + case 11: + table = "apache"; + break; + case 12: + table = "nginx"; + break; + case 13: + table = "iis"; + break; + default: + // wrong WebServerID, but should be unreachable because of the previous operations + throw WebServerException( "Unexpected WebServerID: " + std::to_string(this->wsID) ); + } + + + /*int perf_size;*/ + bool skip = false, + warning = false; + QSqlQuery query = QSqlQuery( db ); + // parse every row of data + for ( const std::unordered_map& row : this->data_collection ) { + // break if failed + if ( ! successful ) { break; } + + // check blacklisted clients + if ( check_bl_cli ) { + if ( row.find( 20 ) != row.end() ) { + // this row do contains this row item, check if they match + const std::string& target = row.at( 20 ); + for ( const auto& item : bl_cli_list ) { + if ( StringOps::startsWith( target, item ) ) { + // match found! skip this line + skip |= true; + break; + } + } + } + } + if ( skip ) { + // append every field to ignored size + for ( const auto& [ id, str ] : row ) { + this->blacklisted_size += str.size(); + } + skip &= false; + continue; + } + + // check warnlisted clients + if ( check_wl_cli ) { + if ( row.find( 20 ) != row.end() ) { + // this row do contains this row item, check if they match + const std::string& target = row.at( 20 ); + for ( const auto& item : wl_cli_list ) { + if ( StringOps::startsWith( target, item ) ) { + // match found! put a warning on this line + warning |= true; + this->warnlisted_size += item.size(); + break; + } + } + } + } + // check warnlisted user-agents + if ( check_wl_ua && !warning ) { + if ( row.find( 21 ) != row.end() ) { + // this row do contains this row item, check if they match + const std::string& target = row.at( 21 ); + for ( const auto& item : wl_ua_list ) { + if ( StringOps::startsWith( target, item ) ) { + // match found! skip this line + warning |= true; + this->warnlisted_size += item.size(); + break; + } + } + } + } + // check warnlisted methods + if ( check_wl_met && !warning ) { + if ( row.find( 11 ) != row.end() ) { + // this row do contains this row item, check if they match + const std::string& target = row.at( 11 ); + for ( const auto& item : wl_met_list ) { + if ( item == target ) { + // match found! skip this line + warning |= true; + this->warnlisted_size += item.size(); + break; + } + } + } + } + // check warnlisted requests URIs + if ( check_wl_req && !warning ) { + if ( row.find( 12 ) != row.end() ) { + // this row do contains this row item, check if they match + const std::string& target = row.at( 12 ); + for ( const auto& item : wl_req_list ) { + if ( StringOps::startsWith( target, item ) ) { + // match found! skip this line + warning |= true; + this->warnlisted_size += item.size(); + break; + } + } + } + } + + + // initialize the SQL statement + QString query_stmt; + query_stmt = "INSERT INTO \""+table+"\" (\"warning\", \"year\", \"month\", \"day\", \"hour\", \"minute\", \"second\", \"protocol\", \"method\", \"uri\", \"query\", \"response\", \"time_taken\", \"bytes_sent\", \"bytes_received\", \"referrer\", \"client\", \"user_agent\", \"cookie\") "\ + "VALUES ("; + + + // complete and execute the statement, binding NULL if not found + /*perf_size = 0;*/ + + // warning + if ( row.find( 99 ) == row.end() ) { + // no value found in the collection, bind NULL + query_stmt += "0"; + } else { + // value found, bind it + /*perf_size ++;*/ + if ( warning ) { + query_stmt += "1"; + warning &= false; + } else { + query_stmt += "0"; + } + } + + // date and time + for ( int i=1; i<7; i++ ) { + query_stmt += ", "; + if ( row.find( i ) == row.end() ) { + // no value found in the collection, bind NULL + query_stmt += "NULL"; + } else { + // value found, bind it + /*perf_size += row.at( i ).size();*/ + query_stmt += QString::fromStdString( row.at( i ) ).replace("'","''"); + } + } + + // request + for ( int i=10; i<14; i++ ) { + query_stmt += ", "; + if ( row.find( i ) == row.end() ) { + // no value found in the collection, bind NULL + query_stmt += "NULL"; + } else { + // value found, bind it + /*perf_size += row.at( i ).size();*/ + query_stmt += QString("'%1'").arg( QString::fromStdString( row.at( i ) ).replace("'","''") ); + } + } + + for ( int i=14; i<18; i++ ) { + query_stmt += ", "; + if ( row.find( i ) == row.end() ) { + // no value found in the collection, bind NULL + query_stmt += "NULL"; + } else { + // value found, bind it + /*perf_size += row.at( i ).size();*/ + query_stmt += QString::fromStdString( row.at( i ) ).replace("'","''"); + } + } + + // client data and referrer + for ( int i : std::vector({18,20,21,22}) ) { + query_stmt += ", "; + if ( row.find( i ) == row.end() ) { + // no value found in the collection, bind NULL + query_stmt += "NULL"; + } else { + // value found, bind it + if ( i == 21 && this->wsID == this->IIS_ID ) { + // iis logs the user-agent using '+' instead of ' ' (spaces) + QString str = QString::fromStdString( row.at( i ) ).replace("+"," "); + /*perf_size += str.size();*/ + query_stmt += QString("'%1'").arg( str.replace("'","''") ); + } else { + /*perf_size += row.at( i ).size();*/ + query_stmt += QString("'%1'").arg( QString::fromStdString( row.at( i ) ).replace("'","''") ); + } + } + } + + + // encode the statement + query_stmt += ");"; + if ( ! query.prepare( query_stmt ) ) { + // error opening database + successful &= false; + QString query_msg="", err_msg=""; + if ( this->dialogs_level > 0 ) { + query_msg = "query.prepare()"; + if ( this->dialogs_level == 2 ) { + err_msg = query.lastError().text(); + } + } + DialogSec::errDatabaseFailedExecuting( db_name, query_msg, err_msg ); + } + + // finalize this statement + if ( ! query.exec() ) { + // error finalizing step + successful &= false; + QString query_msg="", err_msg=""; + if ( this->dialogs_level > 0 ) { + query_msg = "query.exec()"; + if ( this->dialogs_level == 2 ) { + err_msg = query.lastError().text(); + } + } + DialogSec::errDatabaseFailedExecuting( db_name, query_msg, err_msg ); + break; + } + + // reset the statement to prepare for the next one + query.finish(); + } + + return successful; +} diff --git a/logdoctor/modules/craplog/modules/worker.h b/logdoctor/modules/craplog/modules/worker.h new file mode 100644 index 00000000..7cedbe83 --- /dev/null +++ b/logdoctor/modules/craplog/modules/worker.h @@ -0,0 +1,200 @@ +#ifndef CRAPLOGWORKER_H +#define CRAPLOGWORKER_H + +#include + +#include "modules/craplog/craplog.h" + + +typedef std::vector> worker_files_t; +typedef std::unordered_map log_line_data_t; +typedef std::unordered_map bw_lists_t; + + +class CraplogWorker : public QObject +{ + Q_OBJECT + +public: + + explicit CraplogWorker( + const unsigned web_server_id, + const unsigned dialogs_level, + const std::string& db_data_path, + const std::string& db_hashes_path, + const FormatOps::LogsFormat& logs_format, + const bw_lists_t& blacklists, + const bw_lists_t& warnlists, + const worker_files_t& log_files, + QObject* parent=nullptr + ); + +signals: + + void perfData( + const unsigned parsed_size, + const unsigned parsed_lines ); + + void chartData( + const unsigned total_size, + const unsigned total_lines, + const unsigned warnlisted_size, + const unsigned blacklisted_size ); + + void startedParsing(); + + void finishedParsing(); + + void done( const bool successful ); + + void retire(); + +public slots: + + void work(); + + void sendPerfData(); + + void sendChartData(); + +private: + + ///////////////////////// + //// WEB SERVERS IDs //// + + const unsigned APACHE_ID = 11; //!< ID of the Apache2 Web Server + const unsigned NGINX_ID = 12; //!< ID of the Nginx Web Server + const unsigned IIS_ID = 13; //!< ID of the IIS Web Server + + unsigned wsID; + + unsigned dialogs_level = 2; + + + ////////////////////////////// + //// BLACKLIST / WARNLIST //// + + // { log_field_id : BWlist } + bw_lists_t blacklists; + bw_lists_t warnlists; + + FormatOps::LogsFormat logs_format; + + std::mutex mutex; + + bool proceed = true; + + bool db_edited = false; + std::string db_data_path; + std::string db_hashes_path; + + // the selected log files to be parsed during the process + worker_files_t files_to_use; + + // the entire stack of lines which have been read from the log files + std::vector logs_lines; + + // collection of logs items, each item results from a log line + /* structure + [ { log_field_id : "data" } ] + + log_field_ids + 99: warning, + 1: year, 2: month, 3: day, 4: hour, 5: minute, 6:second, + 10: request_protocol, 11: request_method, 12: request_uri, 13: request_query, 14: response_code, + 15: time_taken, 16: bytes_sent, 17: bytes_received, 18: referrer, + 20: client, 21: user_agent, 22: cookie + */ + std::vector data_collection; + + //! Reads the selected files and append the resulting lines to the list + /*! + \throw GenericException + */ + void joinLogLines(); + + //! Parses the lines in the list and stores their data in the data collection + /*! + \throw LogParserException + */ + void parseLogLines(); + + //! Handles the process of storing data in the database + /*! + \see storeData() + */ + void storeLogLines(); + + //! Stores the data collection in the logs Collection database + /*! + \param db A database instance, already initizlized + \return Whether the operation has been successful or not + \throw WebServerException + */ + const bool storeData( QSqlDatabase& db ); + + + ////////////////////// + //// PERFORMANCES //// + + unsigned total_lines = 0; + unsigned parsed_lines = 0; + unsigned total_size = 0; + unsigned parsed_size = 0; + unsigned warnlisted_size = 0; + unsigned blacklisted_size = 0; + + + // Map to convert log fields to field IDs + const std::unordered_map field2id = { + // date-time + {"date_time_year", 1}, + {"date_time_month", 2}, + {"date_time_day", 3}, + {"date_time_hour", 4}, + {"date_time_minute", 5}, + {"date_time_second", 6}, + {"date_time_ncsa", 0}, + {"date_time_iso", 0}, + {"date_time_mcs", 0}, + {"date_time_gmt", 0}, + {"date_time_utc_d", 0}, + {"date_time_utc_t", 0}, + {"date_time_epoch_s", 0}, + {"date_time_epoch_s.ms", 0}, + {"date_time_epoch_ms", 0}, + {"date_time_epoch_us", 0}, + {"date_time_YYYYMMDD", 0}, + {"date_time_MMDDYY", 0}, + {"date_time_MDYYYY", 0}, + {"date_time_year_short", 0}, + {"date_time_month_str", 0}, + {"date_time_clock_12", 0}, + {"date_time_clock_24", 0}, + {"date_time_clock_short", 0}, + // request + {"request_protocol", 10}, + {"request_method", 11}, + {"request_uri", 12}, + {"request_query", 13}, + {"response_code", 14}, + {"request_full", 0}, + // performance + {"time_taken_ms", 15}, + {"time_taken_us", 0}, + {"time_taken_s.ms", 0}, + {"time_taken_s", 0}, + {"bytes_sent", 16}, + {"bytes_received", 17}, + // referer + {"referer", 18}, + // client data + {"client", 20}, + {"user_agent", 21}, + {"cookie", 22} + }; + +}; + + +#endif // CRAPLOGWORKER_H From 3ba11c342d9563a175cf5b1fa5ce682d2e2f3b6f Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:34:33 +0100 Subject: [PATCH 24/36] Improvements and updates Code improvements. Introduced signals and slot to synchronize with the worker. Removed stuff which is now done by the worker. --- logdoctor/modules/craplog/craplog.cpp | 542 ++++++++------------------ logdoctor/modules/craplog/craplog.h | 164 +++----- 2 files changed, 207 insertions(+), 499 deletions(-) diff --git a/logdoctor/modules/craplog/craplog.cpp b/logdoctor/modules/craplog/craplog.cpp index dd50edf8..b2ffd2e8 100644 --- a/logdoctor/modules/craplog/craplog.cpp +++ b/logdoctor/modules/craplog/craplog.cpp @@ -4,6 +4,7 @@ #include "utilities/checks.h" #include "utilities/gzip.h" #include "utilities/io.h" +#include "utilities/printables.h" #include "utilities/strings.h" #include "modules/dialogs.h" @@ -11,7 +12,7 @@ #include "modules/shared.h" #include "modules/craplog/modules/donuts.h" -#include "modules/craplog/modules/store.h" +#include "modules/craplog/modules/worker.h" #include #include @@ -27,8 +28,6 @@ Craplog::Craplog() //////////////////////// //// INITIALIZATION //// //////////////////////// - // shared mutex - this->logOps.setMutex( &this->mutex ); // blacklists / whitelists for ( int i=this->APACHE_ID; i<=this->IIS_ID; i++ ) { this->warnlists.emplace( i, std::unordered_map() ); @@ -112,12 +111,12 @@ void Craplog::setHashesDatabasePath( const std::string& path ) this->db_hashes_path = path + "/hashes.db"; } -const long& Craplog::getWarningSize() const +const unsigned& Craplog::getWarningSize() const { return this->warning_size; } -void Craplog::setWarningSize(const long& new_size ) +void Craplog::setWarningSize(const unsigned& new_size ) { this->warning_size = new_size; } @@ -478,7 +477,7 @@ void Craplog::scanLogsDir() successful = false; } if ( successful ) { - int size; + unsigned size; QString name; std::string path; // iterate over entries in the logs folder @@ -486,6 +485,12 @@ void Craplog::scanLogsDir() // get the attributes path = dir_entry.path().string(); name = QString::fromStdString( dir_entry.path().filename().string() ); + + // match only valid files names + if ( ! this->isFileNameValid( name.toStdString() ) ) { + continue; + } + // check if it is actually a file if ( IOutils::checkFile( path ) ) { // it's a file, check the readability @@ -532,11 +537,6 @@ void Craplog::scanLogsDir() continue; } - // match only valid files names - if ( ! this->isFileNameValid( name.toStdString() ) ) { - continue; - } - std::string hash; try { this->hashOps.digestFile( path, hash ); @@ -665,151 +665,21 @@ const bool Craplog::isFileNameValid( const std::string& name ) const /////////////// //// WORKK //// -void Craplog::startWorking() -{ - std::unique_lock lock( this->mutex ); - this->working = true; - this->parsing = true; - this->proceed = true; - - this->perf_size = 0; - this->total_size = 0; - this->parsed_size = 0; - this->warnlisted_size = 0; - this->blacklisted_size = 0; - this->total_lines = 0; - this->parsed_lines = 0; - - this->data_collection.clear(); - this->logs_lines.clear(); - this->used_files_hashes.clear(); -} -void Craplog::stopWorking() -{ - std::unique_lock lock( this->mutex ); - this->working = false; - this->parsing = false; -} -const bool& Craplog::isWorking() -{ - std::unique_lock lock( this->mutex ); - return this->working; -} -const bool& Craplog::isParsing() -{ - std::unique_lock lock( this->mutex ); - return this->parsing; -} -const bool& Craplog::editedDatabase() const -{ - return this->db_edited; -} - -// performances -const unsigned &Craplog::getPerfSize() -{ - std::unique_lock lock( this->mutex ); - return this->perf_size; -} -/*void Craplog::sumPerfSize( const unsigned& size ) -{ - std::unique_lock lock( this->mutex ); - this->perf_size += size; - this->parsed_size += size; -}*/ -const unsigned &Craplog::getTotalSize() -{ - std::unique_lock lock( this->mutex ); - return this->total_size; -} -/*const unsigned &Craplog::getParsedSize() -{ - std::unique_lock lock( this->mutex ); - return this->parsed_size; -}*/ -const unsigned &Craplog::getParsedLines() -{ - std::unique_lock lock( this->mutex ); - return this->parsed_lines; -} - -void Craplog::sumWarningsSize( const unsigned& size ) -{ - this->warnlisted_size += size; -} -void Craplog::sumBlacklistededSize( const unsigned& size ) -{ - this->blacklisted_size += size; -} - -void Craplog::collectPerfData() -{ - std::unique_lock lock( this->mutex ); - this->parsed_size = this->logOps.getParsedSize(); - this->parsed_lines = this->logOps.getParsedLines(); - this->perf_size = this->parsed_size; -} - -void Craplog::clearDataCollection() -{ - this->data_collection.clear(); -} - - -void Craplog::run() -{ - this->startWorking(); - try { - if ( this->proceed ) { - // collect log lines - this->joinLogLines(); - } - if ( this->proceed ) { - // parse the log lines to fill the collection - this->parseLogLines(); - // finished parsing logs - this->parsing = false; - this->total_size = this->logOps.getTotalSize(); - this->parsed_size = this->logOps.getParsedSize(); - this->parsed_lines = this->logOps.getParsedLines(); - this->perf_size = this->parsed_size; - } - // clear log lines data - this->logs_lines.clear(); - - if ( this->proceed ) { - // store the new data - this->storeLogLines(); - } - - if ( this->proceed ) { - // succesfully updated the database - if ( this->parsed_size > 0 ) { - this->db_edited = true; - } - // insert the hashes of the used files - this->hashOps.insertUsedHashes( this->db_hashes_path, this->used_files_hashes, this->current_WS ); - } - this->used_files_hashes.clear(); - - } catch ( GenericException& e ) { - DialogSec::errGeneric( e.what() ); - this->proceed = false; - - } catch ( LogParserException& e ) { - DialogSec::errFailedParsingLogs( e.what() ); - this->proceed = false; - } - - this->stopWorking(); -} - - - const bool Craplog::checkStuff() { this->proceed = true; - this->log_files_to_use.clear(); + { + size_t l_size = this->logs_list.size(); + this->log_files_to_use.clear(); + if ( this->log_files_to_use.capacity() < l_size ) { + this->log_files_to_use.reserve( l_size ); + } + this->used_files_hashes.clear(); + if ( this->used_files_hashes.capacity() < l_size ) { + this->used_files_hashes.reserve( l_size ); + } + } + for ( const LogFile& file : this->logs_list ) { if ( ! this->proceed ) { break; } @@ -844,31 +714,18 @@ const bool Craplog::checkStuff() } // check if the file respects the warning size - if ( this->warning_size >= 0 ) { + if ( this->warning_size > 0 ) { if ( file.size > this->warning_size ) { // exceeds the warning size - QString size_str, msg = file.name; + QString msg = file.name; if ( this->dialogs_level >= 1 ) { - std::string size_sfx=" B"; - float size = (float)file.size; - if (size > 1024) { - size /= 1024; size_sfx = " KiB"; - if (size > 1024) { - size /= 1024; size_sfx = " MiB"; - } - } - size_str = std::to_string(size).substr(0,std::to_string(size).size()-3).c_str(); - msg += QString("\n\n%1:\n%2%3").arg( DialogSec::tr("Size of the file"), size_str, size_sfx.c_str() ); + msg += QString("\n\n%1:\n%2").arg( + DialogSec::tr("Size of the file"), + PrintSec::printableSize( file.size ) ); if ( this->dialogs_level == 2 ) { - size = (float)this->warning_size; - if (size > 1024) { - size /= 1024; size_sfx = " KiB"; - if (size > 1024) { - size /= 1024; size_sfx = " MiB"; - } - } - size_str = std::to_string(size).substr(0,std::to_string(size).size()-3).c_str(); - msg += QString("\n\n%1:\n%2%3").arg( DialogSec::tr("Warning size parameter"), size_str, size_sfx.c_str() ); + msg += QString("\n\n%1:\n%2").arg( + DialogSec::tr("Warning size parameter"), + PrintSec::printableSize( this->warning_size ) ); } } const int choice = DialogSec::choiceFileSizeWarning( msg ); @@ -889,7 +746,7 @@ const bool Craplog::checkStuff() } } - // check if the statistics' database is fune + // check if the databases are fune if ( ! CheckSec::checkCollectionDatabase( this->db_stats_path ) ) { // checks failed, abort this->proceed = false; @@ -901,230 +758,134 @@ const bool Craplog::checkStuff() break; } - this->log_files_to_use.push_back( file ); + this->log_files_to_use.push_back( + std::make_tuple( file.path, file.hash ) + ); + this->used_files_hashes.push_back( file.hash ); } return this->proceed; } -void Craplog::joinLogLines() +void Craplog::startWorking() { - std::string aux; - std::vector content; - for ( const LogFile& file : this->log_files_to_use ) { - - if ( ! this->proceed ) { break; } - - // collect lines - try { - // try reading - content.clear(); - aux = ""; - try { - // try as gzip compressed archive first - GZutils::readFile( file.path, aux ); - - } catch ( const GenericException& ) { - // failed closing file pointer - throw; - - } catch (...) { - // fallback on reading as normal file - if ( aux.size() > 0 ) { - aux = ""; - } - IOutils::readFile( file.path, aux ); - } - StringOps::splitrip( content, aux ); - if ( this->current_WS == this->IIS_ID ) { - this->logOps.cleanLines( content ); - } - - // re-catched in run() - } catch ( const GenericException& ) { - // failed closing gzip file pointer - throw GenericException( QString("%1:\n%2").arg( - DialogSec::tr("An error accured while reading the gzipped file"), - QString::fromStdString( file.path ) - ).toStdString() ); - - } catch ( const std::ios_base::failure& ) { - // failed reading as text - throw GenericException( QString("%1:\n%2").arg( - DialogSec::tr("An error accured while reading the file"), - QString::fromStdString( file.path ) - ).toStdString() ); - - } catch (...) { - // failed somehow - throw GenericException( QString("%1:\n%2").arg( - DialogSec::tr("Something failed while handling the file"), - QString::fromStdString( file.path ) - ).toStdString() ); - } - - // append to the relative list - this->logs_lines.insert( this->logs_lines.end(), content.begin(), content.end() ); - this->used_files_hashes.push_back( file.hash ); - this->total_lines += content.size(); + std::unique_lock lock( this->mutex ); + this->proceed = true; + this->total_lines = 0; + this->parsed_lines = 0; + this->total_size = 0; + this->parsed_size = 0; + this->warnlisted_size = 0; + this->blacklisted_size = 0; + // hire a worker + CraplogWorker* worker = new CraplogWorker( + this->current_WS, + this->dialogs_level, + this->db_stats_path, + this->db_hashes_path, + this->logs_formats.at( this->current_WS ), + this->blacklists.at( this->current_WS ), + this->warnlists.at( this->current_WS ), + this->log_files_to_use + ); + QThread* worker_thread = new QThread(); + worker->moveToThread( worker_thread ); + // start the worker + connect( worker_thread, &QThread::started, + worker, &CraplogWorker::work ); + // worker started parsing + connect( worker, &CraplogWorker::startedParsing, + this, &Craplog::workerStartedParsing ); + // worker finished parsing + connect( worker, &CraplogWorker::finishedParsing, + this, &Craplog::workerFinishedParsing ); + // receive performance data + connect( worker, &CraplogWorker::perfData, + this, &Craplog::updatePerfData ); + // receive chart data, only received when worker has done + connect( worker, &CraplogWorker::chartData, + this, &Craplog::updateChartData ); + // worker finished its career + connect( worker, &CraplogWorker::done, + this, &Craplog::stopWorking ); + // plan deleting the thread + connect( worker, &CraplogWorker::retire, + worker_thread, &QThread::quit ); + // plan deleting the worker + connect( worker, &CraplogWorker::retire, + worker, &CraplogWorker::deleteLater ); + // make the worker work + worker_thread->start(); +} +void Craplog::stopWorking( const bool successful ) +{ + this->db_edited = successful; + if ( successful ) { + // insert the hashes of the used files + this->hashOps.insertUsedHashes( this->db_hashes_path, this->used_files_hashes, this->current_WS ); } - aux.clear(); - content.clear(); - this->log_files_to_use.clear(); + emit this->finishedWorking(); +} + +const bool Craplog::editedDatabase() const +{ + return this->db_edited; } -void Craplog::parseLogLines() +const unsigned Craplog::getParsedSize() { - if ( this->proceed && this->logs_lines.size() > 0 ) { - this->logOps.parseLines( - this->data_collection, - this->logs_lines, - this->logs_formats.at( this->current_WS ) ); - } + std::unique_lock lock( this->mutex ); + return this->parsed_size; +} +const unsigned Craplog::getParsedLines() +{ + std::unique_lock lock( this->mutex ); + return this->parsed_lines; +} +const QString Craplog::getParsingSpeed() +{ + std::unique_lock lock( this->mutex ); + auto stop = ( is_parsing ) + ? std::chrono::system_clock::now() + : this->parsing_time_stop; + const unsigned secs = std::chrono::duration_cast( + this->parsing_time_start - stop ) + .count() / -1000000000; + return PrintSec::printableSpeed( this->parsed_size, secs ); } - - -void Craplog::storeLogLines() +void Craplog::workerStartedParsing() { - QString db_path = QString::fromStdString( this->db_stats_path ); - QString db_name = QString::fromStdString( this->db_stats_path.substr( this->db_stats_path.find_last_of( '/' ) + 1 ) ); - - QSqlDatabase db; - if ( QSqlDatabase::contains("qt_sql_default_connection") ) { - db = QSqlDatabase::database("qt_sql_default_connection"); - } else { - db = QSqlDatabase::addDatabase("QSQLITE"); - } - db.setDatabaseName( db_path ); - - if ( ! db.open() ) { - // error opening database - this->proceed = false; - QString err_msg = ""; - if ( this->dialogs_level == 2 ) { - err_msg = db.lastError().text(); - } - DialogSec::errDatabaseFailedOpening( db_name, err_msg ); - - } else { - - bool successful; - try { - // ACID transaction - if ( ! db.transaction() ) { - // error opening database - this->proceed = false; - QString stmt_msg="", err_msg = ""; - if ( this->dialogs_level > 0 ) { - stmt_msg = "db.transaction()"; - if ( this->dialogs_level == 2 ) { - err_msg = db.lastError().text(); - } - } - DialogSec::errDatabaseFailedExecuting( db_name, stmt_msg, err_msg ); - } - - if ( this->proceed && this->data_collection.size() > 0 ) { - successful = StoreOps::storeData( db, *this, this->data_collection ); - this->proceed = successful; - } - - if ( this->proceed ) { - // commit the transaction - if ( ! db.commit() ) { - // error opening database - this->proceed = false; - QString stmt_msg="", err_msg = ""; - if ( this->dialogs_level > 0 ) { - stmt_msg = "db.commit()"; - if ( this->dialogs_level == 2 ) { - err_msg= db.lastError().text(); - } - } - DialogSec::errDatabaseFailedExecuting( db_name, stmt_msg, err_msg ); - } - } - if ( ! proceed ) { - // rollback - throw (std::exception()); - } - - } catch (...) { - // wrongthing w3nt some.,. - this->proceed = false; - bool err_shown = false; - // rollback the transaction - if ( ! db.rollback() ) { - // error rolling back commits - QString stmt_msg="", err_msg = ""; - if ( this->dialogs_level > 0 ) { - stmt_msg = "db.rollback()"; - if ( this->dialogs_level == 2 ) { - err_msg = db.lastError().text(); - } - } - DialogSec::errDatabaseFailedExecuting( db_name, stmt_msg, err_msg ); - err_shown = true; - } - if ( ! err_shown ) { - // show a message - DialogSec::errGeneric( QString("%1\n\n%2").arg( - DialogSec::tr("An error occured while working on the database"), - DialogSec::tr("Aborting") ) ); - } - } - - db.close(); - } - + std::unique_lock lock( this->mutex ); + this->is_parsing = true; + this->parsing_time_start = std::chrono::system_clock::now(); +} +void Craplog::workerFinishedParsing() +{ + std::unique_lock lock( this->mutex ); + this->parsing_time_stop = std::chrono::system_clock::now(); + this->is_parsing = false; +} +const bool Craplog::isParsing() const +{ + return this->is_parsing; } - -const QString Craplog::printableSize( const unsigned& bytes ) const +void Craplog::updatePerfData( const unsigned parsed_size, const unsigned parsed_lines ) { - std::string size_str, size_sfx=" B"; - float size = (float)bytes; - if (size > 1024) { - size /= 1024; - size_sfx = " KiB"; - if (size > 1024) { - size /= 1024; - size_sfx = " MiB"; - } - } - // cut decimals depending on how big the floor is - size_str = std::to_string( size ); - size_t cut_index = size_str.find('.'); - if ( cut_index == std::string::npos ) { - cut_index = size_str.find(','); - if ( cut_index == std::string::npos ) { - cut_index = 0; - } - } - if ( cut_index != 0 ) { - cut_index ++; - } - short n_decimals = 3; - if ( size >= 100 ) { - n_decimals = 2; - if ( size >= 1000 ) { - n_decimals = 1; - if ( size >= 10000 ) { - n_decimals = 0; - cut_index --; - } - } - } - if ( cut_index > 0 ) { - cut_index += n_decimals; - if ( cut_index > size_str.size()-1 ) { - cut_index = size_str.size()-1; - } - } - return QString::fromStdString( size_str.substr(0, cut_index ) + size_sfx ); + std::unique_lock lock( this->mutex ); + this->parsed_size = parsed_size; + this->parsed_lines = parsed_lines; +} +void Craplog::updateChartData( const unsigned total_size, const unsigned total_lines, const unsigned warnlisted_size, const unsigned blacklisted_size ) +{ + std::unique_lock lock( this->mutex ); + this->total_size = total_size; + this->total_lines = total_lines; + this->warnlisted_size = warnlisted_size; + this->blacklisted_size = blacklisted_size; } @@ -1139,23 +900,26 @@ void Craplog::makeChart( const QChart::ChartTheme& theme, const std::unordered_m // logs size donut chart QPieSeries *parsedSize_donut = new QPieSeries(); - parsedSize_donut->setName( this->printableSize( this->parsed_size ) ); + parsedSize_donut->setName( PrintSec::printableSize( this->parsed_size + this->blacklisted_size ) ); + const unsigned parsed_size = this->parsed_size - this->warnlisted_size; parsedSize_donut->append( - "P@" + parsed_slice_name + "@" + this->printableSize( this->parsed_size-this->warnlisted_size ), - this->parsed_size-this->warnlisted_size ); + "P@" + parsed_slice_name + "@" + PrintSec::printableSize( parsed_size ), + parsed_size ); parsedSize_donut->append( - "W@" + warning_slice_name + "@" + this->printableSize( this->warnlisted_size ), + "W@" + warning_slice_name + "@" + PrintSec::printableSize( this->warnlisted_size ), this->warnlisted_size ); parsedSize_donut->append( - "B@" + blacklisted_slice_name + "@" + this->printableSize( this->blacklisted_size ), + "B@" + blacklisted_slice_name + "@" + PrintSec::printableSize( this->blacklisted_size ), this->blacklisted_size ); // logs size donut chart QPieSeries *ignoredSize_donut = new QPieSeries(); - ignoredSize_donut->setName( this->printableSize( this->total_size-this->parsed_size-this->blacklisted_size ) ); + const unsigned ignored_size = this->total_size - this->parsed_size - this->blacklisted_size; + QString printable_ignored_size = PrintSec::printableSize( ignored_size ); + ignoredSize_donut->setName( printable_ignored_size ); ignoredSize_donut->append( - "I@#" + ignored_slice_name + "@#" + this->printableSize( this->total_size-this->parsed_size-this->blacklisted_size ), - this->total_size-this->parsed_size-this->blacklisted_size ); + "I@#" + ignored_slice_name + "@#" + printable_ignored_size, + ignored_size ); ignoredSize_donut->setLabelsVisible( false ); DonutBreakdown *sizeBreakdown = new DonutBreakdown(); diff --git a/logdoctor/modules/craplog/craplog.h b/logdoctor/modules/craplog/craplog.h index 8511fdc3..03aea4a2 100644 --- a/logdoctor/modules/craplog/craplog.h +++ b/logdoctor/modules/craplog/craplog.h @@ -16,18 +16,13 @@ /*! Performs operations related to the logs */ -class Craplog +class Craplog : public QObject { + Q_OBJECT + public: explicit Craplog(); - //! Main work method - /*! - Manages the operations which need to be done to parse the logs - when the START button is pressed - */ - void run(); - ///////////////// //// DIALOGS //// @@ -111,7 +106,7 @@ public: struct LogFile { bool selected; //!< Wheter the file has been selected to be use or not bool used_already; //!< Wheter the file has been used already or not - int size; //!< The size of the file + unsigned size; //!< The size of the file QString name; //!< The name of the file, to be displayed in the list std::string hash; //!< The sha256 hash of the content std::string path; //!< The path of the file, including the file name @@ -223,10 +218,10 @@ public: //// WARNING SIZE //// //! Returns the currently set warning size for the log files - const long& getWarningSize() const; + const unsigned& getWarningSize() const; //! Sets the new warning size for the log files - void setWarningSize( const long& new_size ); + void setWarningSize( const unsigned& new_size ); //////////////////// @@ -395,9 +390,6 @@ public: ////////////// //// WORK //// - //! Returns whether the database has been edited or not during the process - const bool& editedDatabase() const; - //! Various checks to be made before starting a new process /*! Checks the databases, the selected files and their size @@ -406,43 +398,24 @@ public: */ const bool checkStuff(); - //! Erases the data collection when a process is done - void clearDataCollection(); + //! Returns whether the database has been edited or not during the process + const bool isParsing() const; - //! Returns whether the process is still running or not - const bool& isWorking(); - - //! Returns whether the process is still parsing or not - const bool& isParsing(); + //! Returns whether the database has been edited or not during the process + const bool editedDatabase() const; ////////////////////// //// PERFORMANCES //// - //! Collects performances data from the sub-modules - /*! - \see LogOps::getParsedSize(), LogOps::getParsedLines() - */ - void collectPerfData(); - - //! Sums the given size to the warnlisted size - void sumWarningsSize( const unsigned int& size ); - - //! Sums the given size to the blacklisted size - void sumBlacklistededSize( const unsigned int& size ); - - /*void sumPerfSize( const unsigned& size );*/ - - //! Returns the size to be displayed in the main window - const unsigned int& getPerfSize(); - //! Returns the total logs size - const unsigned int& getTotalSize(); + const unsigned getParsedSize(); //! Returns the parsed logs lines - const unsigned int& getParsedLines(); + const unsigned getParsedLines(); - /*const unsigned int& getParsedSize();*/ + //! Returns the speed on parsing logs + const QString getParsingSpeed(); //! Builds and draws the chart to be displayed in the main window /*! @@ -454,6 +427,29 @@ public: void makeChart( const QChart::ChartTheme& theme, const std::unordered_map& fonts, QChartView* size_chart ) const; +signals: + + void finishedWorking(); + + +public slots: + + void startWorking(); + + void workerStartedParsing(); + + void workerFinishedParsing(); + + void stopWorking( const bool successful ); + + void updatePerfData( const unsigned parsed_size, + const unsigned parsed_lines ); + + void updateChartData( const unsigned total_size, + const unsigned total_lines, + const unsigned warnlisted_size, + const unsigned blacklisted_size ); + private: @@ -466,9 +462,9 @@ private: ///////////////////////// //// WEB SERVERS IDs //// - const unsigned int APACHE_ID = 11; //!< ID of the Apache2 Web Server - const unsigned int NGINX_ID = 12; //!< ID of the Nginx Web Server - const unsigned int IIS_ID = 13; //!< ID of the IIS Web Server + const unsigned APACHE_ID = 11; //!< ID of the Apache2 Web Server + const unsigned NGINX_ID = 12; //!< ID of the Nginx Web Server + const unsigned IIS_ID = 13; //!< ID of the IIS Web Server /////////////////// @@ -481,85 +477,33 @@ private: ////////////// //// WORK //// - bool db_edited = false; - bool working = false; - bool parsing = false; bool proceed = false; + bool db_edited = false; + bool is_parsing = false; + std::mutex mutex; - //! Sets the working state - /*! - \see isWorking() - */ - void startWorking(); - - //! Un-sets the working state - /*! - \see isWorking() - */ - void stopWorking(); - ////////////////////// //// PERFORMANCES //// - unsigned int total_lines = 0; // total number of logs lines - unsigned int parsed_lines = 0; // number of parsed logs lines - unsigned int perf_size = 0; // final size to show in the main window - unsigned int total_size = 0; // total size of the logs - unsigned int parsed_size = 0; // size of the logs which have been used - unsigned int warnlisted_size = 0; // size of the logs which caused a warning - unsigned int blacklisted_size = 0; // size of the logs which has been blacklisted + unsigned total_lines = 0; // total number of logs lines + unsigned parsed_lines = 0; // number of parsed logs lines + unsigned total_size = 0; // total size of the logs + unsigned parsed_size = 0; // size of the logs which have been used + unsigned warnlisted_size = 0; // size of the logs which caused a warning + unsigned blacklisted_size = 0; // size of the logs which has been blacklisted - //! Returns a printable size to be displayed in the chart, including the suffix - /*! - \param bytes The size in bytes - \return The string to be displayed - \see makeChart() - */ - const QString printableSize( const unsigned int& bytes ) const; + std::chrono::system_clock::time_point parsing_time_start, + parsing_time_stop; //////////////////// //// LOGS ITEMS //// - // collection of logs items, each item results from a log line - /* structure - [ { log_field_id : "data" } ] - - log_field_ids - 99: warning, - 1: year, 2: month, 3: day, 4: hour, 5: minute, 6:second, - 10: request_protocol, 11: request_method, 12: request_uri, 13: request_query, 14: response_code, - 15: time_taken, 16: bytes_sent, 17: bytes_received, 18: referrer, - 20: client, 21: user_agent, 22: cookie - */ - std::vector> data_collection; - // the selected log files to be parsed during the process - std::vector log_files_to_use; + std::vector> log_files_to_use; - // the entire stack of lines which have been read from the log files - std::vector logs_lines; - - //! Reads the selected files and append the resulting lines to the list - /*! - \throw GenericException - */ - void joinLogLines(); - - //! Parses the lines in the list and stores their data in the data collection - /*! - \see LogOps::parseLines() - */ - void parseLogLines(); - - //! Stores the data collection in the database - /*! - \see StoreOps::storeData() - */ - void storeLogLines(); - - // used files + // used files hashes std::vector used_files_hashes; @@ -567,7 +511,7 @@ private: //// LOGS CONTROL //// // warning size, in Bytes - long warning_size = (1'048'576 * 50) +1; // => 1 MiB * x + unsigned warning_size = (1'048'576 * 50) +1; // => 1 MiB * x ////////////////////////////// From d744f346fbc3910627b27b1ea1addec4d854b8b5 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:35:36 +0100 Subject: [PATCH 25/36] Update Removed stuff which is now done by Craplog's worker. --- logdoctor/modules/craplog/modules/logs.cpp | 341 --------------------- logdoctor/modules/craplog/modules/logs.h | 107 ------- 2 files changed, 448 deletions(-) diff --git a/logdoctor/modules/craplog/modules/logs.cpp b/logdoctor/modules/craplog/modules/logs.cpp index 49a731b3..6ead0a25 100644 --- a/logdoctor/modules/craplog/modules/logs.cpp +++ b/logdoctor/modules/craplog/modules/logs.cpp @@ -13,12 +13,6 @@ LogOps::LogOps() } -void LogOps::setMutex( std::mutex* craplog_mutex ) -{ - this->mutex = craplog_mutex; -} - - const LogOps::LogType LogOps::defineFileType( const std::vector& lines, const FormatOps::LogsFormat& format ) const { if ( lines.size() == 0 ) { @@ -142,338 +136,3 @@ const bool LogOps::deepTypeCheck( const std::string& line, const FormatOps::Logs return result; } - - -void LogOps::cleanLines( std::vector& lines ) const -{ - std::vector aux; - for ( const std::string& line : lines ) { - if ( !StringOps::startsWith( line, "#" ) ) { - // not a commented line - aux.push_back( line ); - } - } - lines = std::move( aux ); -} - - - -const std::unordered_map LogOps::parseLine( const std::string& line, const FormatOps::LogsFormat& format ) -{ - std::unordered_map data; - std::string sep, fld, fld_str; - bool add_pm=false; - size_t start, stop=0, aux_start, aux_stop, - line_size = line.size()-1; - int i=0, n_sep=format.separators.size()-1; - - // add the initial chars - stop = format.initial.size(); - - while (true) { - // split fields - start = stop; // stop updated at the end of the loop - if ( i <= n_sep ) { - sep = format.separators.at( i ); - stop = line.find( sep, start ); - } else if ( i == n_sep+1 ) { - // final separator - sep = format.final; - if ( sep == "" ) { - stop = line_size+1; - } else { - stop = line.find( sep, start ); - if ( stop == std::string::npos ) { - stop = line_size +1; - } - } - } else { - // no more separators - break; - } - if ( stop == std::string::npos ) { - // separator not found, abort - throw LogParserException( "Separator not found", sep ); - } - - // get the field - fld = format.fields.at( i ); - if ( fld != "NONE" ) { - // only parse the considered fields - fld_str = StringOps::strip( line.substr(start, stop-start), " " ); - - if ( i+1 <= n_sep ) { - // not the last separator, check for mistakes - bool ok = true; - aux_stop = stop; - - if ( sep == " " ) { - // whitespace-separated-values fields - int c = StringOps::count( fld_str, sep ), - n = 0; - if ( fld == "request_full" ) { - n = 2; - } else if ( fld == "date_time_mcs" ) { - n = 4; - } else if ( fld == "date_time_ncsa" ) { - n = 1; - } else if ( fld == "date_time_gmt" ) { - n = 3; - } - if ( n > 0 && c < n ) { - // loop until the correct number of whitespaces is reached - aux_start = stop + 1; - while ( c < n ) { - aux_stop = line.find( sep, aux_start ); - if ( aux_stop == std::string::npos ) { - // not found - ok = false; - break; - } - aux_start = aux_stop + 1; - c++; - } - } - - } else if ( fld == "user_agent" && StringOps::startsWith( sep, "\"" ) ) { - // atm the only support is for escaped quotes - if ( fld_str.back() == '\\' ) { - aux_start = stop + sep.size(); - while (true) { - aux_stop = line.find( sep, aux_start ); - if ( aux_stop == std::string::npos ) { - // not found - break; - } else if ( line.at( aux_stop-1 ) != '\\' ) { - // non-backslashed quotes - break; - } - aux_start = aux_stop + sep.size(); - } - } - } - - // finally update if needed - if ( ok && aux_stop >= stop ) { - stop = aux_stop; - fld_str = StringOps::strip( line.substr(start, stop-start), " " ); - } - } - - // process the field - { - std::unique_lock lock( *this->mutex ); - this->parsed_size += fld_str.size(); - } - - if ( fld_str != "" ) { - int fld_id = this->field2id.at(fld); - if ( fld_id > 0 ) { - // no need to process, append directly if non-empty - data.emplace( fld_id, fld_str ); - - } else { - // process the field - - // process the date to get year, month, day, hour and minute - if ( StringOps::startsWith( fld, "date_time" ) ) { - const std::vector dt = DateTimeOps::processDateTime( fld_str, fld.substr( 10 ) ); // cut away the "date_time_" part which is useless from now on - if ( dt.at( 0 ) != "" ) { - // year - data.emplace( this->field2id.at("date_time_year"), dt.at( 0 ) ); - } - if ( dt.at( 1 ) != "" ) { - // month - data.emplace( this->field2id.at("date_time_month"), dt.at( 1 ) ); - } - if ( dt.at( 2 ) != "" ) { - // day - data.emplace( this->field2id.at("date_time_day"), dt.at( 2 ) ); - } - if ( dt.at( 3 ) != "" ) { - // hour - if ( dt.at( 3 ) == "PM" ) { - add_pm = true; - } else { - data.emplace( this->field2id.at("date_time_hour"), dt.at( 3 ) ); - } - } - if ( dt.at( 4 ) != "" ) { - // minute - data.emplace( this->field2id.at("date_time_minute"), dt.at( 4 ) ); - } - if ( dt.at( 5 ) != "" ) { - // second - data.emplace( this->field2id.at("date_time_second"), dt.at( 5 ) ); - } - - - // process the request to get the protocol, method, resource and query - } else if ( fld == "request_full" ) { - size_t aux; - std::string aux_fld, protocol="", method="", page="", query=""; - aux_fld = fld_str; - // method - aux = aux_fld.find( ' ' ); - if ( aux != std::string::npos ) { - method = aux_fld.substr( 0, aux ); - aux_fld = StringOps::lstrip( aux_fld.substr( aux ) ); - - // page & query - aux = aux_fld.find( ' ' ); - if ( aux != std::string::npos ) { - std::string aux_str = aux_fld.substr( 0, aux ); - // search for the query - int aux_ = aux_str.find( '?' ); - if ( aux_ != std::string::npos ) { - page = aux_str.substr( 0, aux_ ); - query = aux_str.substr( aux_+1 ); - } else { - // query not found - page = aux_str; - } - aux_fld = StringOps::lstrip( aux_fld.substr( aux ) ); - - // protocol - protocol = aux_fld; - } - } - // append non-empty data - if ( protocol != "" ) { - data.emplace( this->field2id.at("request_protocol"), protocol ); - } - if ( method != "" ) { - data.emplace( this->field2id.at("request_method"), method ); - } - if ( page != "" ) { - data.emplace( this->field2id.at("request_uri"), page ); - } - if ( query != "" ) { - data.emplace( this->field2id.at("request_query"), query ); - } - - - - // process the request to get uri and query - } else if ( fld == "request_uri_query" ) { - // search for the query - std::string page, query; - size_t aux_ = fld_str.find( '?' ); - if ( aux_ != std::string::npos ) { - page = fld_str.substr( 0, aux_ ); - query = fld_str.substr( aux_+1 ); - } else { - // query not found - page = fld_str; - } - if ( page != "" ) { - data.emplace( this->field2id.at("request_uri"), page ); - } - if ( query != "" ) { - data.emplace( this->field2id.at("request_query"), query ); - } - - - - // process the time taken to convert to milliseconds - } else if ( StringOps::startsWith( fld, "time_taken_" ) ) { - float t = std::stof( fld_str ); - fld = fld.substr( 11 ); - if ( fld == "us" ) { - // from microseconds - t /= 1000; - } else if ( fld == "s" || fld == "s.ms" ) { - // from seconds - t *= 1000; - } - data.emplace( this->field2id.at("time_taken"), std::to_string( (int)t ) ); - - - // something went wrong - } else { - // hmmm.. no... - throw LogParserException( "Unexpected LogField", fld ); - } - } - } - } - - - // update the stop for the next start - stop += sep.size(); - i++; - if ( stop > line_size ) { - // this was the final separator - break; - } - } - - if ( add_pm ) { - try { - // add +12 hours for PM - data.at( 4 ) = std::to_string( 12 + std::stoi(data.at( 4 )) ); - } catch (...) { - // no hour data - } - } - - // set the default warning mark ( 0=false ) to default status - data.emplace( 99, "0" ); - { - std::unique_lock lock( *this->mutex ); - this->total_size += line_size; - this->parsed_lines ++; - } - - return data; -} - -void LogOps::parseLines( std::vector>& data, const std::vector& lines, const FormatOps::LogsFormat& format ) -{ - data.clear(); - data.shrink_to_fit(); - int nl = format.new_lines; - if ( nl == 0 ) { - data.reserve( lines.size() ); - for ( const std::string& line : lines ) { - data.push_back( this->parseLine( line, format ) ); - } - } else { - data.reserve( parsed_size / (nl+1) ); - parsed_size --; - for ( int i=0; iparseLine( line, format ) ); - } - } - if ( data.size() < data.capacity() ) { - data.shrink_to_fit(); - } -} - - -void LogOps::resetPerfData() -{ - this->total_size = 0; - this->parsed_size = 0; - this->parsed_lines = 0; -} -const unsigned LogOps::getTotalSize() -{ - std::unique_lock lock( *this->mutex ); - return this->total_size; -} -const unsigned LogOps::getParsedSize() -{ - std::unique_lock lock( *this->mutex ); - return this->parsed_size; -} -const unsigned LogOps::getParsedLines() -{ - std::unique_lock lock( *this->mutex ); - return this->parsed_lines; -} diff --git a/logdoctor/modules/craplog/modules/logs.h b/logdoctor/modules/craplog/modules/logs.h index eb622a7b..e8bb34b0 100644 --- a/logdoctor/modules/craplog/modules/logs.h +++ b/logdoctor/modules/craplog/modules/logs.h @@ -19,13 +19,6 @@ public: explicit LogOps(); - //! Receives the mutex to be shared with Craplog - /*! - \param craplog_mutex The mutex from Craplog - */ - void setMutex( std::mutex* craplog_mutex=nullptr ); - - //! Enumerates log file types /*! File types used to decide whether a file should be considered valid or not @@ -49,87 +42,9 @@ public: const FormatOps::LogsFormat& format ) const; - //! Removes commented lines from the given list - /*! - \param lines The lines to clean - */ - void cleanLines( - std::vector& lines - ) const; - - //! Parses log lines to extract data - /*! - \param data The data collection which will hold the data - \param lines The list of lines to parse - \param format The logs format to use - \throw LogParserException - \see parseLine(), Craplog::parseLogLines(), FormatOps::LogsFormat - */ - void parseLines( - std::vector>& data, - const std::vector& lines, - const FormatOps::LogsFormat& format - ); - - //! Resets the performances data - void resetPerfData(); - - // share perf data with craplog - const unsigned getTotalSize(); //!< Returns the total size of the logs lines. \see total_size - const unsigned getParsedSize(); //!< Returns the parsed logs size. \see parsed_size - const unsigned getParsedLines(); //!< Returns the number of parsed log lines. \see parsed_lines private: - // Map to convert log fields to field IDs - const std::unordered_map field2id = { - // date-time - {"date_time_year", 1}, - {"date_time_month", 2}, - {"date_time_day", 3}, - {"date_time_hour", 4}, - {"date_time_minute", 5}, - {"date_time_second", 6}, - {"date_time_ncsa", 0}, - {"date_time_iso", 0}, - {"date_time_mcs", 0}, - {"date_time_gmt", 0}, - {"date_time_utc_d", 0}, - {"date_time_utc_t", 0}, - {"date_time_epoch_s", 0}, - {"date_time_epoch_s.ms", 0}, - {"date_time_epoch_ms", 0}, - {"date_time_epoch_us", 0}, - {"date_time_YYYYMMDD", 0}, - {"date_time_MMDDYY", 0}, - {"date_time_MDYY", 0}, - {"date_time_year_short", 0}, - {"date_time_month_str", 0}, - {"date_time_clock_12", 0}, - {"date_time_clock_24", 0}, - {"date_time_clock_short", 0}, - // request - {"request_protocol", 10}, - {"request_method", 11}, - {"request_uri", 12}, - {"request_query", 13}, - {"response_code", 14}, - {"request_full", 0}, - // performance - {"time_taken_ms", 15}, - {"time_taken_us", 0}, - {"time_taken_s.ms", 0}, - {"time_taken_s", 0}, - {"bytes_sent", 16}, - {"bytes_received", 17}, - // referer - {"referer", 18}, - // client data - {"client", 20}, - {"user_agent", 21}, - {"cookie", 22} - }; - //! Parse the given line using the given format /*! \param line The log line to check @@ -142,28 +57,6 @@ private: const FormatOps::LogsFormat& format ) const; - //! Parses a line to extract data - /*! - \param line The log line to parse - \param format The logs format to use - \return A data collection item - \throw LogParserException - \see parseLines(), Craplog::data_collection, FormatOps::LogsFormat - */ - const std::unordered_map parseLine( - const std::string& line, - const FormatOps::LogsFormat& format - ); - - // a mutex shared with craplog - std::mutex* mutex = nullptr; - - // temporary vars - unsigned total_size=0; //!< Total size of the parsed logs. \see getTotalSize() - unsigned parsed_size=0; //!< Size of the parsed logs. \see getParsedSize() - unsigned parsed_lines=0; //!< Number of parsed logs lines. \see getParsedLines() - - }; #endif // LOGS_H From ca1bb8d91d27e4fee1a6fc570d7245fffc59e3e2 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:37:05 +0100 Subject: [PATCH 26/36] Removed Craplog's module StoreOps Worker handles all this stuff --- logdoctor/modules/craplog/modules/store.cpp | 290 -------------------- logdoctor/modules/craplog/modules/store.h | 27 -- 2 files changed, 317 deletions(-) delete mode 100644 logdoctor/modules/craplog/modules/store.cpp delete mode 100644 logdoctor/modules/craplog/modules/store.h diff --git a/logdoctor/modules/craplog/modules/store.cpp b/logdoctor/modules/craplog/modules/store.cpp deleted file mode 100644 index 4927e9b2..00000000 --- a/logdoctor/modules/craplog/modules/store.cpp +++ /dev/null @@ -1,290 +0,0 @@ - -#include "store.h" - -#include "modules/dialogs.h" -#include "modules/exceptions.h" - -#include "utilities/strings.h" - -#include - - -StoreOps::StoreOps() -{ - -} - - - -bool StoreOps::storeData( QSqlDatabase& db, Craplog& craplog, const std::vector>& data ) -{ - bool successful = true; - - int wsID = craplog.getCurrentWSID(); - QString db_name; - { - std::string db_path = craplog.getStatsDatabasePath(); - db_name.append( QString::fromStdString( db_path.substr( db_path.find_last_of( '/' ) + 1 ) ) ); - } - - // get blacklist/warnlist items - bool check_bl_cli, - check_wl_cli, check_wl_ua, check_wl_met, check_wl_req; - check_bl_cli = craplog.isBlacklistUsed( wsID, 20 ); - check_wl_met = craplog.isWarnlistUsed( wsID, 11 ); - check_wl_req = craplog.isWarnlistUsed( wsID, 12 ); - check_wl_cli = craplog.isWarnlistUsed( wsID, 20 ); - check_wl_ua = craplog.isWarnlistUsed( wsID, 21 ); - std::vector bl_cli_list, wl_cli_list, wl_ua_list, wl_met_list, wl_req_list; - if ( check_bl_cli ) { - bl_cli_list = craplog.getBlacklist( wsID, 20 ); - } - if ( check_wl_met ) { - wl_met_list = craplog.getWarnlist( wsID, 11 ); - } - if ( check_wl_req ) { - wl_req_list = craplog.getWarnlist( wsID, 12 ); - } - if ( check_wl_cli ) { - wl_cli_list = craplog.getWarnlist( wsID, 20 ); - } - if ( check_wl_ua ) { - wl_ua_list = craplog.getWarnlist( wsID, 21 ); - } - - // prepare the database related studd - QString table; - switch ( wsID ) { - case 11: - table = "apache"; - break; - case 12: - table = "nginx"; - break; - case 13: - table = "iis"; - break; - default: - // wrong WebServerID, but should be unreachable because of the previous operations - throw WebServerException( "Unexpected WebServerID: " + std::to_string(wsID) ); - } - - - int perf_size; - bool skip = false, - warning = false; - QSqlQuery query = QSqlQuery( db ); - // parse every row of data - for ( const std::unordered_map& row : data ) { - // break if failed - if ( ! successful ) { break; } - - // check blacklisted clients - if ( check_bl_cli ) { - if ( row.find( 20 ) != row.end() ) { - // this row do contains this row item, check if they match - const std::string& target = row.at( 20 ); - for ( const auto& item : bl_cli_list ) { - if ( StringOps::startsWith( target, item ) ) { - // match found! skip this line - skip = true; - break; - } - } - } - } - if ( skip ) { - // append every field to ignored size - int blacklisted_size = 0; - for ( const auto& [ id, str ] : row ) { - blacklisted_size += str.size(); - } - craplog.sumBlacklistededSize( blacklisted_size ); - skip = false; - continue; - } - - // check warnlisted clients - if ( check_wl_cli ) { - if ( row.find( 20 ) != row.end() ) { - // this row do contains this row item, check if they match - const std::string& target = row.at( 20 ); - for ( const auto& item : wl_cli_list ) { - if ( StringOps::startsWith( target, item ) ) { - // match found! put a warning on this line - warning = true; - craplog.sumWarningsSize( item.size() ); - break; - } - } - } - } - // check warnlisted user-agents - if ( check_wl_ua && !warning ) { - if ( row.find( 21 ) != row.end() ) { - // this row do contains this row item, check if they match - const std::string& target = row.at( 21 ); - for ( const auto& item : wl_ua_list ) { - if ( StringOps::startsWith( target, item ) ) { - // match found! skip this line - warning = true; - craplog.sumWarningsSize( item.size() ); - break; - } - } - } - } - // check warnlisted methods - if ( check_wl_met && !warning ) { - if ( row.find( 11 ) != row.end() ) { - // this row do contains this row item, check if they match - const std::string& target = row.at( 11 ); - for ( const auto& item : wl_met_list ) { - if ( item == target ) { - // match found! skip this line - warning = true; - craplog.sumWarningsSize( item.size() ); - break; - } - } - } - } - // check warnlisted requests urls - if ( check_wl_req && !warning ) { - if ( row.find( 12 ) != row.end() ) { - // this row do contains this row item, check if they match - const std::string& target = row.at( 12 ); - for ( const auto& item : wl_req_list ) { - if ( StringOps::startsWith( target, item ) ) { - // match found! skip this line - warning = true; - craplog.sumWarningsSize( item.size() ); - break; - } - } - } - } - - - // initialize the SQL statement - QString query_stmt; - query_stmt = "INSERT INTO \""+table+"\" (\"warning\", \"year\", \"month\", \"day\", \"hour\", \"minute\", \"second\", \"protocol\", \"method\", \"uri\", \"query\", \"response\", \"time_taken\", \"bytes_sent\", \"bytes_received\", \"referrer\", \"client\", \"user_agent\", \"cookie\") "\ - "VALUES ("; - - - // complete and execute the statement, binding NULL if not found - perf_size = 0; - - // warning - if ( row.find( 99 ) == row.end() ) { - // no value found in the collection, bind NULL - query_stmt += "0"; - } else { - // value found, bind it - perf_size ++; - if ( ! warning ) { - query_stmt += "0"; - } else { - query_stmt += "1"; - warning = false; - } - } - - // date and time - for ( int i=1; i<7; i++ ) { - query_stmt += ", "; - if ( row.find( i ) == row.end() ) { - // no value found in the collection, bind NULL - query_stmt += "NULL"; - } else { - // value found, bind it - perf_size += row.at( i ).size(); - query_stmt += QString::fromStdString( row.at( i ) ).replace("'","''"); - } - } - - // request - for ( int i=10; i<14; i++ ) { - query_stmt += ", "; - if ( row.find( i ) == row.end() ) { - // no value found in the collection, bind NULL - query_stmt += "NULL"; - } else { - // value found, bind it - perf_size += row.at( i ).size(); - query_stmt += QString("'%1'").arg( QString::fromStdString( row.at( i ) ).replace("'","''") ); - } - } - - for ( int i=14; i<18; i++ ) { - query_stmt += ", "; - if ( row.find( i ) == row.end() ) { - // no value found in the collection, bind NULL - query_stmt += "NULL"; - } else { - // value found, bind it - perf_size += row.at( i ).size(); - query_stmt += QString::fromStdString( row.at( i ) ).replace("'","''"); - } - } - - // client data and referrer - for ( int i : std::vector({18,20,21,22}) ) { - query_stmt += ", "; - if ( row.find( i ) == row.end() ) { - // no value found in the collection, bind NULL - query_stmt += "NULL"; - } else { - // value found, bind it - if ( i == 21 && wsID == 13 ) { - // iis logs the user-agent using '+' instead of ' ' (spaces) - QString str = QString::fromStdString( row.at( i ) ).replace("+"," "); - perf_size += str.size(); - query_stmt += QString("'%1'").arg( str.replace("'","''") ); - } else { - perf_size += row.at( i ).size(); - query_stmt += QString("'%1'").arg( QString::fromStdString( row.at( i ) ).replace("'","''") ); - } - } - } - - - // encode the statement - query_stmt += ");"; - if ( ! query.prepare( query_stmt ) ) { - // error opening database - successful = false; - QString query_msg="", err_msg=""; - if ( craplog.getDialogsLevel() > 0 ) { - query_msg = "query.prepare()"; - if ( craplog.getDialogsLevel() == 2 ) { - err_msg = query.lastError().text(); - } - } - DialogSec::errDatabaseFailedExecuting( db_name, query_msg, err_msg ); - } - - // sum stored data size for the perfs - //craplog.sumPerfSize( perf_size ); - - // finalize this statement - if ( ! query.exec() ) { - // error finalizing step - successful = false; - QString query_msg="", err_msg=""; - if ( craplog.getDialogsLevel() > 0 ) { - query_msg = "query.exec()"; - if ( craplog.getDialogsLevel() == 2 ) { - err_msg = query.lastError().text(); - } - } - DialogSec::errDatabaseFailedExecuting( db_name, query_msg, err_msg ); - break; - } - - // reset the statement to prepare for the next one - query.finish(); - } - - return successful; -} diff --git a/logdoctor/modules/craplog/modules/store.h b/logdoctor/modules/craplog/modules/store.h deleted file mode 100644 index 242d7100..00000000 --- a/logdoctor/modules/craplog/modules/store.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef STORE_H -#define STORE_H - -#include "modules/craplog/craplog.h" - - -//! StoreOps -/*! - Operations to store logs data -*/ -class StoreOps -{ -public: - explicit StoreOps(); - - //! Stores the data collection in the logs Collection database - /*! - \param db A database instance, already initizlized - \param craplog The Craplog instance - \param data The logs data collection - \return Whether the operation has been successful or not - \throw WebServerException - */ - static bool storeData( QSqlDatabase& db, Craplog& craplog, const std::vector>& data ); -}; - -#endif // STORE_H From bbb5065dc7d12a6e4cc92b9dbc4e95a092831b7e Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:39:57 +0100 Subject: [PATCH 27/36] Update Removed use of the default connection for the database as consequence of the introduction of the worker updating it in a separate thread: avoid query errors and crashes --- logdoctor/modules/craplog/modules/hash.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/logdoctor/modules/craplog/modules/hash.cpp b/logdoctor/modules/craplog/modules/hash.cpp index e723f7f1..4d83b704 100644 --- a/logdoctor/modules/craplog/modules/hash.cpp +++ b/logdoctor/modules/craplog/modules/hash.cpp @@ -179,12 +179,7 @@ const bool HashOps::insertUsedHashes( const std::string& db_path, const std::vec bool proceed = true; const QString db_name = QString::fromStdString( db_path.substr( db_path.find_last_of( '/' ) + 1 ) ); - QSqlDatabase db; - if ( QSqlDatabase::contains("qt_sql_default_connection") ) { - db = QSqlDatabase::database("qt_sql_default_connection"); - } else { - db = QSqlDatabase::addDatabase("QSQLITE"); - } + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName( QString::fromStdString( db_path ) ); if ( ! db.open() ) { From df46ae69da3d6a5a393231b6fce60222b47a8c0f Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:45:51 +0100 Subject: [PATCH 28/36] Improvements and updates Code improvements. Removed printable stuff. Added help fallback to hard-coded default in case of missing resources. Added signals and slots to synchronize with Craplog and get performance data. --- logdoctor/mainwindow.cpp | 493 +++++++++++++++------------------------ logdoctor/mainwindow.h | 51 ++-- 2 files changed, 207 insertions(+), 337 deletions(-) diff --git a/logdoctor/mainwindow.cpp b/logdoctor/mainwindow.cpp index 358361d2..ee348d76 100644 --- a/logdoctor/mainwindow.cpp +++ b/logdoctor/mainwindow.cpp @@ -6,6 +6,7 @@ #include "utilities/colors.h" #include "utilities/gzip.h" #include "utilities/io.h" +#include "utilities/printables.h" #include "utilities/rtf.h" #include "utilities/stylesheets.h" @@ -107,6 +108,12 @@ MainWindow::MainWindow(QWidget *parent) this->readConfigs(); + ///////////////// + //// CRAPLOG //// + connect(this, &MainWindow::runCraplog, &this->craplog, &Craplog::startWorking); + connect(&this->craplog, &Craplog::finishedWorking, this, &MainWindow::craplogFinished); + + /////////////////// //// POLISHING //// // default tabs @@ -245,7 +252,6 @@ MainWindow::~MainWindow() { delete this->ui; delete this->waiter_timer; - delete this->craplog_timer; delete this->crapview_timer; delete this->craphelp; delete this->crapnote; @@ -357,7 +363,8 @@ void MainWindow::readConfigs() } if ( proceed ) { - QString err_msg="", aux_err_msg; + err_msg.clear(); + QString aux_err_msg; std::vector aux, configs; try { // reset the lists when a config file is found @@ -987,13 +994,16 @@ const std::string MainWindow::list2string( const std::vector& list, { std::string string; if ( user_agent ) { - for ( const std::string& str : list ) { - string += StringOps::replace( str, " ", "%@#" ) + " "; - } + string = std::accumulate( + list.begin(), list.end(), string, + [](auto& s, auto str)->std::string& + { return s += StringOps::replace( str, " ", "%@#" ) + " "; } ); + } else { - for ( const std::string& str : list ) { - string += str + " "; - } + string = std::accumulate( + list.begin(), list.end(), string, + [](auto& s, auto str)->std::string& + { return s += str + " "; } ); } return string; } @@ -1002,13 +1012,11 @@ const std::vector MainWindow::string2list( const std::string& strin std::vector list, aux; StringOps::splitrip( aux, string, " " ); if ( user_agent ) { - for ( const std::string& str : aux ) { - list.push_back( StringOps::replace( str, "%@#", " " ) ); - } + std::transform( aux.cbegin(), aux.cend(), + std::back_inserter( list ), + [](auto str){ return StringOps::replace( str, "%@#", " " ); } ); } else { - for ( const std::string& str : aux ) { - list.push_back( str ); - } + list = std::move( aux ); } return list; } @@ -1799,105 +1807,14 @@ const std::string MainWindow::parentPath( const std::string& path ) const return path.substr( 0, stop ); } -// printable size with suffix and limited decimals -const QString MainWindow::printableSize( const int bytes ) const -{ - std::string size_str, size_sfx=" B"; - float size = (float)bytes; - if (size > 1024) { - size /= 1024; - size_sfx = " KiB"; - if (size > 1024) { - size /= 1024; - size_sfx = " MiB"; - } - } - // cut decimals depending on how big the floor is - size_str = std::to_string( size ); - int cut_index = size_str.find('.')+1; - if ( cut_index == 0 ) { - cut_index = size_str.find(',')+1; - } - int n_decimals = 3; - if ( size >= 100 ) { - n_decimals = 2; - if ( size >= 1000 ) { - n_decimals = 1; - if ( size >= 10000 ) { - n_decimals = 0; - cut_index --; - } - } - } - if ( cut_index >= 1 ) { - cut_index += n_decimals; - if ( cut_index > size_str.size()-1 ) { - cut_index = size_str.size()-1; - } - } - return QString::fromStdString( size_str.substr(0, cut_index ) + size_sfx ); -} - -// printable speed with suffix and limited decimals -const QString MainWindow::printableSpeed( const int bytes, const int secs_ ) const -{ - std::string speed_str, speed_sfx=" B/s"; - int secs = secs_; - if ( secs == 0 ) { - secs = 1; - } - float speed = (float)bytes / (float)secs; - if (speed > 1024) { - speed /= 1024; - speed_sfx = " KiB/s"; - if (speed > 1024) { - speed /= 1024; - speed_sfx = " MiB/s"; - } - } - // cut decimals depending on how big the floor is - speed_str = std::to_string( speed ); - int cut_index = speed_str.find('.')+1; - if ( cut_index == 0 ) { - cut_index = speed_str.find(',')+1; - } - int n_decimals = 3; - if ( speed >= 100 ) { - n_decimals = 2; - if ( speed >= 1000 ) { - n_decimals = 1; - if ( speed >= 10000 ) { - n_decimals = 0; - cut_index --; - } - } - } - if ( cut_index >= 1 ) { - cut_index += n_decimals; - if ( cut_index > speed_str.size()-1 ) { - cut_index = speed_str.size()-1; - } - } - return QString::fromStdString( speed_str.substr(0, cut_index ) + speed_sfx ); -} - -const QString MainWindow::printableTime( const int secs_ ) const -{ - int secs = secs_; - int mins = secs / 60; - secs = secs - (mins*60); - std::string mins_str = (mins<10) ? "0"+std::to_string(mins) : std::to_string(mins); - std::string secs_str = (secs<10) ? "0"+std::to_string(secs) : std::to_string(secs); - return QString::fromStdString( mins_str +":"+ secs_str ); -} - ////////////// //// HELP //// ////////////// void MainWindow::showHelp( const std::string& file_name ) { - const std::string link = "https://github.com/elB4RTO/LogDoctor/tree/main/installation_stuff/logdocdata/help/"; + bool fallback = false; + const QString link = "https://github.com/elB4RTO/LogDoctor/tree/main/installation_stuff/logdocdata/help/"; const std::string path = this->logdoc_path+"/help/"+this->language+"/"+file_name+".html"; if ( IOutils::exists( path ) ) { if ( IOutils::isFile( path ) ) { @@ -1916,15 +1833,32 @@ void MainWindow::showHelp( const std::string& file_name ) } } else { // resource not readable - DialogSec::errHelpNotReadable( QString::fromStdString( link ) ); + DialogSec::errHelpNotReadable( link ); + fallback = true; } } else { // resource is not a file - DialogSec::errHelpFailed( QString::fromStdString( link ), DialogSec::tr("unrecognized entry") ); + DialogSec::errHelpFailed( link, DialogSec::tr("Unrecognized entry") ); + fallback = true; } } else { // resource not found - DialogSec::errHelpNotFound( QString::fromStdString( link ) ); + DialogSec::errHelpNotFound( link ); + fallback = true; + } + if ( fallback ) { + // help file not found for the current locale, fallback to the default version + delete this->craphelp; + this->craphelp = new Craphelp(); + this->craphelp->helpLogsFormatDefault( + file_name, + this->TB.getFont(), + this->TB.getColorSchemeID() ); + if ( this->isMaximized() ) { + this->craphelp->showMaximized(); + } else { + this->craphelp->show(); + } } } @@ -2023,19 +1957,10 @@ void MainWindow::menu_actionBlockNote_triggered() void MainWindow::menu_actionInfos_triggered() { - std::string version_ = std::to_string( this->version ); - size_t cut = version_.find('.'); - if ( cut == std::string::npos ) { - cut = version_.find(','); - if ( cut == std::string::npos ) { - cut = version_.size()-3; - } - } - version_ = version_.substr( 0, cut+3 ); delete this->crapinfo; this->crapinfo = new Crapinfo( this->window_theme_id, - QString::fromStdString( version_ ), + QString::number( this->version ), QString::fromStdString( this->resolvePath( "./" ) ), QString::fromStdString( this->configs_path ), QString::fromStdString( this->logdoc_path ) ); @@ -2372,13 +2297,13 @@ void MainWindow::checkMakeStats_Makable() // switch to apache web server void MainWindow::on_button_LogFiles_Apache_clicked() { - if ( this->craplog.getCurrentWSID() != 11 ) { + if ( this->craplog.getCurrentWSID() != this->APACHE_ID ) { // flat/unflat this->ui->button_LogFiles_Apache->setFlat( false ); this->ui->button_LogFiles_Nginx->setFlat( true ); this->ui->button_LogFiles_Iis->setFlat( true ); // set the WebServer - this->craplog.setCurrentWSID( 11 ); + this->craplog.setCurrentWSID( this->APACHE_ID ); // reset the log files viewer { QString rich_text; @@ -2393,13 +2318,13 @@ void MainWindow::on_button_LogFiles_Apache_clicked() // switch to nginx web server void MainWindow::on_button_LogFiles_Nginx_clicked() { - if ( this->craplog.getCurrentWSID() != 12 ) { + if ( this->craplog.getCurrentWSID() != this->NGINX_ID ) { // flat/unflat this->ui->button_LogFiles_Nginx->setFlat( false ); this->ui->button_LogFiles_Apache->setFlat( true ); this->ui->button_LogFiles_Iis->setFlat( true ); // set the WebServer - this->craplog.setCurrentWSID( 12 ); + this->craplog.setCurrentWSID( this->NGINX_ID ); // reset the log files viewer { QString rich_text; @@ -2414,13 +2339,13 @@ void MainWindow::on_button_LogFiles_Nginx_clicked() // switch to iis web server void MainWindow::on_button_LogFiles_Iis_clicked() { - if ( this->craplog.getCurrentWSID() != 13 ) { + if ( this->craplog.getCurrentWSID() != this->IIS_ID ) { // flat/unflat this->ui->button_LogFiles_Iis->setFlat( false ); this->ui->button_LogFiles_Apache->setFlat( true ); this->ui->button_LogFiles_Nginx->setFlat( true ); // set the WebServer - this->craplog.setCurrentWSID( 13 ); + this->craplog.setCurrentWSID( this->IIS_ID ); // reset the log files viewer { QString rich_text; @@ -2436,27 +2361,25 @@ void MainWindow::on_button_LogFiles_Iis_clicked() // refresh the log files list void MainWindow::on_button_LogFiles_RefreshList_clicked() { - // clear the current tree - this->ui->listLogFiles->clear(); - this->ui->checkBox_LogFiles_CheckAll->setCheckState( Qt::CheckState::Unchecked ); - // disable elements - this->ui->button_LogFiles_RefreshList->setEnabled( false ); - this->ui->button_LogFiles_ViewFile->setEnabled( false ); - this->ui->button_LogFiles_Apache->setEnabled( false ); - this->ui->button_LogFiles_Nginx->setEnabled( false ); - this->ui->button_LogFiles_Iis->setEnabled( false ); - // start refreshing as thread - this->refreshing_list = true; - delete this->craplog_timer; - this->craplog_timer = new QTimer(this); - this->craplog_timer->setSingleShot( true ); - connect(this->craplog_timer, &QTimer::timeout, this, &MainWindow::refreshLogsList); - this->craplog_timer->start(250); - // periodically check if thread finished - delete this->waiter_timer; - this->waiter_timer = new QTimer(this); - connect(this->waiter_timer, &QTimer::timeout, this, &MainWindow::checkRefreshFinished); - this->waiter_timer->start(250); + if ( ! this->refreshing_list ) { + this->refreshing_list = true; + // clear the current tree + this->ui->listLogFiles->clear(); + this->ui->checkBox_LogFiles_CheckAll->setCheckState( Qt::CheckState::Unchecked ); + // disable elements + this->ui->button_LogFiles_RefreshList->setEnabled( false ); + this->ui->button_LogFiles_ViewFile->setEnabled( false ); + this->ui->button_LogFiles_Apache->setEnabled( false ); + this->ui->button_LogFiles_Nginx->setEnabled( false ); + this->ui->button_LogFiles_Iis->setEnabled( false ); + // start refreshing as thread + delete this->waiter_timer; + this->waiter_timer = new QTimer(this); + this->waiter_timer->setSingleShot( true ); + connect( this->waiter_timer, &QTimer::timeout, + this, &MainWindow::refreshLogsList); + this->waiter_timer->start(250); + } } void MainWindow::refreshLogsList() @@ -2488,7 +2411,7 @@ void MainWindow::refreshLogsList() // set the name item->setText( 0, log_file.name ); // set the size - item->setText( 1, this->printableSize( log_file.size ) ); + item->setText( 1, PrintSec::printableSize( log_file.size ) ); item->setFont( 1, this->FONTS.at("main_italic") ); // append the item (on top, forced) item->setCheckState(0, Qt::CheckState::Unchecked ); @@ -2502,19 +2425,13 @@ void MainWindow::refreshLogsList() this->ui->checkBox_LogFiles_CheckAll->setCheckState( Qt::CheckState::Unchecked ); this->ui->checkBox_LogFiles_CheckAll->setEnabled( false ); } - refreshing_list = false; -} -void MainWindow::checkRefreshFinished() -{ - if ( ! this->refreshing_list ) { - this->waiter_timer->stop(); - // back to normal state - this->ui->button_LogFiles_RefreshList->setEnabled( true ); - this->ui->button_LogFiles_ViewFile->setEnabled( true ); - this->ui->button_LogFiles_Apache->setEnabled( true ); - this->ui->button_LogFiles_Nginx->setEnabled( true ); - this->ui->button_LogFiles_Iis->setEnabled( true ); - } + // refresh finished, back to normal state + this->ui->button_LogFiles_RefreshList->setEnabled( true ); + this->ui->button_LogFiles_ViewFile->setEnabled( true ); + this->ui->button_LogFiles_Apache->setEnabled( true ); + this->ui->button_LogFiles_Nginx->setEnabled( true ); + this->ui->button_LogFiles_Iis->setEnabled( true ); + this->refreshing_list = false; } @@ -2559,32 +2476,19 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked() // check the size if ( proceed ) { - const long warn_size = this->craplog.getWarningSize(); - if ( warn_size >= 0 ) { + const unsigned warn_size = this->craplog.getWarningSize(); + if ( warn_size > 0 ) { if ( item.size > warn_size ) { // exceeds the warning size - QString size_str, msg = item.name; + QString msg = item.name; if ( this->dialogs_level >= 1 ) { - std::string size_sfx=" B"; - float size = (float)item.size; - if (size > 1024) { - size /= 1024; size_sfx = " KiB"; - if (size > 1024) { - size /= 1024; size_sfx = " MiB"; - } - } - size_str = std::to_string(size).substr(0,std::to_string(size).size()-3).c_str(); - msg += QString("\n\n%1:\n%2%3").arg( DialogSec::tr("Size of the file"), size_str, size_sfx.c_str() ); + msg += QString("\n\n%1:\n%2").arg( + DialogSec::tr("Size of the file"), + PrintSec::printableSize( item.size ) ); if ( this->dialogs_level == 2 ) { - size = (float)warn_size; - if (size > 1024) { - size /= 1024; size_sfx = " KiB"; - if (size > 1024) { - size /= 1024; size_sfx = " MiB"; - } - } - size_str = std::to_string(size).substr(0,std::to_string(size).size()-3).c_str(); - msg += QString("\n\n%1:\n%2%3").arg( DialogSec::tr("Warning size parameter"), size_str, size_sfx.c_str() ); + msg += QString("\n\n%1:\n%2").arg( + DialogSec::tr("Warning size parameter"), + PrintSec::printableSize( warn_size ) ); } } // ask the user what to do @@ -2744,26 +2648,20 @@ void MainWindow::on_button_MakeStats_Start_clicked() // periodically update perfs delete this->waiter_timer; this->waiter_timer = new QTimer(this); - connect(this->waiter_timer, &QTimer::timeout, this, &MainWindow::checkCraplogFinished); - // run craplog as thread - this->waiter_timer_start = std::chrono::system_clock::now(); - delete this->craplog_timer; - this->craplog_timer = new QTimer(this); - this->craplog_timer->setSingleShot( true ); - connect(this->craplog_timer, &QTimer::timeout, this, &MainWindow::runCraplog); + this->waiter_timer->setInterval(250); + this->waiter_timer->setTimerType( Qt::PreciseTimer ); + connect( this->waiter_timer, &QTimer::timeout, + this, &MainWindow::updatePerfsLabels ); // start processing - this->waiter_timer->start(250); - this->craplog_timer->start(100); + this->waiter_timer_start = std::chrono::system_clock::now(); + this->waiter_timer->start(); + emit runCraplog(); } else { this->craplogFinished(); } } } } -void MainWindow::runCraplog() -{ - this->craplog.run(); -} void MainWindow::resetPerfsLabels() { @@ -2778,42 +2676,24 @@ void MainWindow::resetPerfsLabels() void MainWindow::updatePerfsLabels() { // update values - unsigned size; - long secs; - // size and lines - if ( this->craplog.isParsing() ) { - this->craplog.collectPerfData(); + if ( this->craplog.isParsing() || this->force_updating_labels ) { + const unsigned size = this->craplog.getParsedSize(); + this->ui->label_MakeStats_Size->setText( PrintSec::printableSize( size ) ); + this->ui->label_MakeStats_Lines->setText( QString::number( this->craplog.getParsedLines() ) ); + this->ui->label_MakeStats_Speed->setText( this->craplog.getParsingSpeed() ); } - size = this->craplog.getTotalSize(); - //size = this->craplog.getParsedSize(); - this->ui->label_MakeStats_Size->setText( this->printableSize( size ) ); - this->ui->label_MakeStats_Lines->setText( QString::fromStdString(std::to_string(this->craplog.getParsedLines())) ); // time and speed this->waiter_timer_elapsed = std::chrono::duration_cast( this->waiter_timer_start - std::chrono::system_clock::now() ); - size = this->craplog.getPerfSize(); - secs = this->waiter_timer_elapsed.count() / -1000000000; - this->ui->label_MakeStats_Time->setText( this->printableTime( secs )); - this->ui->label_MakeStats_Speed->setText( this->printableSpeed( size, secs )); -} - -void MainWindow::checkCraplogFinished() -{ - // craplog is running as thread, update the values meanwhile - this->updatePerfsLabels(); - // check if Craplog has finished working - if ( ! this->craplog.isWorking() ) { - this->waiter_timer->stop(); - this->craplogFinished(); - } + const unsigned secs = this->waiter_timer_elapsed.count() / -1000000000; + this->ui->label_MakeStats_Time->setText( PrintSec::printableTime( secs )); } void MainWindow::craplogStarted() { // reset perfs this->resetPerfsLabels(); - this->craplog.logOps.resetPerfData(); // disable the LogFiles section this->ui->stacked_Logs_Pages->setEnabled(false); // disable things which needs database access @@ -2831,36 +2711,31 @@ void MainWindow::craplogStarted() void MainWindow::craplogFinished() { - // update the perf data one last time, just in case - this->updatePerfsLabels(); - this->craplog.makeChart( - this->CHARTS_THEMES.at( this->charts_theme_id ), this->FONTS, - this->ui->chart_MakeStats_Size ); - if ( this->craplog.editedDatabase() ) { - // craplog succeeded - this->db_edited = true; + if ( this->waiter_timer->isActive() ) { + this->waiter_timer->stop(); + this->force_updating_labels = true; + this->updatePerfsLabels(); + this->force_updating_labels = false; + // draw the chart + this->craplog.makeChart( + this->CHARTS_THEMES.at( this->charts_theme_id ), this->FONTS, + this->ui->chart_MakeStats_Size ); + this->db_edited = this->craplog.editedDatabase(); + // refresh the logs section + delete this->waiter_timer; + this->waiter_timer = new QTimer(this); + this->waiter_timer->setSingleShot( true ); + connect(this->waiter_timer, &QTimer::timeout, this, &MainWindow::afterCraplogFinished); + this->waiter_timer->start(1000); + } else { + this->afterCraplogFinished(); } - if ( this->craplog.getTotalSize() == 0 ) { - // no data - this->resetPerfsLabels(); - } - // clean up temp vars - this->craplog.clearDataCollection(); - this->craplog.logOps.resetPerfData(); - // refresh the logs section - delete this->craplog_timer; - this->craplog_timer = new QTimer(this); - this->craplog_timer->setSingleShot( true ); - connect(this->craplog_timer, &QTimer::timeout, this, &MainWindow::afterCraplogFinished); - this->craplog_timer->start(1000); } void MainWindow::afterCraplogFinished() { - // refresh the logs list - this->on_button_LogFiles_RefreshList_clicked(); // enable the LogFiles section - this->ui->stacked_Logs_Pages->setEnabled( true ); + this->ui->stacked_Logs_Pages->setEnabled( true ); // enable all labels (needed only the first time each session) this->ui->icon_MakeStats_Size->setEnabled( true ); this->ui->icon_MakeStats_Lines->setEnabled( true ); @@ -2868,8 +2743,12 @@ void MainWindow::afterCraplogFinished() this->ui->icon_MakeStats_Speed->setEnabled( true ); // enable back this->setDbWorkingState( false ); - // get a fresh collection of available stats dates - this->refreshStatsDates(); + if ( this->craplog.editedDatabase() ) { + // refresh the logs list + this->on_button_LogFiles_RefreshList_clicked(); + // get a fresh collection of available stats dates + this->refreshStatsDates(); + } } @@ -3729,78 +3608,73 @@ void MainWindow::drawStatsRelat() //////////////// //// GLOBAL //// -// + void MainWindow::drawStatsGlobals() { - if ( this->dbUsable() ) { - std::vector> recur_list; - std::vector> traffic_list; - std::vector> perf_list; - std::vector work_list; + std::vector> recur_list; + std::vector> traffic_list; + std::vector> perf_list; + std::vector work_list; - const bool result = this->crapview.calcGlobals( - recur_list, traffic_list, perf_list, work_list, - this->glob_ws ); + const bool result = this->crapview.calcGlobals( + recur_list, traffic_list, perf_list, work_list, + this->glob_ws ); - if ( result ) { - this->ui->label_StatsGlob_Recur_Protocol_String->setText( std::get<0>( recur_list.at(0) ) ); - this->ui->label_StatsGlob_Recur_Protocol_Count->setText( std::get<1>( recur_list.at(0) ) ); - this->ui->label_StatsGlob_Recur_Method_String->setText( std::get<0>( recur_list.at(1) ) ); - this->ui->label_StatsGlob_Recur_Method_Count->setText( std::get<1>( recur_list.at(1) ) ); - this->ui->label_StatsGlob_Recur_URI_String->setText( std::get<0>( recur_list.at(2) ) ); - this->ui->label_StatsGlob_Recur_URI_Count->setText( std::get<1>( recur_list.at(2) ) ); - this->ui->label_StatsGlob_Recur_UserAgent_String->setText( std::get<0>( recur_list.at(3) ) ); - this->ui->label_StatsGlob_Recur_UserAgent_Count->setText( std::get<1>( recur_list.at(3) ) ); + if ( result ) { + this->ui->label_StatsGlob_Recur_Protocol_String->setText( std::get<0>( recur_list.at(0) ) ); + this->ui->label_StatsGlob_Recur_Protocol_Count->setText( std::get<1>( recur_list.at(0) ) ); + this->ui->label_StatsGlob_Recur_Method_String->setText( std::get<0>( recur_list.at(1) ) ); + this->ui->label_StatsGlob_Recur_Method_Count->setText( std::get<1>( recur_list.at(1) ) ); + this->ui->label_StatsGlob_Recur_URI_String->setText( std::get<0>( recur_list.at(2) ) ); + this->ui->label_StatsGlob_Recur_URI_Count->setText( std::get<1>( recur_list.at(2) ) ); + this->ui->label_StatsGlob_Recur_UserAgent_String->setText( std::get<0>( recur_list.at(3) ) ); + this->ui->label_StatsGlob_Recur_UserAgent_Count->setText( std::get<1>( recur_list.at(3) ) ); - this->ui->label_StatsGlob_Traffic_Date_String->setText( std::get<0>( traffic_list.at(0) ) ); - this->ui->label_StatsGlob_Traffic_Date_Count->setText( std::get<1>( traffic_list.at(0) ) ); - this->ui->label_StatsGlob_Traffic_Day_String->setText( std::get<0>( traffic_list.at(1) ) ); - this->ui->label_StatsGlob_Traffic_Day_Count->setText( std::get<1>( traffic_list.at(1) ) ); - this->ui->label_StatsGlob_Traffic_Hour_String->setText( std::get<0>( traffic_list.at(2) ) ); - this->ui->label_StatsGlob_Traffic_Hour_Count->setText( std::get<1>( traffic_list.at(2) ) ); + this->ui->label_StatsGlob_Traffic_Date_String->setText( std::get<0>( traffic_list.at(0) ) ); + this->ui->label_StatsGlob_Traffic_Date_Count->setText( std::get<1>( traffic_list.at(0) ) ); + this->ui->label_StatsGlob_Traffic_Day_String->setText( std::get<0>( traffic_list.at(1) ) ); + this->ui->label_StatsGlob_Traffic_Day_Count->setText( std::get<1>( traffic_list.at(1) ) ); + this->ui->label_StatsGlob_Traffic_Hour_String->setText( std::get<0>( traffic_list.at(2) ) ); + this->ui->label_StatsGlob_Traffic_Hour_Count->setText( std::get<1>( traffic_list.at(2) ) ); - this->ui->label_StatsGlob_Perf_Time_Mean->setText( std::get<0>( perf_list.at(0) ) ); - this->ui->label_StatsGlob_Perf_Time_Max->setText( std::get<1>( perf_list.at(0) ) ); - this->ui->label_StatsGlob_Perf_Sent_Mean->setText( std::get<0>( perf_list.at(1) ) ); - this->ui->label_StatsGlob_Perf_Sent_Max->setText( std::get<1>( perf_list.at(1) ) ); - this->ui->label_StatsGlob_Perf_Received_Mean->setText( std::get<0>( perf_list.at(2) ) ); - this->ui->label_StatsGlob_Perf_Received_Max->setText( std::get<1>( perf_list.at(2) ) ); + this->ui->label_StatsGlob_Perf_Time_Mean->setText( std::get<0>( perf_list.at(0) ) ); + this->ui->label_StatsGlob_Perf_Time_Max->setText( std::get<1>( perf_list.at(0) ) ); + this->ui->label_StatsGlob_Perf_Sent_Mean->setText( std::get<0>( perf_list.at(1) ) ); + this->ui->label_StatsGlob_Perf_Sent_Max->setText( std::get<1>( perf_list.at(1) ) ); + this->ui->label_StatsGlob_Perf_Received_Mean->setText( std::get<0>( perf_list.at(2) ) ); + this->ui->label_StatsGlob_Perf_Received_Max->setText( std::get<1>( perf_list.at(2) ) ); - this->ui->label_StatsGlob_Work_Req_Count->setText( work_list.at(0) ); - this->ui->label_StatsGlob_Work_Time_Count->setText( work_list.at(1) ); - this->ui->label_StatsGlob_Work_Sent_Count->setText( work_list.at(2) ); + this->ui->label_StatsGlob_Work_Req_Count->setText( work_list.at(0) ); + this->ui->label_StatsGlob_Work_Time_Count->setText( work_list.at(1) ); + this->ui->label_StatsGlob_Work_Sent_Count->setText( work_list.at(2) ); - if ( this->glob_ws == "apache" ) { - if ( this->ui->button_StatsGlob_Apache->isFlat() ) { - // un-flat - this->ui->button_StatsGlob_Apache->setFlat( false ); - this->ui->button_StatsGlob_Nginx->setFlat( true ); - this->ui->button_StatsGlob_Iis->setFlat( true ); - } - } else if ( this->glob_ws == "nginx" ) { - if ( this->ui->button_StatsGlob_Nginx->isFlat() ) { - // un-flat - this->ui->button_StatsGlob_Nginx->setFlat( false ); - this->ui->button_StatsGlob_Apache->setFlat( true ); - this->ui->button_StatsGlob_Iis->setFlat( true ); - } - } else if ( this->glob_ws == "iis" ) { - if ( this->ui->button_StatsGlob_Iis->isFlat() ) { - // un-flat - this->ui->button_StatsGlob_Iis->setFlat( false ); - this->ui->button_StatsGlob_Apache->setFlat( true ); - this->ui->button_StatsGlob_Nginx->setFlat( true ); - } + if ( this->glob_ws == "apache" ) { + if ( this->ui->button_StatsGlob_Apache->isFlat() ) { + // un-flat + this->ui->button_StatsGlob_Apache->setFlat( false ); + this->ui->button_StatsGlob_Nginx->setFlat( true ); + this->ui->button_StatsGlob_Iis->setFlat( true ); + } + } else if ( this->glob_ws == "nginx" ) { + if ( this->ui->button_StatsGlob_Nginx->isFlat() ) { + // un-flat + this->ui->button_StatsGlob_Nginx->setFlat( false ); + this->ui->button_StatsGlob_Apache->setFlat( true ); + this->ui->button_StatsGlob_Iis->setFlat( true ); + } + } else if ( this->glob_ws == "iis" ) { + if ( this->ui->button_StatsGlob_Iis->isFlat() ) { + // un-flat + this->ui->button_StatsGlob_Iis->setFlat( false ); + this->ui->button_StatsGlob_Apache->setFlat( true ); + this->ui->button_StatsGlob_Nginx->setFlat( true ); } - - } else { - this->resetStatsGlob(); } } else { this->resetStatsGlob(); } - // restore + // restore db state this->setDbWorkingState( false ); } @@ -4966,6 +4840,9 @@ 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() == this->IIS_ID ) { + this->on_button_LogFiles_RefreshList_clicked(); + } } } } @@ -4980,6 +4857,9 @@ void MainWindow::on_radio_ConfIis_Format_NCSA_toggled(bool checked) this->ui->inLine_ConfIis_Format_String->setText( QString::fromStdString( this->craplog.getLogsFormatString( this->IIS_ID ) ) ); this->ui->inLine_ConfIis_Format_String->setEnabled( false ); this->ui->button_ConfIis_Format_Save->setEnabled( false ); + if ( this->craplog.getCurrentWSID() == this->IIS_ID ) { + this->on_button_LogFiles_RefreshList_clicked(); + } } } } @@ -4994,6 +4874,9 @@ void MainWindow::on_radio_ConfIis_Format_IIS_toggled(bool checked) this->ui->inLine_ConfIis_Format_String->setText( QString::fromStdString( this->craplog.getLogsFormatString( this->IIS_ID ) ) ); this->ui->inLine_ConfIis_Format_String->setEnabled( false ); this->ui->button_ConfIis_Format_Save->setEnabled( false ); + if ( this->craplog.getCurrentWSID() == this->IIS_ID ) { + this->on_button_LogFiles_RefreshList_clicked(); + } } } } diff --git a/logdoctor/mainwindow.h b/logdoctor/mainwindow.h index 5d57f32e..d09546bd 100644 --- a/logdoctor/mainwindow.h +++ b/logdoctor/mainwindow.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "utilities/strings.h" @@ -47,6 +48,11 @@ public: ~MainWindow(); +signals: + + void runCraplog(); + + private slots: /////////////////// @@ -87,20 +93,18 @@ private slots: ///////////////// //// CRAPLOG //// + void refreshLogsList(); // CUSTOM + + void updatePerfsLabels(); // CUSTOM + + void craplogFinished(); // CUSTOM + + void afterCraplogFinished(); // CUSTOM + void on_button_Logs_Down_clicked(); void on_button_Logs_Up_clicked(); - void refreshLogsList(); // CUSTOM - - void checkRefreshFinished(); // CUSTOM - - void runCraplog(); // CUSTOM - - void checkCraplogFinished(); // CUSTOM - - void afterCraplogFinished(); // CUSTOM - void on_button_LogFiles_ViewFile_clicked(); void on_checkBox_LogFiles_CheckAll_stateChanged(int arg1); @@ -679,14 +683,9 @@ private: //// GENERAL USE //// ///////////////////// - //! Printable size, including suffix - const QString printableSize( const int bytes ) const; - - //! Printable time, including suffix(es) - const QString printableTime( const int seconds ) const; - - //! Printable speed, namely printable size over printable time - const QString printableSpeed( const int bytes, const int secs ) const; + QTimer* waiter_timer; + std::chrono::system_clock::time_point waiter_timer_start; + std::chrono::system_clock::duration waiter_timer_elapsed; //! Resolves the given path and returns the canonical path @@ -749,18 +748,8 @@ private: Craplog craplog; - QTimer* craplog_timer = new QTimer(); - QTimer* waiter_timer; - - std::chrono::system_clock::time_point waiter_timer_start; - std::chrono::system_clock::duration waiter_timer_elapsed; - - //! The logs parser started working void craplogStarted(); - //! The logs parser finished working - void craplogFinished(); - void checkMakeStats_Makable(); @@ -785,11 +774,9 @@ private: ////////////////////////// //// LOGS PERFORMANCE //// - void updatePerfsLabels(); // CUSTOM + void resetPerfsLabels(); - /*void update_MakeStats_graphs(); // CUSTOM*/ - - void resetPerfsLabels(); // CUSTOM + bool force_updating_labels = false; ////////////////// From e8eafe7b4f469f7ff034b1233d3fea454db09ac6 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:46:52 +0100 Subject: [PATCH 29/36] Updated UI --- logdoctor/mainwindow.ui | 68 +++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/logdoctor/mainwindow.ui b/logdoctor/mainwindow.ui index 3c42e50d..927e757d 100644 --- a/logdoctor/mainwindow.ui +++ b/logdoctor/mainwindow.ui @@ -208,7 +208,7 @@ - 0 + 1 @@ -1613,6 +1613,9 @@ li.checked::marker { content: "\2612"; } 13 + + - + @@ -1634,6 +1637,9 @@ li.checked::marker { content: "\2612"; } 13 + + - +
    @@ -1655,6 +1661,9 @@ li.checked::marker { content: "\2612"; } 13 + + - + @@ -1685,6 +1694,9 @@ li.checked::marker { content: "\2612"; } 13 + + * + @@ -2109,6 +2121,9 @@ li.checked::marker { content: "\2612"; } 13 + + - + @@ -2130,6 +2145,9 @@ li.checked::marker { content: "\2612"; } 13 + + - + @@ -2151,6 +2169,9 @@ li.checked::marker { content: "\2612"; } 13 + + - + @@ -3153,6 +3174,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3174,6 +3198,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3225,6 +3252,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3378,6 +3408,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3405,6 +3438,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3441,6 +3477,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3465,6 +3504,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3501,6 +3543,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3522,6 +3567,9 @@ Use '!', '=','<' or '>' to declare what to use 13 + + - + @@ -3887,7 +3935,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use Year - Year + - @@ -3914,7 +3962,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use Month - Month + - @@ -3941,7 +3989,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use Day - Day + - @@ -3995,7 +4043,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use Year - Year + - @@ -4022,7 +4070,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use Month - Month + - @@ -4049,7 +4097,7 @@ With numbers, use '!', '=','<' or '>' to declare what to use Day - Day + - @@ -8372,7 +8420,7 @@ Any field not considered by LogDoctor will appear as 'DISCARDED' 0 0 - 62 + 98 54 @@ -9376,7 +9424,7 @@ Any field not considered by LogDoctor will appear as 'DISCARDED' 0 0 - 62 + 98 54 @@ -10458,7 +10506,7 @@ Any field not considered by LogDoctor will appear as 'DISCARDED' 0 0 - 62 + 98 54 From 06ea08b82939197375112645c0a8e5e923b421a8 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:48:46 +0100 Subject: [PATCH 30/36] Updated CMakeLists.txt --- logdoctor/CMakeLists.txt | 6 ++++-- version.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/logdoctor/CMakeLists.txt b/logdoctor/CMakeLists.txt index e68a1820..d6e71c75 100644 --- a/logdoctor/CMakeLists.txt +++ b/logdoctor/CMakeLists.txt @@ -39,6 +39,8 @@ set(PROJECT_SOURCES utilities/gzip.cpp utilities/io.h utilities/io.cpp + utilities/printables.h + utilities/printables.cpp utilities/result.h utilities/result.cpp utilities/rtf.h @@ -84,8 +86,8 @@ set(PROJECT_SOURCES modules/craplog/modules/logs.cpp modules/craplog/modules/sha256.h modules/craplog/modules/sha256.cpp - modules/craplog/modules/store.h - modules/craplog/modules/store.cpp + modules/craplog/modules/worker.h + modules/craplog/modules/worker.cpp modules/crapview/crapview.h modules/crapview/crapview.cpp diff --git a/version.txt b/version.txt index d1442284..5b9cf0a8 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -.:!¦version¦!:.2.01.:!¦version¦!:. +.:!¦version¦!:.2.03.:!¦version¦!:. From f895c7475cbd4f7ad6cf079061988eb493e1fdcb Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 02:51:02 +0100 Subject: [PATCH 31/36] Version update Version 2.03 --- logdoctor/CMakeLists.txt | 2 +- logdoctor/mainwindow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/logdoctor/CMakeLists.txt b/logdoctor/CMakeLists.txt index d6e71c75..04f9c1a8 100644 --- a/logdoctor/CMakeLists.txt +++ b/logdoctor/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -project(LogDoctor VERSION 2.02 LANGUAGES CXX) +project(LogDoctor VERSION 2.03 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/logdoctor/mainwindow.h b/logdoctor/mainwindow.h index d09546bd..c3e60ae6 100644 --- a/logdoctor/mainwindow.h +++ b/logdoctor/mainwindow.h @@ -520,7 +520,7 @@ private: Ui::MainWindow *ui; // current version of LogDoctor - const float version = 2.02; + const float version = 2.03; // web servers ID constants const unsigned int APACHE_ID=11, NGINX_ID=12, IIS_ID=13; From 8366e8e5e446b20f19b42583817c06149a538169 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 15:34:56 +0100 Subject: [PATCH 32/36] Updated translation files --- logdoctor/translations/LogDoctor_en_GB.ts | 8 +- logdoctor/translations/LogDoctor_es_ES.ts | 808 +++++++++++----------- logdoctor/translations/LogDoctor_fr_FR.ts | 808 +++++++++++----------- logdoctor/translations/LogDoctor_it_IT.ts | 8 +- logdoctor/translations/LogDoctor_ja_JP.ts | 8 +- logdoctor/translations/LogDoctor_pt_BR.ts | 806 +++++++++++---------- 6 files changed, 1214 insertions(+), 1232 deletions(-) diff --git a/logdoctor/translations/LogDoctor_en_GB.ts b/logdoctor/translations/LogDoctor_en_GB.ts index 10eabfc8..94869073 100644 --- a/logdoctor/translations/LogDoctor_en_GB.ts +++ b/logdoctor/translations/LogDoctor_en_GB.ts @@ -228,10 +228,6 @@ Please visit LogDoctor's git repository and follow the instruction about ho Failed to update the backups Failed to update the backups - - unrecognized entry - unrecognized entry - Failed to read gzipped file Failed to read gzipped file @@ -674,6 +670,10 @@ please follow the instruction on the repository page Failed to create the directory Failed to create the directory + + Unrecognized entry + Unrecognized entry +
    MainWindow diff --git a/logdoctor/translations/LogDoctor_es_ES.ts b/logdoctor/translations/LogDoctor_es_ES.ts index ee13f0f3..9c319fa2 100644 --- a/logdoctor/translations/LogDoctor_es_ES.ts +++ b/logdoctor/translations/LogDoctor_es_ES.ts @@ -80,49 +80,49 @@ Comprobando para actualizaciones - + Failed to establish a connection Error al establecer una conexión - + Connection error, please try again later Error de conexión, inténtalo de nuevo más tarde - + Connection timed out Tiempo de conexión agotado - + New version available Nueva versión disponible - + A new version is available! Please visit LogDoctor's git repository and follow the instruction about how to update ¡Una nueva versión es disponible! Visite el repositorio git de LogDoctor y siga las instrucciones sobre cómo actualizar - + No update found Ninguna actualización encontrada - + LogDoctor is up-to-date LogDoctor está actualizado - + :/ :/ - + You're running a version from the future! Your version is beyond the current upstream version Are you running the original LogDoctor? @@ -133,33 +133,33 @@ Tu versión es mayor de la versión online Visita el repositorio de LogDoctor y descargalo una otra vez - + Version check failed Comprobación de la versión fallida - + An error occured while parsing: initial version mark not found Ocurrió un error al analizar: marcador inicial no encontrado - + An error occured while parsing: final version mark not found Ocurrió un error al analizar: marcador final no encontrado - + An error occured while parsing: malformed version Ocurrió un error al analizar: versión mal formada - + An error occured while comparing: malformed upstream version Ocurrió un error al comparar: @@ -236,66 +236,66 @@ versión online mal formada DialogSec - + An error occured while reading the configuration file Error durante la lectura del archivo de configuración - + One of the lists has an invalid item Una de las listas tiene un elemento no válido - + An error occured while parsing configuration file's data Error durante el análisis del archivo de configuración - - + + Failed to create the configuration file's directory Error al crear la carpeta del archivo de configuración - + An error occured while writing the configuration file Error al escribir el archivo de configuración - + An error occured while preparing the configuration file's data Error al preparar los datos de los archivos de configuración - - + + Failed to create the database backups' directory Error al crear el directorio de copias de seguridad del database - + Failed to copy the database file Error al copiar el archivo del database - - + + Failed to update the backups Error al actualizar las copias de seguridad - - + + Failed to create the directory Error al crear la carpeta - - unrecognized entry - entrada no reconocida + + Unrecognized entry + Entrada no reconocida - + Failed to read gzipped file Lectura del archivo gzip no conseguida @@ -625,8 +625,8 @@ Corrígela y vuelve a intentarlo El archivo está vacío - + An error accured while reading the file Error en la lectura del archivo @@ -819,7 +819,7 @@ por favor notifica este problema Saltado - + @@ -835,43 +835,43 @@ por favor notifica este problema Se pueden descargar recursos adicionales desde el repositorio - - - + + + An error occured while parsing the format string Error al analizar la cadena de formato - - + + Size of the file Tamaño del archivo - - + + Warning size parameter Parámetro de advertencia del tamaño - + An error accured while reading the gzipped file Error en la lectura del archivo gzip - + Something failed while handling the file Algo falló al manejar el archivo - + An error occured while working on the database Error durante el trabajo en el database - + An error occured while working on the database Aborting @@ -884,19 +884,19 @@ Anulado MainWindow - + Parse logs from the Apache2 web server Analizar los registros del servidor web Apache2 - + Parse logs from the Nginx web server Analizar los registros del servidor web Nginx - + Parse logs from the Microsoft IIS web server Analizar los registros del servidor web Microsoft IIS @@ -957,8 +957,8 @@ Anulado - - + + Draw the chart Dibujar el gráfico @@ -969,46 +969,40 @@ Anulado - - - - + + + + Select a Web Server Seleccione un Web Server - - - - - - - + + + + + Year Año - - - - - - - + + + + + Month Mes - - - - - - - + + + + + Day Día @@ -1018,225 +1012,225 @@ Anulado Hora - + Update the database with current Warning States Actualice el database con los estados de advertencia actuales - + Log line marked as Warning Línea de registro marcada como Advertencia - + Date when the request arrived (YYYY-MM-DD) Fecha en que llegó la solicitud (AAAA-MM-DD) - - + + Time when the request arrived (hh:mm:ss) Hora en que llegó la solicitud (hh:mm:ss) - - - - + + + + Protocol of the request Protocolo de la solicitud - - - - + + + + Method of the request Método de la solicitud - - - - + + + + URI of the requested page URL de la página solicitada - - - - + + + + Response code from the server Código de respuesta del servidor - - + + IP address of the Client which made the request Dirección IP del cliente que realizó la solicitud - + Size ib Bytes of the request, usually includes header and data Tamaño en Bytes de la solicitud, generalmente incluye el header y los datos - + Size in Bytes of the served content, usually includes header and data Tamaño en Bytes del contenido servido, generalmente incluye el header y los datos - + Protocol: Protocolo: - + Method: Método: - + Response: Respuesta: - + Query: Query: - + URI: URI: - + Filters Filtros - - - - + + + + Query carried along with the URI Query llevada junto con el URI - - + + Cookie used for the request Cookie utilizado para la solicitud - - + + User-agent of the client which made the request User-agent del cliente que realizó la solicitud - + Count Cálculo - - + + The URL which redirected the Client to the requested page La URL que redirigió al Cliente a la página solicitada - + Number of occurrences Numero de incidentes - + Item Artículo - + Value of the field Valor del campo - - + + From: De: - - + + To: A: - - - + + + Field: Campo: - - - + + + Select a log field to view Seleccione un campo de registro para ver - - - + + + Filter: Filtro: - + Protocol Protocolo - + Method Método - + URI URI - + User-agent User-agent - + Most recurrent Más recurrente - + Date ever Fecha de la historia - + Day of the week Día de la semana - + Hour of the day Hora del día - + Most trafficked Más traficado @@ -1246,763 +1240,763 @@ Anulado Seleccione/deseleccione todos los archivios - - + + Time taken Tiempo tomado - - + + Bytes sent Bytes enviados - + Bytes received Bytes recibidos - + Mean/Max performances Desempeño medio/máximo - + Requests received Solicitudes recibidas - + Total work Trabajo total - - + + General General - + General settings Configuración general - + Window Ventana - - - - - - + + + + + + Remember window's position and size Recuerda la posición y el tamaño de la ventana - + Geometry Apariencia - - + + Theme to use for the window Tema a usar para la ventana - - + + Theme Tema - + None (System) Ninguno (Sistema) - - + + Dark Oscuro - + Dialogs Diálogos - + Candy Dulce - + Herb Hierba - + Powder Polvo - + Auto (Default) Auto (Predeterminado) - + Light Claro - + Dialogs level Nivel de diálogo - + Reduced quantity of dialog messages shown Cantidad reducida de mensajes de diálogo mostrados - + Essential Básico - + Normal quantity of dialog messages shown Cantidad normal de mensajes de diálogo mostrados - + Normal Normal - + Explanatory Explicativo - + Logs parser Analizador de registros - + Statistics viewer Visor de estadísticas - + TextBrowser TextBrowser - + Font to use for the Text Browser Font a usar para el Text Browser - + Font Font - + Double-spaced lines Líneas a doble espacio - + Use wide lines Usa líneas anchas - + Define the spacing between lines Definir el espaciado entre líneas - + Lines spacing Espaciado de líneas - + None Ninguno - + Color scheme to use for the Text Browser Combinación de colores a utilizar para el Text Browser - + Color scheme Esquema de colores - + The appearance of the Text Browser with the current settings La apariencia del Text Browser con la configuración actual - - + + Preview Preestreno - + Charts Gráficos - + Default (Light) Predeterminado (Claro) - + Sand Arena - + Cerulean Azul claro - + Theme to use for the Charts Tema a usar para los Gráficos - + Databases Databases - - - - - + + + + + Apply the current path Aplicar la ruta actual - + Path where the logs data collection database is located Ruta donde se encuentra el database de recopilación de datos de registros - + Logs data Datos de registros - - - - - + + + + + The given path doen't exists, or doesn't point to a folder La ruta dada no existe o no apunta a una carpeta - + Path where the used files hashes database is located Ruta donde se encuentra el database de hash de los archivos usados - + Used files Archivos usados - - + + Insert the base path only, file name excluded Inserte solo la ruta base, nombre de archivo excluido - + Path for the database files Ruta de los archivos de el database - - - - + + + + Paths Rutas - + Backup options for the Logs Data database Opciones de copia de seguridad para el database de datos de registros - + Backups Copias de seguridad - + A new backup is made when closing LogDoctor after having succesfully edited the database Se realiza una nueva copia de seguridad al cerrar LogDoctor después de haber editado correctamente el database - + Backup the Logs Data database and keep Haga una copia de seguridad de el database de datos y conserve - + Logs Registros - + Logs related settings Configuración relacionada con los registros - + Defaults Predeterminados - + Default WebServer Servidor Web predeterminado - + Control Controlar - + Options about the log files usage control Opciones sobre el control de uso de archivos de registro - + Usage control Control de uso - + Hide already used files Ocultar archivos ya usados - + Size warnings Advertencias de tamaño - + Warn me when using files with a size exceeding: Avisarme cuando use archivos con un tamaño superior a: - - - + + + Generate a sample log line from the currently saved string, to check if it gets formatted correctly. Any field not considered by LogDoctor will appear as 'DISCARDED' Genere una línea de registro de muestra a partir de la cadena guardada actualmente, para verificar si se formatea correctamente. Cualquier campo no considerado por LogDoctor aparecerá como 'DISCARDED' - + CrissCross CrissCross - + Play CrissCross Jugar a CrissCross - + Snake Snake - + Play Snake Jugar a Snake - - - - - - + + + + + + Apache2 Apache2 - - + + Time taken by the server to serve the content, in milliseconds Tiempo que tarda el servidor en servir el contenido, en milisegundos - - - - + + + + Only use lines in which the field is starting with this string Use solo líneas en las que el campo comience con esta cadena - + Only use lines in which the field is matching this statement. Use '!', '=','<' or '>' to declare what to use Solo use líneas en las que el campo coincida con esta declaración. Use '!', '=', '<' o '>' para declarar qué usar - - - + + + With strings, only the lines in which the field is starting with this string will be used. With numbers, use '!', '=','<' or '>' to declare what to use Con cadenas, solo se utilizarán las líneas en las que el campo comienza con esta cadena. Con números, use '!', '=', '<' o '>' para declarar qué usar - + Remember the window's position and size Recuerda la posición y el tamaño de la ventana - + Remember position and size Recuerda posición y tamaño - + Ash Ceniza - + Icons Iconos - + Define the quantity of dialog mesages shown Definir la cantidad de mensajes de diálogo que se muestran - + Augmented quantity of dialog messages shown Cantidad aumentada de mensajes de diálogo mostrados - + Dialogs from the main processes Diálogos de los principales procesos - + Dialogs emitted when parsing logs Diálogos emitidos al analizar registros - + Dialogs emitted when viewing statistics Diálogos emitidos al visualizar estadísticas - + Configure Apache2 specific options Configurar opciones específicas de Apache2 - - - + + + Logs folder Carpeta de registros - - - + + + Logs format string Cadena de formato de registros - - - + + + Format string Cadena de formato - - - + + + Insert the format string you're using Inserta la cadena de formato que estás usando - - - + + + Apply the current string Aplicar la cadena actual - - - + + + Generate sample Generar muestra - - - + + + Please check the correctness of this line. Fields marked as 'DISCARDED' got parsed correctly, but are not considered by LogDoctor Por favor, compruebe la exactitud de esta línea. Los campos marcados como 'DISCARDED' se analizaron correctamente, pero LogDoctor no los tiene en cuenta - - - + + + Open an help window Abrir una ventana de ayuda - - - + + + Help Ayuda - - - + + + Warnlists Warnlists - - - - - - + + + + + + Select a log field Seleccione un campo de registro - - - + + + Use warnlist for this field Usar Lista de Advertencia para este campo - + Add the current line to the list Agregar la línea actual a la lista - + Remove the selected item from the list Eliminar el elemento seleccionado de la lista - - - - - - - - - - - - + + + + + + + + + + + + Move the selected item down Mover el elemento seleccionado hacia abajo - - - + + + Blacklists Blacklists - - - + + + Use blacklist for this field Usar Lista Negra para este campo - - - - - + + + + + Add line Añadir línea - - - - - + + + + + Remove selection Eliminar selección - - - - - - + + + + + + Nginx Nginx - + Configure Nginx specific options Configurar opciones específicas de Nginx - - - - - - + + + + + + IIS IIS - - - + + + Format Formato - + Configure IIS specific options Configurar opciones específicas de IIS - + Language Langue - + Utilities Utilidades - + Tools Instrumentos - + Games Juegos - + Check updates Revisa actualizaciones - + Perform a version-check Realizar una verificación de versión - + Infos Información - + BlockNote Bloc de Notas - + Open a block-note like window to write temporary text Abra una ventana similar a una nota de bloque para escribir texto temporal - - - - - - - - - - - - + + + + + + + + + + + + warnlist warnlists - - - + + + blacklist blacklist - + copy copia - + copies copias @@ -2010,17 +2004,17 @@ Los campos marcados como 'DISCARDED' se analizaron correctamente, pero RichText - + Select a file from the list Seleccione un archivo de la lista - + to inspect its content para inspeccionar su contenido - + Failed to read Fracaso en la lectura @@ -2110,27 +2104,27 @@ Los campos marcados como 'DISCARDED' se analizaron correctamente, pero TR - + Logs Size Breakdown Desglose del Tamaño de los Registros - + Ignored Ignorado - + Parsed Analizado - + Warnings Advertencias - + Blacklisted Excluido @@ -2145,80 +2139,80 @@ Los campos marcados como 'DISCARDED' se analizaron correctamente, pero VERDADERO - + Log Lines Marked as Warning Líneas Marcadas como Advertencia - + Time Taken to Serve Requests Tiempo Necesario para Atender las Solicitudes - + Others Otros - - + + Time of Day Count Recuento de la Hora del Día - - + + from de - - + + to a - + Unexpected WebServer WebServer inesperdado - + An error occured while processing Ocurrió un error durante el procesamiento - + An error occured while processing dates Ocurrió un error al procesar las fechas - + An error occured while parsing %1 from the database Ocurrió un error al procesar los %1 en la base de datos - + Years Años - + Months Meses - + Days Días - + Value responsible for the error Valor responsable del error - + Database table name Nombre de la tabla de la base de datos diff --git a/logdoctor/translations/LogDoctor_fr_FR.ts b/logdoctor/translations/LogDoctor_fr_FR.ts index e182ba19..0823cbd5 100644 --- a/logdoctor/translations/LogDoctor_fr_FR.ts +++ b/logdoctor/translations/LogDoctor_fr_FR.ts @@ -80,49 +80,49 @@ Vérification des mises à jour - + Failed to establish a connection Échec de l'établissement d'une connexion - + Connection error, please try again later Erreur de connexion, veuillez réessayer plus tard - + Connection timed out La connexion a expiré - + New version available Nouvelle version disponible - + A new version is available! Please visit LogDoctor's git repository and follow the instruction about how to update Une nouvelle version est disponible! Veuillez visiter le référentiel git de LogDoctor et suivez les instructions sur la façon de mettre à jour - + No update found Aucune mise à jour trouvée - + LogDoctor is up-to-date LogDoctor est à jour - + :/ :/ - + You're running a version from the future! Your version is beyond the current upstream version Are you running the original LogDoctor? @@ -133,33 +133,33 @@ Utilisez-vous le LogDoctor d'origine? Veuillez visiter le référentiel de LogDoctor et en obtenir une nouvelle version - + Version check failed La vérification de la version a échoué - + An error occured while parsing: initial version mark not found Une erreur s'est produite lors de l'analyse: marqueur initial pas trouvé - + An error occured while parsing: final version mark not found Une erreur s'est produite lors de l'analyse: marqueur final pas trouvé - + An error occured while parsing: malformed version Une erreur s'est produite lors de l'analyse: version malformée - + An error occured while comparing: malformed upstream version Une erreur s'est produite lors de la comparaison: @@ -236,66 +236,66 @@ version online malformée DialogSec - + An error occured while reading the configuration file Une erreur s'est produite lors de la lecture du fichier de configuration - + One of the lists has an invalid item L'une des listes contient un élément non valide - + An error occured while parsing configuration file's data Une erreur s'est produite lors de l'analyse des données du fichier de configuration - - + + Failed to create the configuration file's directory Échec de la création du répertoire du fichier de configuration - + An error occured while writing the configuration file Une erreur s'est produite lors de l'écriture du fichier de configuration - + An error occured while preparing the configuration file's data Une erreur s'est produite lors de la préparation des données des fichiers de configuration - - + + Failed to create the database backups' directory Echec de la création du répertoire des sauvegardes de le database - + Failed to copy the database file Impossible de copier le fichier de database - - + + Failed to update the backups Échec de la mise à jour des sauvegardes - - + + Failed to create the directory Échec de la création du répertoire - - unrecognized entry - entrée non reconnue + + Unrecognized entry + Entrée non reconnue - + Failed to read gzipped file Impossible de lire le fichier gzippé @@ -625,8 +625,8 @@ Veuillez le corriger et réessayer Le fichier est vide - + An error accured while reading the file Une erreur s'est produite lors de la lecture du fichier @@ -819,7 +819,7 @@ merci de signaler ce problème Saut - + @@ -835,43 +835,43 @@ merci de signaler ce problème Des ressources supplémentaires peuvent être téléchargées à partir du dépôt git - - - + + + An error occured while parsing the format string Une erreur s'est produite lors de l'analyse de la chaîne de format - - + + Size of the file Taille du fichier - - + + Warning size parameter Paramètre de taille d'avertissement - + An error accured while reading the gzipped file Une erreur s'est produite lors de la lecture du fichier gzippé - + Something failed while handling the file Quelque chose a échoué lors du traitement du fichier - + An error occured while working on the database Une erreur s'est produite lors du travail sur le database - + An error occured while working on the database Aborting @@ -884,19 +884,19 @@ Abandon MainWindow - + Parse logs from the Apache2 web server Analyser les journaux du serveur web Apache2 - + Parse logs from the Nginx web server Analyser les journaux du serveur web Nginx - + Parse logs from the Microsoft IIS web server Analyser les journaux du serveur web Microsoft IIS @@ -957,8 +957,8 @@ Abandon - - + + Draw the chart Dessinez le graphique @@ -969,46 +969,40 @@ Abandon - - - - + + + + Select a Web Server Sélectionnez un Web Server - - - - - - - + + + + + Year An - - - - - - - + + + + + Month Mois - - - - - - - + + + + + Day Jour @@ -1018,225 +1012,225 @@ Abandon Heure - + Update the database with current Warning States Mettre à jour le database avec les états d'avertissement actuels - + Log line marked as Warning Ligne de journal marquée comme Avertissement - + Date when the request arrived (YYYY-MM-DD) Date d'arrivée de la demande (AAAA-MM-JJ) - - + + Time when the request arrived (hh:mm:ss) Heure d'arrivée de la demande (hh:mm:ss) - - - - + + + + Protocol of the request Protocole de la demande - - - - + + + + Method of the request Méthode de la demande - - - - + + + + URI of the requested page URL de la page demandée - - - - + + + + Response code from the server Code de résponse du serveur - - + + IP address of the Client which made the request Addresse IP du client qui a fait la demande - + Size ib Bytes of the request, usually includes header and data Taille en Octets de la demande, comprend généralement header et données - + Size in Bytes of the served content, usually includes header and data Taille en Octets du contenu servi, comprend généralement header et données - + Protocol: Protocole: - + Method: Méthode: - + Response: Réponse: - + Query: Query: - + URI: URI: - + Filters Filtres - - - - + + + + Query carried along with the URI Query transportée avec l'URI - - + + Cookie used for the request Cookie utilisé pour la requête - - + + User-agent of the client which made the request User-agent du client qui a fait la demande - + Count Compter - - + + The URL which redirected the Client to the requested page L'URL qui a redirigé le Client vers la page demandée - + Number of occurrences Nombre d'occurrences - + Item Article - + Value of the field Valeur du champ - - + + From: De: - - + + To: À: - - - + + + Field: Champ: - - - + + + Select a log field to view Sélectionnez un champ de journal à afficher - - - + + + Filter: Filtre: - + Protocol Protocole - + Method Méthode - + URI URI - + User-agent User-agent - + Most recurrent Le plus récurrent - + Date ever Date de tous les temps - + Day of the week Jour de la semaine - + Hour of the day Heure du jour - + Most trafficked Plus trafiqué @@ -1246,763 +1240,763 @@ Abandon Sélectionnez/désélectionnez tous les fichiers - - + + Time taken Temps pris - - + + Bytes sent Octets envoyés - + Bytes received Octets reçus - + Mean/Max performances Performances moyennes/maxi - + Requests received Demandes reçues - + Total work Travail total - - + + General Général - + General settings Réglages généraux - + Window Fenêtre - - - - - - + + + + + + Remember window's position and size Se souvenir de la position et de la taille de la fenêtre - + Geometry Apparence - - + + Theme to use for the window Thème à utiliser pour la fenêtre - - + + Theme Thème - + None (System) Aucun (Système) - - + + Dark Sombre - + Dialogs Dialogues - + Candy Bonbon - + Herb Herbe - + Powder Poudre - + Auto (Default) Auto (Défaut) - + Light Clair - + Dialogs level Niveau dialogue - + Reduced quantity of dialog messages shown Quantité réduite de messages de dialogue affichés - + Essential Essentiel - + Normal quantity of dialog messages shown Quantité normale de messages de dialogue affichés - + Normal Normal - + Explanatory Explicatif - + Logs parser Analyseur de journaux - + Statistics viewer Visualiseur de statistiques - + TextBrowser TextBrowser - + Font to use for the Text Browser Font à utiliser pour le Text Browser - + Font Font - + Double-spaced lines Lignes à double interligne - + Use wide lines Utilisez des lignes larges - + Define the spacing between lines Définir l'espacement entre les lignes - + Lines spacing Interligne - + None Aucun - + Color scheme to use for the Text Browser Jeu de couleurs à utiliser pour le Text Browser - + Color scheme Schéma de couleur - + The appearance of the Text Browser with the current settings L'apparence du Text Browser avec les paramètres actuels - - + + Preview Aperçu - + Charts Graphiques - + Default (Light) Par défaut (lDégager) - + Sand Sable - + Cerulean Azuré - + Theme to use for the Charts Thème à utiliser pour les Graphiques - + Databases Databases - - - - - + + + + + Apply the current path Appliquer le chemin actuel - + Path where the logs data collection database is located Chemin où se trouve le database de collecte de données de journaux - + Logs data Données de journaux - - - - - + + + + + The given path doen't exists, or doesn't point to a folder Le chemin donné n'existe pas ou ne pointe pas vers un dossier - + Path where the used files hashes database is located Chemin où se trouve le database de hachage des fichiers utilisés - + Used files Archivos usados - - + + Insert the base path only, file name excluded Insérez le chemin de base uniquement, nom de fichier exclu - + Path for the database files Chemin des fichiers de laìe database - - - - + + + + Paths Chemins - + Backup options for the Logs Data database Options de sauvegarde pour le database de données de journaux - + Backups Sauvegardes - + A new backup is made when closing LogDoctor after having succesfully edited the database Une nouvelle sauvegarde est effectuée à la fermeture de LogDoctor après avoir édité avec succès le database - + Backup the Logs Data database and keep Sauvegardez le database de données de journaux et conservez - + Logs Journaux - + Logs related settings Paramètres liés aux journaux - + Defaults Défaut - + Default WebServer Serveur Web par défaut - + Control Control - + Options about the log files usage control Options concernant le contrôle de l'utilisation des fichiers journaux - + Usage control Contrôle de l'utilisation - + Hide already used files Masquer les fichiers déjà utilisés - + Size warnings Avertissements de taille - + Warn me when using files with a size exceeding: M'avertir lors de l'utilisation de fichiers dont la taille dépasse : - - - + + + Generate a sample log line from the currently saved string, to check if it gets formatted correctly. Any field not considered by LogDoctor will appear as 'DISCARDED' Générez un exemple de ligne de journal à partir de la chaîne actuellement enregistrée, pour vérifier si elle est correctement formatée. Tout champ non pris en compte par LogDoctor apparaîtra comme 'DISCARDED' - + CrissCross CrissCross - + Play CrissCross Jouer au CrissCross - + Snake Snake - + Play Snake Jouer au Snake - - - - - - + + + + + + Apache2 Apache2 - - + + Time taken by the server to serve the content, in milliseconds Temps mis par le serveur pour servir le contenu, en millisecondes - - - - + + + + Only use lines in which the field is starting with this string Utilisez uniquement les lignes dans lesquelles le champ commence par cette chaîne - + Only use lines in which the field is matching this statement. Use '!', '=','<' or '>' to declare what to use Utilisez uniquement les lignes dans lesquelles le champ correspond à cette instruction. Utilisez '!', '=', '<' ou '>' pour déclarer quoi utiliser - - - + + + With strings, only the lines in which the field is starting with this string will be used. With numbers, use '!', '=','<' or '>' to declare what to use Avec les chaînes, seules les lignes dans lesquelles le champ commence par cette chaîne seront utilisées. Avec des nombres, utilisez '!', '=', '<' ou '>' pour déclarer ce qu'il faut utiliser - + Remember the window's position and size Rappelez-vous la position et la taille de la fenêtre - + Remember position and size Rappelez-vous la position et la taille - + Ash Cendre - + Icons Icônes - + Define the quantity of dialog mesages shown Définir la quantité de messages de dialogue affichés - + Augmented quantity of dialog messages shown Quantité augmentée de messages de dialogue affichés - + Dialogs from the main processes Dialogues des principaux processus - + Dialogs emitted when parsing logs Boîtes de dialogue émises lors de l'analyse des journaux - + Dialogs emitted when viewing statistics Dialogues émis lors de la consultation des statistiques - + Configure Apache2 specific options Configurer les options spécifiques à Apache2 - - - + + + Logs folder Dossier journaux - - - + + + Logs format string Chaîne de format des journaux - - - + + + Format string Chaîne de format - - - + + + Insert the format string you're using Insérez la chaîne de format que vous utilisez - - - + + + Apply the current string Appliquer la chaîne actuelle - - - + + + Generate sample Générer un échantillon - - - + + + Please check the correctness of this line. Fields marked as 'DISCARDED' got parsed correctly, but are not considered by LogDoctor Veuillez vérifier l'exactitude de cette ligne. Les champs marqués comme 'DISCARDED' ont été analysés correctement, mais ne sont pas pris en compte par LogDoctor - - - + + + Open an help window Ouvrir une fenêtre d'aide - - - + + + Help Aider - - - + + + Warnlists Warnlists - - - - - - + + + + + + Select a log field Sélectionnez un champ de journal - - - + + + Use warnlist for this field Utiliser la Liste d'Avertissement pour ce champ - + Add the current line to the list Ajouter la ligne actuelle à la liste - + Remove the selected item from the list Supprimer l'élément sélectionné de la liste - - - - - - - - - - - - + + + + + + + + + + + + Move the selected item down Déplacer l'élément sélectionné vers le bas - - - + + + Blacklists Blacklists - - - + + + Use blacklist for this field Utiliser la Liste Noire pour ce champ - - - - - + + + + + Add line Ajouter une ligne - - - - - + + + + + Remove selection Supprimer la sélection - - - - - - + + + + + + Nginx Nginx - + Configure Nginx specific options Configurer les options spécifiques à Nginx - - - - - - + + + + + + IIS IIS - - - + + + Format Format - + Configure IIS specific options Configurer les options spécifiques à IIS - + Language Langue - + Utilities Utilitaires - + Tools Outils - + Games Jeux - + Check updates Vérifier les mises à jour - + Perform a version-check Effectuer une vérification de version - + Infos Infos - + BlockNote Bloc Notes - + Open a block-note like window to write temporary text Ouvrir une fenêtre de type bloc-note pour écrire un texte temporaire - - - - - - - - - - - - + + + + + + + + + + + + warnlist warnlist - - - + + + blacklist blacklist - + copy copie - + copies copies @@ -2010,17 +2004,17 @@ Les champs marqués comme 'DISCARDED' ont été analysés correctement RichText - + Select a file from the list Sélectionnez un fichier dans la liste - + to inspect its content pour inspecter son contenu - + Failed to read Echec en lecture @@ -2110,27 +2104,27 @@ Les champs marqués comme 'DISCARDED' ont été analysés correctement TR - + Logs Size Breakdown Répartition de la Taille des Journaux - + Ignored Ignoré - + Parsed analysé - + Warnings Avertissements - + Blacklisted Exclu @@ -2145,80 +2139,80 @@ Les champs marqués comme 'DISCARDED' ont été analysés correctement VRAI - + Log Lines Marked as Warning Lignes Marquées comme Avertissement - + Time Taken to Serve Requests Temps Pris pour Traiter les Demandes - + Others Autres - - + + Time of Day Count Compter les Heures de la Journée - - + + from de - - + + to à - + Unexpected WebServer WebServer inattendu - + An error occured while processing Une erreur s'est produite lors du traitement - + An error occured while processing dates Une erreur s'est produite lors du traitement des dates - + An error occured while parsing %1 from the database Erreur lors du traitement de '%1' dans la database - + Years Ans - + Months Mois - + Days Journées - + Value responsible for the error Valeur responsable de l'erreur - + Database table name Nom de la table de la base de données diff --git a/logdoctor/translations/LogDoctor_it_IT.ts b/logdoctor/translations/LogDoctor_it_IT.ts index 5a1553a1..e6ed6fbf 100644 --- a/logdoctor/translations/LogDoctor_it_IT.ts +++ b/logdoctor/translations/LogDoctor_it_IT.ts @@ -228,10 +228,6 @@ Visita il repository di LogDoctor e segui le istruzioni su come aggiornareFailed to update the backups Fallimento nell'aggiornare i backups - - unrecognized entry - input non riconosciuto - Failed to read gzipped file Lettura del file gzip non riuscita @@ -674,6 +670,10 @@ per favore segui le istruzioni nella pagina del repository Failed to create the directory Creazione della cartella non riuscita + + Unrecognized entry + Input non riconosciuto + MainWindow diff --git a/logdoctor/translations/LogDoctor_ja_JP.ts b/logdoctor/translations/LogDoctor_ja_JP.ts index f4ca0d49..ae182382 100644 --- a/logdoctor/translations/LogDoctor_ja_JP.ts +++ b/logdoctor/translations/LogDoctor_ja_JP.ts @@ -224,10 +224,6 @@ LogDoctor の git リポジトリにアクセスし、更新方法に関する Failed to update the backups バックアップの更新に失敗しました - - unrecognized entry - 認識されないエントリ - Failed to read gzipped file Gzip されたファイルの読み取りに失敗しました @@ -670,6 +666,10 @@ please follow the instruction on the repository page Failed to create the directory ディレクトリの作成に失敗しました + + Unrecognized entry + 認識されないエントリ + MainWindow diff --git a/logdoctor/translations/LogDoctor_pt_BR.ts b/logdoctor/translations/LogDoctor_pt_BR.ts index 41f82465..b208f0c5 100644 --- a/logdoctor/translations/LogDoctor_pt_BR.ts +++ b/logdoctor/translations/LogDoctor_pt_BR.ts @@ -80,49 +80,49 @@ Procurando por atualizações - + Failed to establish a connection Erro ao estabelecer uma conexão - + Connection error, please try again later Erro de conexão, tente novamente mais tarde - + Connection timed out Tempo de conexão esgotado - + New version available Nova versão disponível - + A new version is available! Please visit LogDoctor's git repository and follow the instruction about how to update Uma nova versão está disponível! Visite o repositorio do git do LogDoctor e siga as instruções sobre como atualizar - + No update found Nenhuma atualização encontrada - + LogDoctor is up-to-date LogDoctor está atualizado - + :/ :/ - + You're running a version from the future! Your version is beyond the current upstream version Are you running the original LogDoctor? @@ -133,33 +133,33 @@ Está executando o LogDoctor original? Visite o repositório e baixe novamente - + Version check failed Falha na verificação da versão - + An error occured while parsing: initial version mark not found Um erro ocorreu ao analisar: marcador inicial no encontrado - + An error occured while parsing: final version mark not found Um erro ocorreu ao analisar: marcador final não encontrado - + An error occured while parsing: malformed version Um erro ocorreu ao analisar: versão mal formada - + An error occured while comparing: malformed upstream version Um erro ocorreu ao comparar: @@ -236,66 +236,66 @@ versão online mal formada DialogSec - + An error occured while reading the configuration file Erro durante a leitura do arquivo de configuração - + One of the lists has an invalid item Uma das listas possui um elemento inválido - + An error occured while parsing configuration file's data Erro durante a análise do arquivo de configuração - - + + Failed to create the configuration file's directory Erro ao criar diretório do arquivo de configuração - + An error occured while writing the configuration file Erro ao escrever o arquivo de configuração - + An error occured while preparing the configuration file's data Erro ao preparar os dados do arquivo de configuração - - + + Failed to create the database backups' directory Erro ao criar backup do banco de dados - + Failed to copy the database file Erro ao copiar arquivos do banco de dados - - + + Failed to update the backups Erro ao atualizar backup - - + + Failed to create the directory Erro ao criar diretório - - unrecognized entry + + Unrecognized entry Entrada não reconhecida - + Failed to read gzipped file Falha na leitura do arquivo gzip @@ -625,8 +625,8 @@ Por favor, corrija e tente novamente O arquivo está vazio - + An error accured while reading the file Erro na leitura do arquivo @@ -819,7 +819,7 @@ por favor reporte este problema Saltado - + @@ -835,43 +835,43 @@ por favor reporte este problema Recursos adicionais podem ser baixados do repositório - - - + + + An error occured while parsing the format string Erro ao analisar string de formato - - + + Size of the file Tamanho do arquivo - - + + Warning size parameter Parâmetro de aviso do tamanho - + An error accured while reading the gzipped file Erro ao ler o arquivo gzip - + Something failed while handling the file Algo deu errado ao manipular o arquivo - + An error occured while working on the database Erro ao trabalhar no banco de dados - + An error occured while working on the database Aborting @@ -884,19 +884,19 @@ Abortado MainWindow - + Parse logs from the Apache2 web server Analisar logs do servidor web Apache2 - + Parse logs from the Nginx web server Analise os logs do servidor web Nginx - + Parse logs from the Microsoft IIS web server Analisar logs do servidor web Microsoft IIS @@ -957,8 +957,8 @@ Abortado - - + + Draw the chart Desenhe o gráfico @@ -969,46 +969,40 @@ Abortado - - - - + + + + Select a Web Server Selecione um Servidor Web - - - - - - - + + + + + Year Ano - - - - - - - + + + + + Month Mês - - - - - - - + + + + + Day Dia @@ -1018,225 +1012,225 @@ Abortado Hora - + Update the database with current Warning States Atualize o banco de dados com os estados de aviso atuais - + Log line marked as Warning Linha de registro marcada como Aviso - + Date when the request arrived (YYYY-MM-DD) Data em que o pedido chegou (AAAA-MM-DD) - - + + Time when the request arrived (hh:mm:ss) Hora em que o pedido chegou (hh:mm:ss) - - - - + + + + Protocol of the request Protocolo do pedido - - - - + + + + Method of the request Método do pedido - - - - + + + + URI of the requested page URL da página solicitada - - - - + + + + Response code from the server Código de resposta do servidor - - + + IP address of the Client which made the request Endereço IP do cliente que fez a solicitação - + Size ib Bytes of the request, usually includes header and data Tamanho da solicitação em bytes, geralmente inclui cabeçalho e dados - + Size in Bytes of the served content, usually includes header and data Tamanho em Bytes do conteúdo servido, geralmente inclui o cabeçalho e os dados - + Protocol: Protocolo: - + Method: Método: - + Response: Reposta: - + Query: Query: - + URI: URI: - + Filters Filtros - - - - + + + + Query carried along with the URI Consulta realizada junto com o URI - - + + Cookie used for the request Cookie utilizado para o pedido - - + + User-agent of the client which made the request User-agent do cliente que fez a requisição - + Count Cálculo - - + + The URL which redirected the Client to the requested page A URL que redirecionou o Cliente para a página solicitada - + Number of occurrences Número de incidentes - + Item Item - + Value of the field Valor do campo - - + + From: De: - - + + To: Para: - - - + + + Field: Campo: - - - + + + Select a log field to view Selecione um campo de registro para visualizar - - - + + + Filter: Filtro: - + Protocol Protocolo - + Method Método - + URI URI - + User-agent User-agent - + Most recurrent Mais recorrente - + Date ever Data histórica - + Day of the week Dia da semana - + Hour of the day Hora do dia - + Most trafficked Mais trafegado @@ -1246,762 +1240,762 @@ Abortado Selecionar/desmarcar todos os arquivos - - + + Time taken Tempo gasto - - + + Bytes sent Bytes enviados - + Bytes received Bytes recebidos - + Mean/Max performances Desempenho médio/máximo - + Requests received Inscrições recebidas - + Total work Trabalho total - - + + General Geral - + General settings Configuração geral - + Window Janela - - - - - - + + + + + + Remember window's position and size Lembre-se da posição e tamanho da janela - + Geometry Aparência - - + + Theme to use for the window Tema para usar na janela - - + + Theme Tema - + None (System) Ninguno (Sistema) - - + + Dark Escuro - + Dialogs Diálogos - + Candy Doce - - - + + + With strings, only the lines in which the field is starting with this string will be used. With numbers, use '!', '=','<' or '>' to declare what to use - + Herb Erva - + Powder Polvo - + Auto (Default) Auto (Predeterminado) - + Light Claro - + Dialogs level Nivel de diálogo - + Reduced quantity of dialog messages shown Quantidade reduzida de mensagens de diálogo exibidas - + Essential Básico - + Normal quantity of dialog messages shown Quantidade normal de mensagens de diálogo exibidas - + Normal Normal - + Explanatory Explicativo - + Logs parser Analizador de logs - + Statistics viewer Visualizador de estatísticas - + TextBrowser Navegador de texto - + Font to use for the Text Browser Fonte a ser usada para o navegador de texto - + Font Fonte - + Double-spaced lines linhas com espaçamento duplo - + Use wide lines Usar linhas largas - + Define the spacing between lines Defina o espaçamento entre as linhas - + Lines spacing Espaçamento entre linhas - + None Ninguém - + Color scheme to use for the Text Browser Combinação de cores para usar no Navegador de Texto - + Color scheme Esquema de cores - + The appearance of the Text Browser with the current settings A aparência do navegador de texto com a configuração atual - - + + Preview Visualização - + Charts Gráficos - + Default (Light) Predeterminado (Claro) - + Sand Areia - + Cerulean Azul claro - + Theme to use for the Charts Tema para usar em gráficos - + Databases Banco de dados - - - - - + + + + + Apply the current path Aplicar caminho atual - + Path where the logs data collection database is located Caminho onde o banco de dados de coleta de dados de log está localizado - + Logs data Dados de registros - - - - - + + + + + The given path doen't exists, or doesn't point to a folder O caminho fornecido não existe ou não aponta para uma pasta - + Path where the used files hashes database is located Quebrado onde está localizado o banco de dados hash dos arquivos usados - + Used files Arquivos usados - - + + Insert the base path only, file name excluded Insira apenas a rotação base, nome de arquivo excluído - + Path for the database files Arquivos quebrados do banco de dados - - - - + + + + Paths Rotas - + Backup options for the Logs Data database Opções de backup para o banco de dados de log - + Backups Backups - + A new backup is made when closing LogDoctor after having succesfully edited the database Um novo backup é feito ao fechar o LogDoctor após editar o banco de dados com sucesso - + Backup the Logs Data database and keep Faça um backup do banco de dados e guarde - + Logs Logs - + Logs related settings Configuração relacionada a logs - + Defaults Padrões - + Default WebServer Servidor Web padrão - + Control Controlar - + Options about the log files usage control Opções de controle de uso do arquivo de log - + Usage control Controle de uso - + Hide already used files Ocultar arquivos já usados - + Size warnings Avisos de tamanho - + Warn me when using files with a size exceeding: Avisar-me quando usar arquivos maiores que: - - - + + + Generate a sample log line from the currently saved string, to check if it gets formatted correctly. Any field not considered by LogDoctor will appear as 'DISCARDED' Gere uma linha de log de amostra a partir da string atualmente salva, para verificar se ela está formatada corretamente. Qualquer campo não considerado pelo LogDoctor aparecerá como 'DISCARDED' - + CrissCross Cruzado - + Play CrissCross Jogar a Cruzada - + Snake Cobra - + Play Snake Jogar a Cobra - - - - - - + + + + + + Apache2 Apache2 - - + + Time taken by the server to serve the content, in milliseconds Tempo que o servidor leva para veicular o conteúdo, em milissegundos - - - - + + + + Only use lines in which the field is starting with this string Use apenas linhas onde o campo começa com esta string - + Only use lines in which the field is matching this statement. Use '!', '=','<' or '>' to declare what to use Use apenas linhas onde o campo corresponda a esta declaração. Use '!', '=', '<' o '>' para declarar qué usar - + Remember the window's position and size Lembre-se da posição e tamanho da janela - + Remember position and size Lembre-se de posição e tamanho - + Ash Cinza - + Icons Icones - + Define the quantity of dialog mesages shown Defina o número de mensagens de diálogo exibidas - + Augmented quantity of dialog messages shown Maior quantidade de mensagens de diálogo exibidas - + Dialogs from the main processes Diálogos dos principais processos - + Dialogs emitted when parsing logs Diálogos emitidos ao analisar logs - + Dialogs emitted when viewing statistics Diálogos emitidos ao visualizar estatísticas - + Configure Apache2 specific options Configurar opções específicas do Apache2 - - - + + + Logs folder Pasta de registros - - - + + + Logs format string String de formato de registro - - - + + + Format string String de formato - - - + + + Insert the format string you're using Insira a string de formato que você está usando - - - + + + Apply the current string Aplicar string atual - - - + + + Generate sample Gerar amostra - - - + + + Please check the correctness of this line. Fields marked as 'DISCARDED' got parsed correctly, but are not considered by LogDoctor Por favor, verifique a precisão desta linha. Campos marcados como 'DISCARDED' analisados ​​corretamente, mas o LogDoctor não os leva em consideração - - - + + + Open an help window Abra uma janela de ajuda - - - + + + Help Ajuda - - - + + + Warnlists Listas de aviso - - - - - - + + + + + + Select a log field Selecione um campo de logs - - - + + + Use warnlist for this field Use a lista de avisos para este campo - + Add the current line to the list Adicionar a linha atual à lista - + Remove the selected item from the list Remova o item selecionado da lista - - - - - - - - - - - - + + + + + + + + + + + + Move the selected item down Mover item selecionado para baixo - - - + + + Blacklists Listas negras - - - + + + Use blacklist for this field Usar Lista Negra para este campo - - - - - + + + + + Add line Adicionar linha - - - - - + + + + + Remove selection Eliminar seleção - - - - - - + + + + + + Nginx Nginx - + Configure Nginx specific options Configurar opções específicas de Nginx - - - - - - + + + + + + IIS IIS - - - + + + Format Formato - + Configure IIS specific options Configurar opções específicas de IIS - + Language Língua - + Utilities Utilidades - + Tools Instrumentos - + Games Jogos - + Check updates Verificar atualizações - + Perform a version-check Execute uma verificação de versão - + Infos Informação - + BlockNote Bloco de Notas - + Open a block-note like window to write temporary text Abra uma janela semelhante a uma nota de bloco para escrever um texto temporário - - - - - - - - - - - - + + + + + + + + + + + + warnlist listas de avisos - - - + + + blacklist lista negra - + copy copia - + copies copias @@ -2009,17 +2003,17 @@ Campos marcados como 'DISCARDED' analisados ​​corretamente, mas o RichText - + Select a file from the list Selecione um arquivo da lista - + to inspect its content para inspecionar seu conteúdo - + Failed to read Falha em ler @@ -2109,27 +2103,27 @@ Campos marcados como 'DISCARDED' analisados ​​corretamente, mas o TR - + Logs Size Breakdown Divisão do Tamanho do Registro - + Ignored Ignorado - + Parsed Analizado - + Warnings Avisos - + Blacklisted Excluído @@ -2144,80 +2138,80 @@ Campos marcados como 'DISCARDED' analisados ​​corretamente, mas o VERDADEIRO - + Log Lines Marked as Warning Linhas Marcadas como Aviso - + Time Taken to Serve Requests Tempo Necessário para Atender às Solicitações - + Others Outros - - + + Time of Day Count Contagem de Horas do Dia - - + + from de - - + + to a - + Unexpected WebServer Servidor Web inesperado - + An error occured while processing Ocorreu um erro durante o processamento - + An error occured while processing dates Ocorreu um erro ao processar as datas - + An error occured while parsing %1 from the database Ocorreu um erro ao processar %1 na base de dados - + Years Anos - + Months Meses - + Days Dias - + Value responsible for the error Valor responsável pelo erro - + Database table name Nome da tabela do banco de dados From c2cd21d2b78213c9c96d7ba0534a93d0de1aa264 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 15:35:44 +0100 Subject: [PATCH 33/36] Updated translation resources --- .../resources/translations/LogDoctor_en_GB.qm | Bin 47062 -> 47062 bytes .../resources/translations/LogDoctor_es_ES.qm | Bin 49738 -> 49738 bytes .../resources/translations/LogDoctor_fr_FR.qm | Bin 52036 -> 52036 bytes .../resources/translations/LogDoctor_it_IT.qm | Bin 49566 -> 49566 bytes .../resources/translations/LogDoctor_ja_JP.qm | Bin 37341 -> 37341 bytes .../resources/translations/LogDoctor_pt_BR.qm | Bin 47890 -> 47890 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/logdoctor/resources/translations/LogDoctor_en_GB.qm b/logdoctor/resources/translations/LogDoctor_en_GB.qm index d9193f1930301135a0ab67c8e948d2ecb987fcdb..34a3adb8ad0f555e8c303f7d88e940cbdd5c13fd 100644 GIT binary patch delta 57 zcmV-90LK5;?*i8E0{BM)MST delta 57 zcmV-90LK5Gg9Dy}1F(1m2TH(+002~|vv&l+0kc2`Rt5n^vzH9NRFkq{VgoDyX_HxD PGy!#!j$tIT6k>{BO@$Os diff --git a/logdoctor/resources/translations/LogDoctor_ja_JP.qm b/logdoctor/resources/translations/LogDoctor_ja_JP.qm index e59f9d0f6d6cc15505c06c1fb2ddac06eda8c173..aa51ce9d951cca5cd713185806e6b5d471e95bde 100644 GIT binary patch delta 53 zcmV-50LuT}qXONd0 Date: Fri, 27 Jan 2023 15:36:49 +0100 Subject: [PATCH 34/36] Updated template configuration file --- installation_stuff/logdoctor.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation_stuff/logdoctor.conf b/installation_stuff/logdoctor.conf index 17eb30b2..e71324a5 100644 --- a/installation_stuff/logdoctor.conf +++ b/installation_stuff/logdoctor.conf @@ -1,5 +1,5 @@ [UI] -Language=en +Language=en_GB RememberGeometry=true Geometry=0,0,800,600,true WindowTheme=0 From dbeca1e44a559b19ba389a4e633d639497bc7961 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 27 Jan 2023 15:37:29 +0100 Subject: [PATCH 35/36] Updated documentation --- docs/html/annotated.html | 77 +-- docs/html/classCraphelp-members.html | 3 +- docs/html/classCraphelp.html | 58 +- docs/html/classCrapinfo-members.html | 2 +- docs/html/classCrapinfo.html | 8 + docs/html/classCraplog-members.html | 100 ++- docs/html/classCraplog.html | 571 +++++------------- docs/html/classCraplog.png | Bin 0 -> 395 bytes docs/html/classCraplogWorker-members.html | 93 +++ docs/html/classCraplogWorker.html | 264 ++++++++ docs/html/classCraplogWorker.png | Bin 0 -> 496 bytes docs/html/classCrapup-members.html | 4 +- docs/html/classCrapup.html | 20 +- docs/html/classCrapview-members.html | 46 +- docs/html/classCrapview.html | 410 ++++--------- docs/html/classCrapview.png | Bin 0 -> 403 bytes docs/html/classCrissCross-members.html | 4 +- docs/html/classCrissCross.html | 20 +- docs/html/classDbQuery-members.html | 33 +- docs/html/classDbQuery.html | 394 +++++++----- docs/html/classDialogBool-members.html | 2 +- docs/html/classDialogBool.html | 8 + docs/html/classDialogDia-members.html | 2 +- docs/html/classDialogDia.html | 8 + docs/html/classDialogMsg-members.html | 2 +- docs/html/classDialogMsg.html | 8 + docs/html/classDonutBreakdown.html | 2 +- docs/html/classFood-members.html | 12 +- docs/html/classFood.html | 52 +- docs/html/classFormatOps-members.html | 22 +- docs/html/classFormatOps.html | 156 ++--- docs/html/classHashOps-members.html | 11 +- docs/html/classHashOps.html | 121 ++-- docs/html/classLogOps-members.html | 18 +- docs/html/classLogOps.html | 335 +--------- docs/html/classMainWindow-members.html | 37 +- docs/html/classMainWindow.html | 164 +++-- ...embers.html => classPrintSec-members.html} | 11 +- docs/html/classPrintSec.html | 370 ++++++++++++ docs/html/classResult-members.html | 2 +- docs/html/classResult.html | 8 +- docs/html/classSnake-members.html | 8 +- docs/html/classSnake.html | 32 +- docs/html/classSnakeGame-members.html | 2 +- docs/html/classSnakeGame.html | 8 +- docs/html/classStoreOps.html | 165 ----- docs/html/classStringOps-members.html | 2 +- docs/html/classStringOps.html | 12 +- docs/html/classStyleSec-members.html | 2 +- docs/html/classStyleSec.html | 12 +- docs/html/classTextBrowser-members.html | 12 +- docs/html/classTextBrowser.html | 52 +- docs/html/classes.html | 17 +- docs/html/functions.html | 4 +- docs/html/functions_b.html | 3 +- docs/html/functions_c.html | 19 +- docs/html/functions_d.html | 18 +- docs/html/functions_e.html | 2 +- docs/html/functions_f.html | 2 +- docs/html/functions_func.html | 2 +- docs/html/functions_func_b.html | 3 +- docs/html/functions_func_c.html | 19 +- docs/html/functions_func_d.html | 18 +- docs/html/functions_func_e.html | 2 +- docs/html/functions_func_f.html | 2 +- docs/html/functions_func_g.html | 101 ++-- docs/html/functions_func_h.html | 5 +- docs/html/functions_func_i.html | 14 +- docs/html/functions_func_j.html | 2 +- docs/html/functions_func_l.html | 4 +- docs/html/functions_func_m.html | 6 +- docs/html/functions_func_p.html | 31 +- docs/html/functions_func_r.html | 4 +- docs/html/functions_func_s.html | 24 +- docs/html/functions_func_u.html | 6 +- docs/html/functions_func_v.html | 2 +- docs/html/functions_func_x.html | 2 +- docs/html/functions_func_y.html | 2 +- docs/html/functions_g.html | 101 ++-- docs/html/functions_h.html | 5 +- docs/html/functions_i.html | 16 +- docs/html/functions_j.html | 2 +- docs/html/functions_l.html | 4 +- docs/html/functions_m.html | 6 +- docs/html/functions_n.html | 4 +- docs/html/functions_p.html | 33 +- docs/html/functions_r.html | 4 +- docs/html/functions_s.html | 26 +- docs/html/functions_t.html | 1 - docs/html/functions_u.html | 6 +- docs/html/functions_v.html | 2 +- docs/html/functions_vars.html | 17 +- docs/html/functions_x.html | 5 +- docs/html/functions_y.html | 5 +- docs/html/hierarchy.html | 105 ++-- docs/html/menudata.js | 1 - docs/html/search/all_0.js | 4 +- docs/html/search/all_1.js | 21 +- docs/html/search/all_10.js | 16 +- docs/html/search/all_11.js | 47 +- docs/html/search/all_12.js | 5 +- docs/html/search/all_13.js | 6 +- docs/html/search/all_14.js | 2 +- docs/html/search/all_16.js | 4 +- docs/html/search/all_17.js | 4 +- docs/html/search/all_2.js | 44 +- docs/html/search/all_3.js | 18 +- docs/html/search/all_4.js | 2 +- docs/html/search/all_5.js | 2 +- docs/html/search/all_6.js | 107 ++-- docs/html/search/all_7.js | 7 +- docs/html/search/all_8.js | 34 +- docs/html/search/all_9.js | 2 +- docs/html/search/all_b.js | 4 +- docs/html/search/all_c.js | 6 +- docs/html/search/all_d.js | 4 +- docs/html/search/all_f.js | 44 +- docs/html/search/classes_1.js | 9 +- docs/html/search/classes_9.js | 3 +- docs/html/search/classes_a.js | 8 +- docs/html/search/classes_b.js | 8 +- docs/html/search/classes_c.js | 4 +- docs/html/search/classes_d.js | 2 +- docs/html/search/classes_e.js | 4 + docs/html/search/functions_0.js | 2 +- docs/html/search/functions_1.js | 13 +- docs/html/search/functions_10.js | 12 +- docs/html/search/functions_11.js | 38 +- docs/html/search/functions_13.js | 6 +- docs/html/search/functions_14.js | 2 +- docs/html/search/functions_16.js | 2 +- docs/html/search/functions_17.js | 2 +- docs/html/search/functions_2.js | 31 +- docs/html/search/functions_3.js | 18 +- docs/html/search/functions_4.js | 2 +- docs/html/search/functions_5.js | 2 +- docs/html/search/functions_6.js | 105 ++-- docs/html/search/functions_7.js | 5 +- docs/html/search/functions_8.js | 30 +- docs/html/search/functions_9.js | 2 +- docs/html/search/functions_b.js | 4 +- docs/html/search/functions_c.js | 6 +- docs/html/search/functions_f.js | 37 +- docs/html/search/searchdata.js | 4 +- docs/html/search/variables_0.js | 2 +- docs/html/search/variables_10.js | 4 - docs/html/search/variables_6.js | 2 +- docs/html/search/variables_a.js | 4 +- docs/html/search/variables_b.js | 6 +- docs/html/search/variables_c.js | 2 +- docs/html/search/variables_d.js | 3 +- docs/html/search/variables_e.js | 3 +- docs/html/search/variables_f.js | 2 +- docs/html/structBodyPart-members.html | 2 +- docs/html/structBodyPart.html | 8 +- .../structCraplog_1_1LogFile-members.html | 2 +- docs/html/structCraplog_1_1LogFile.html | 8 +- docs/html/structCraplog_1_1LogName.html | 2 +- ...structFormatOps_1_1LogsFormat-members.html | 2 +- docs/html/structFormatOps_1_1LogsFormat.html | 8 +- 160 files changed, 2528 insertions(+), 2698 deletions(-) create mode 100644 docs/html/classCraplog.png create mode 100644 docs/html/classCraplogWorker-members.html create mode 100644 docs/html/classCraplogWorker.html create mode 100644 docs/html/classCraplogWorker.png create mode 100644 docs/html/classCrapview.png rename docs/html/{classStoreOps-members.html => classPrintSec-members.html} (62%) create mode 100644 docs/html/classPrintSec.html delete mode 100644 docs/html/classStoreOps.html create mode 100644 docs/html/search/classes_e.js delete mode 100644 docs/html/search/variables_10.js diff --git a/docs/html/annotated.html b/docs/html/annotated.html index b2e36b81..b942e05f 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -86,44 +86,45 @@ $(function() {  CBWlistStructure to hold the items of a blacklist/warnlist  CLogFileStructure which holds informations about a log file  CLogNameWeb Server specific file names criterions - CCrapnoteCrapnote - CCrapupCrapup - CCrapviewCrapview - CCrissCrossCrissCross - CDateTimeExceptionDateTimeException - CDateTimeOpsDateTimeOps - CDbQuery - CDialogBoolDialogBool - CDialogDiaDialogDia - CDialogMsgDialogMsg - CDialogSecDialogSec - CDonutBreakdownDonutBreakdon - CFood - CFormatOpsFormatOps - CLogsFormatStructure which holds informations about a log format - CGameSecGameSec - CGenericExceptionGenericException - CGZutilsGZUtils - CHashOpsHashOps - CIOutilsIOUtils - CLogFormatExceptionLogFormatException - CLogOpsLogOps - CLogParserExceptionLogParserException - CMainSliceRepresents a slice - CMainWindowMainWindow - CResultResult - CRichTextRichText - CSHA256 - CSnake - CTile - CSnakeGameSnake - CStoreOpsStoreOps - CStringOpsStringOps - CStyleSecStyleSec - CTextBrowserTextBrowser - CTRTR - CVecOpsVecOps - CWebServerExceptionWebServerException + CCraplogWorker + CCrapnoteCrapnote + CCrapupCrapup + CCrapviewCrapview + CCrissCrossCrissCross + CDateTimeExceptionDateTimeException + CDateTimeOpsDateTimeOps + CDbQuery + CDialogBoolDialogBool + CDialogDiaDialogDia + CDialogMsgDialogMsg + CDialogSecDialogSec + CDonutBreakdownDonutBreakdon + CFood + CFormatOpsFormatOps + CLogsFormatStructure which holds informations about a log format + CGameSecGameSec + CGenericExceptionGenericException + CGZutilsGZUtils + CHashOpsHashOps + CIOutilsIOUtils + CLogFormatExceptionLogFormatException + CLogOpsLogOps + CLogParserExceptionLogParserException + CMainSliceRepresents a slice + CMainWindowMainWindow + CPrintSec + CResultResult + CRichTextRichText + CSHA256 + CSnake + CTile + CSnakeGameSnake + CStringOpsStringOps + CStyleSecStyleSec + CTextBrowserTextBrowser + CTRTR + CVecOpsVecOps + CWebServerExceptionWebServerException diff --git a/docs/html/classCraphelp-members.html b/docs/html/classCraphelp-members.html index cc66d8cc..a4345ffa 100644 --- a/docs/html/classCraphelp-members.html +++ b/docs/html/classCraphelp-members.html @@ -77,7 +77,8 @@ $(function() {

    This is the complete list of members for Craphelp, including all inherited members.

    - + +
    helpLogsFormat(const std::string &path, const QFont &font, const int &color_scheme_id)Craphelp
    helpLogsFormat(const std::string &path, const QFont &font, const int &color_scheme_id) constCraphelp
    helpLogsFormatDefault(const std::string &path, const QFont &font, const int &color_scheme_id) constCraphelp