![]() |
LogDoctor 2.00
Parse Apache2/Nginx/IIS logs and create statistics
|
#include <craplog.h>
Classes | |
| struct | BWlist |
| Structure to hold the items of a blacklist/warnlist. More... | |
| struct | LogFile |
| Structure which holds informations about a log file. More... | |
| struct | LogName |
| Web Server specific file names criterions. More... | |
Public Member Functions | |
| void | run () |
| Main work method. More... | |
| const int & | getDialogsLevel () |
| Returns the Dialogs level. | |
| void | setDialogsLevel (const int &new_level) |
| Sets the new Dialogs level. | |
| const std::string & | getStatsDatabasePath () |
| Returns the path of the logs Collection database. | |
| const std::string & | getHashesDatabasePath () |
| Returns the path of the log files' Hashes database. | |
| void | setStatsDatabasePath (const std::string &path) |
| Sets the new path for the logs Collection database. More... | |
| void | setHashesDatabasePath (const std::string &path) |
| Sets the new path for the log files' Hashes database. More... | |
| void | setCurrentWSID (const int &web_server_id) |
| Sets the currently used Web Server ID. More... | |
| const int & | getCurrentWSID () |
| Returns the currently used Web Server ID. More... | |
| const FormatOps::LogsFormat & | getCurrentLogFormat () |
| Returns the currently used LogsFormat. More... | |
| const std::string & | getLogsPath (const int &web_server) |
| Returns the logs' path for the given web Server. More... | |
| void | setLogsPath (const int &web_server, const std::string &new_path) |
| Sets a new path for the given Web Server to search the logs in. More... | |
| const bool | isFileNameValid (const std::string &name) |
| Checks if a file name respects the relative criterions. More... | |
| const std::vector< LogFile > & | getLogsList (const bool &fresh=false) |
| Returns the list of log files. More... | |
| const int | getLogsListSize () |
| Returns the amount of log files in the list. More... | |
| const LogFile & | getLogFileItem (const QString &file_name) |
| Returns the LogFile instance of the given file. More... | |
| const bool | setLogFileSelected (const QString &file_name) |
| Sets a file in the list as selected. More... | |
| const bool | setApacheLogFormat (const std::string &format_string) |
| Sets the Apache2 LogsFormat from the given format string. More... | |
| const bool | setNginxLogFormat (const std::string &format_string) |
| Sets the Nginx LogsFormat from the given format string. More... | |
| const bool | setIisLogFormat (const std::string &format_string, const int &log_module) |
| Sets the IIS LogsFormat from the given format string. More... | |
| const std::string & | getLogsFormatString (const int &web_server_id) |
| Returns the logs format string for the given Web Server. More... | |
| const FormatOps::LogsFormat & | getLogsFormat (const int &web_server_id) |
| Returns the LogsFormat currently set for the given Web Server. More... | |
| const QString | getLogsFormatSample (const int &web_server_id) |
| Returns a sample log line for the given Web Server using the relative LogsFormat. More... | |
| const long & | getWarningSize () |
| Returns the currently set warning size for the log files. | |
| void | setWarningSize (const long &new_size) |
| Sets the new warning size for the log files. | |
| const bool & | isBlacklistUsed (const int &web_server_id, const int &log_field_id) |
| Returns whether the relative blacklist is set to be used or not. More... | |
| const bool & | isWarnlistUsed (const int &web_server_id, const int &log_field_id) |
| Returns whether the relative warnlist is set to be used or not. More... | |
| void | setBlacklistUsed (const int &web_server_id, const int &log_field_id, const bool &used) |
| Sets the relative blacklist to be used or not. More... | |
| void | setWarnlistUsed (const int &web_server_id, const int &log_field_id, const bool &used) |
| Sets the relative warnlist to be used or not. More... | |
| const std::vector< std::string > & | getBlacklist (const int &web_server_id, const int &log_field_id) |
| Returns the relative items list. More... | |
| const std::vector< std::string > & | getWarnlist (const int &web_server_id, const int &log_field_id) |
| Returns the relative items list. More... | |
| void | setBlacklist (const int &web_server_id, const int &log_field_id, const std::vector< std::string > &new_list) |
| Sets the relative items list. More... | |
| void | setWarnlist (const int &web_server_id, const int &log_field_id, const std::vector< std::string > &new_list) |
| Sets the relative items list. More... | |
| void | blacklistAdd (const int &web_server_id, const int &log_field_id, const std::string &new_item) |
| Adds an item to the relative list. More... | |
| void | warnlistAdd (const int &web_server_id, const int &log_field_id, const std::string &new_item) |
| Adds an item to the relative list. More... | |
| void | blacklistRemove (const int &web_server_id, const int &log_field_id, const std::string &item) |
| Removes an item from the relative list. More... | |
| void | warnlistRemove (const int &web_server_id, const int &log_field_id, const std::string &item) |
| Removes an item from the relative list. More... | |
| const int | blacklistMoveUp (const int &web_server_id, const int &log_field_id, const std::string &item) |
| Moves an item one position up in the relative list. More... | |
| const int | warnlistMoveUp (const int &web_server_id, const int &log_field_id, const std::string &item) |
| Moves an item one position up in the relative list. More... | |
| const int | blacklistMoveDown (const int &web_server_id, const int &log_field_id, const std::string &item) |
| Moves an item one position down in the relative list. More... | |
| const int | warnlistMoveDown (const int &web_server_id, const int &log_field_id, const std::string &item) |
| Moves an item one position down in the relative list. More... | |
| const bool & | editedDatabase () |
| Returns whether the database has been edited or not during the process. | |
| const bool | checkStuff () |
| Various checks to be made before starting a new process. More... | |
| void | clearDataCollection () |
| Erases the data collection when a process is done. | |
| const bool & | isWorking () |
| Returns whether the process is still running or not. | |
| const bool & | isParsing () |
| Returns whether the process is still parsing or not. | |
| void | collectPerfData () |
| Collects performances data from the sub-modules. More... | |
| void | sumWarningsSize (const unsigned int &size) |
| Sums the given size to the warnlisted size. | |
| void | sumBlacklistededSize (const unsigned int &size) |
| Sums the given size to the blacklisted size. | |
| const unsigned int & | getPerfSize () |
| Returns the size to be displayed in the main window. | |
| const unsigned int & | getTotalSize () |
| Returns the total logs size. | |
| const unsigned int & | getParsedLines () |
| Returns the parsed logs lines. | |
| void | makeChart (const QChart::ChartTheme &theme, const std::unordered_map< std::string, QFont > &fonts, QChartView *size_chart) |
| Builds and draws the chart to be displayed in the main window. More... | |
Private Member Functions | |
| void | startWorking () |
| Sets the working state. More... | |
| void | stopWorking () |
| Un-sets the working state. More... | |
| const QString | printableSize (const unsigned int &bytes) |
| Returns a printable size to be displayed in the chart, including the suffix. More... | |
| void | joinLogLines () |
| Reads the selected files and append the resulting lines to the list. More... | |
| void | parseLogLines () |
| Parses the lines in the list and stores their data in the data collection. More... | |
| void | storeLogLines () |
| Stores the data collection in the database. More... | |
| const std::string | sanitizeBWitem (const int &log_field_id, const std::string &new_item) |
| Ssnitizes an item removing the unwanted elements. More... | |
| void | changeIisLogsBaseNames (const int &module_id) |
| Changes the name criterions for IIS logs files names depending on the given module. More... | |
| void | scanLogsDir () |
| Scans the logs directory to get a list of log files. | |
| void | setCurrentLogFormat () |
| Uses the current Web Server to set the relative logs format. More... | |
Performs operations related to the logs
| void Craplog::blacklistAdd | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | new_item | ||
| ) |
Adds an item to the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| new_list | The new items list |
| const int Craplog::blacklistMoveDown | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | item | ||
| ) |
Moves an item one position down in the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| item | The item to move |
| const int Craplog::blacklistMoveUp | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | item | ||
| ) |
Moves an item one position up in the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| item | The item to move |
| void Craplog::blacklistRemove | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | item | ||
| ) |
Removes an item from the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| item | The item to remove from the list |
|
private |
Changes the name criterions for IIS logs files names depending on the given module.
| module_id | The ID of the module to use to set the criterions |
| GenericException |
| const bool Craplog::checkStuff | ( | ) |
Various checks to be made before starting a new process.
Checks the databases, the selected files and their size
| GenericException |
| void Craplog::collectPerfData | ( | ) |
Collects performances data from the sub-modules.
| const std::vector< std::string > & Craplog::getBlacklist | ( | const int & | web_server_id, |
| const int & | log_field_id | ||
| ) |
Returns the relative items list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| const FormatOps::LogsFormat & Craplog::getCurrentLogFormat | ( | ) |
| const int & Craplog::getCurrentWSID | ( | ) |
Returns the currently used Web Server ID.
| const Craplog::LogFile & Craplog::getLogFileItem | ( | const QString & | file_name | ) |
Returns the LogFile instance of the given file.
| file_name | The name of the file |
| GenericException |
| const FormatOps::LogsFormat & Craplog::getLogsFormat | ( | const int & | web_server_id | ) |
Returns the LogsFormat currently set for the given Web Server.
| web_server_id | ID of the Web Server |
| const QString Craplog::getLogsFormatSample | ( | const int & | web_server_id | ) |
Returns a sample log line for the given Web Server using the relative LogsFormat.
| web_server_id | ID of the Web Server |
| WebServerException |
| const std::string & Craplog::getLogsFormatString | ( | const int & | web_server_id | ) |
Returns the logs format string for the given Web Server.
| web_server_id | ID of the Web Server |
| const std::vector< Craplog::LogFile > & Craplog::getLogsList | ( | const bool & | fresh = false | ) |
Returns the list of log files.
| fresh | Whether to refresh the list before to return it or not |
| const int Craplog::getLogsListSize | ( | ) |
Returns the amount of log files in the list.
| const std::string & Craplog::getLogsPath | ( | const int & | web_server | ) |
Returns the logs' path for the given web Server.
| web_server | The ID of the Web Server |
| const std::vector< std::string > & Craplog::getWarnlist | ( | const int & | web_server_id, |
| const int & | log_field_id | ||
| ) |
Returns the relative items list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| const bool & Craplog::isBlacklistUsed | ( | const int & | web_server_id, |
| const int & | log_field_id | ||
| ) |
Returns whether the relative blacklist is set to be used or not.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| const bool Craplog::isFileNameValid | ( | const std::string & | name | ) |
Checks if a file name respects the relative criterions.
| name | The name of the file |
| const bool & Craplog::isWarnlistUsed | ( | const int & | web_server_id, |
| const int & | log_field_id | ||
| ) |
Returns whether the relative warnlist is set to be used or not.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
|
private |
Reads the selected files and append the resulting lines to the list.
| GenericException |
| void Craplog::makeChart | ( | const QChart::ChartTheme & | theme, |
| const std::unordered_map< std::string, QFont > & | fonts, | ||
| QChartView * | size_chart | ||
| ) |
Builds and draws the chart to be displayed in the main window.
| theme | The theme to use for the Chart |
| fonts | The map holding the fonts |
| size_chart | The widget which will display the chart |
|
private |
Parses the lines in the list and stores their data in the data collection.
|
private |
Returns a printable size to be displayed in the chart, including the suffix.
| bytes | The size in bytes |
| void Craplog::run | ( | ) |
Main work method.
Manages the operations which need to be done to parse the logs when the START button is pressed
|
private |
Ssnitizes an item removing the unwanted elements.
Called when adding a new item to a list
| log_field_id | The ID of the log field |
| new_item | The item to be sanitized |
| BWlistException,GenericException |
| const bool Craplog::setApacheLogFormat | ( | const std::string & | format_string | ) |
Sets the Apache2 LogsFormat from the given format string.
| format_string | The logs format string |
| void Craplog::setBlacklist | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::vector< std::string > & | new_list | ||
| ) |
Sets the relative items list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| new_list | The new items list |
| void Craplog::setBlacklistUsed | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const bool & | used | ||
| ) |
Sets the relative blacklist to be used or not.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| used | Whether the list is to be used or not |
|
private |
Uses the current Web Server to set the relative logs format.
| void Craplog::setCurrentWSID | ( | const int & | web_server_id | ) |
Sets the currently used Web Server ID.
| web_server_id | The new currently used Web Server |
| void Craplog::setHashesDatabasePath | ( | const std::string & | path | ) |
Sets the new path for the log files' Hashes database.
| The | new path of the database file |
| const bool Craplog::setIisLogFormat | ( | const std::string & | format_string, |
| const int & | log_module | ||
| ) |
Sets the IIS LogsFormat from the given format string.
| format_string | The logs format string |
| log_module | The IIS logs module to be used to parse the format string |
| const bool Craplog::setLogFileSelected | ( | const QString & | file_name | ) |
Sets a file in the list as selected.
| file_name | The name of the file |
| void Craplog::setLogsPath | ( | const int & | web_server, |
| const std::string & | new_path | ||
| ) |
Sets a new path for the given Web Server to search the logs in.
| web_server | The ID of the Web Server |
| new_path | The new path |
| const bool Craplog::setNginxLogFormat | ( | const std::string & | format_string | ) |
Sets the Nginx LogsFormat from the given format string.
| format_string | The logs format string |
| void Craplog::setStatsDatabasePath | ( | const std::string & | path | ) |
Sets the new path for the logs Collection database.
| The | new path of the database file |
| void Craplog::setWarnlist | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::vector< std::string > & | new_list | ||
| ) |
Sets the relative items list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| new_list | The new items list |
| void Craplog::setWarnlistUsed | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const bool & | used | ||
| ) |
Sets the relative warnlist to be used or not.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| used | Whether the list is to be used or not |
|
private |
Sets the working state.
|
private |
Un-sets the working state.
|
private |
Stores the data collection in the database.
| void Craplog::warnlistAdd | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | new_item | ||
| ) |
Adds an item to the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| new_item | The new item to add to the list |
| const int Craplog::warnlistMoveDown | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | item | ||
| ) |
Moves an item one position down in the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| item | The item to move |
| const int Craplog::warnlistMoveUp | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | item | ||
| ) |
Moves an item one position up in the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| item | The item to move |
| void Craplog::warnlistRemove | ( | const int & | web_server_id, |
| const int & | log_field_id, | ||
| const std::string & | item | ||
| ) |
Removes an item from the relative list.
| web_server_id | The ID of the Web Server |
| log_field_id | The ID of the log field |
| item | The item to remove from the list |