LogDoctor 3.00
Parse Apache2/Nginx/IIS logs and view dinamically generated statistics
|
#include <craplog.h>
Classes | |
struct | LogName |
Web Server specific file names criterions. More... | |
Public Member Functions | |
int | getDialogsLevel () const |
Returns the Dialogs level. | |
void | setDialogsLevel (const int new_level) |
Sets the new Dialogs level. | |
const std::string & | getStatsDatabasePath () const |
Returns the path of the logs Collection database. | |
const std::string & | getHashesDatabasePath () const |
Returns the path of the log files' Hashes database. | |
void | setStatsDatabasePath (const std::string &path) |
Sets the new path for the logs Collection database. | |
void | setHashesDatabasePath (const std::string &path) |
Sets the new path for the log files' Hashes database. | |
void | setCurrentWSID (const unsigned web_server_id) |
Sets the currently used Web Server ID. | |
unsigned | getCurrentWSID () const |
Returns the currently used Web Server ID. | |
void | setCurrentLogFormat () |
Uses the current Web Server to set the relative logs format. | |
const LogsFormat & | getCurrentLogFormat () const |
Returns the currently used LogsFormat. | |
const std::string & | getLogsPath (const unsigned &web_server) const |
Returns the logs' path for the given web Server. | |
void | setLogsPath (const unsigned &web_server, const std::string &new_path) |
Sets a new path for the given Web Server to search the logs in. | |
bool | isFileNameValid (const std::string &name) const |
Checks if a file name respects the relative criterions. | |
const std::vector< LogFile > & | getLogsList () const |
Returns the list of log files for the current WebServer. | |
size_t | getLogsListSize () const |
Returns the amount of log files in the list. | |
const LogFile & | getLogFileItem (const QString &file_name) const |
Returns the LogFile instance of the given file. | |
bool | setLogFileSelected (const QString &file_name) |
Sets a file in the list as selected. | |
void | clearLogFilesSelection () |
Sets all files in the list as unselected. | |
bool | setApacheLogFormat (const std::string &format_string) |
Sets the Apache2 LogsFormat from the given format string. | |
bool | setNginxLogFormat (const std::string &format_string) |
Sets the Nginx LogsFormat from the given format string. | |
bool | setIisLogFormat (const std::string &format_string, const int log_module) |
Sets the IIS LogsFormat from the given format string. | |
const std::string & | getLogsFormatString (const unsigned &web_server_id) const |
Returns the logs format string for the given Web Server. | |
const LogsFormat & | getLogsFormat (const unsigned &web_server_id) const |
Returns the LogsFormat currently set for the given Web Server. | |
QString | getLogsFormatSample (const unsigned &web_server_id) const |
Returns a sample log line for the given Web Server using the relative LogsFormat. | |
size_t | getWarningSize () const |
Returns the currently set warning size for the log files. | |
void | setWarningSize (const size_t new_size) |
Sets the new warning size for the log files. | |
bool | isBlacklistUsed (const unsigned &web_server_id, const int &log_field_id) const |
Returns whether the relative blacklist is set to be used or not. | |
bool | isWarnlistUsed (const unsigned &web_server_id, const int &log_field_id) const |
Returns whether the relative warnlist is set to be used or not. | |
void | setBlacklistUsed (const unsigned &web_server_id, const int &log_field_id, const bool used) |
Sets the relative blacklist to be used or not. | |
void | setWarnlistUsed (const unsigned &web_server_id, const int &log_field_id, const bool used) |
Sets the relative warnlist to be used or not. | |
const std::vector< std::string > & | getBlacklist (const unsigned &web_server_id, const int &log_field_id) const |
Returns the relative items list. | |
const std::vector< std::string > & | getWarnlist (const unsigned &web_server_id, const int &log_field_id) const |
Returns the relative items list. | |
void | setBlacklist (const unsigned &web_server_id, const int &log_field_id, const std::vector< std::string > &new_list) |
Sets the relative items list. | |
void | setWarnlist (const unsigned &web_server_id, const int &log_field_id, const std::vector< std::string > &new_list) |
Sets the relative items list. | |
void | blacklistAdd (const unsigned &web_server_id, const int &log_field_id, const std::string &new_item) |
Adds an item to the relative list. | |
void | warnlistAdd (const unsigned &web_server_id, const int &log_field_id, const std::string &new_item) |
Adds an item to the relative list. | |
void | blacklistRemove (const unsigned &web_server_id, const int &log_field_id, const std::string &item) |
Removes an item from the relative list. | |
void | warnlistRemove (const unsigned &web_server_id, const int &log_field_id, const std::string &item) |
Removes an item from the relative list. | |
int | blacklistMoveUp (const unsigned &web_server_id, const int &log_field_id, const std::string &item) |
Moves an item one position up in the relative list. | |
int | warnlistMoveUp (const unsigned &web_server_id, const int &log_field_id, const std::string &item) |
Moves an item one position up in the relative list. | |
int | blacklistMoveDown (const unsigned &web_server_id, const int &log_field_id, const std::string &item) |
Moves an item one position down in the relative list. | |
int | warnlistMoveDown (const unsigned &web_server_id, const int &log_field_id, const std::string &item) |
Moves an item one position down in the relative list. | |
bool | checkStuff () |
Various checks to be made before starting a new process. | |
bool | isParsing () const |
Returns whether the database has been edited or not during the process. | |
bool | editedDatabase () const |
Returns whether the database has been edited or not during the process. | |
size_t | getParsedSize () |
Returns the total logs size. | |
size_t | getParsedLines () |
Returns the parsed logs lines. | |
QString | getParsingSpeed () |
Returns the speed on parsing logs. | |
void | makeChart (const QChart::ChartTheme &theme, const std::unordered_map< std::string, QFont > &fonts, QChartView *size_chart) const |
Builds and draws the chart to be displayed in the main window. | |
Private Member Functions | |
void | hireWorker () const |
Hires a worker to parse the selected logs. | |
void | hireAsyncWorker () const |
Hires a worker to parse the selected logs, asynchronously. | |
bool | shouldWorkAsync () const |
Defines whether it's worth it working async or not. | |
std::string | sanitizeBWitem (const int &log_field_id, const std::string &new_item) const |
Sanitizes an item removing the unwanted elements. | |
void | changeIisLogsBaseNames (const int module_id) |
Changes the name criterions for IIS logs files names depending on the given module. | |
Performs operations related to the logs
void Craplog::blacklistAdd | ( | const unsigned & | 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 |
int Craplog::blacklistMoveDown | ( | const unsigned & | 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 |
int Craplog::blacklistMoveUp | ( | const unsigned & | 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 unsigned & | 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 |
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::clearLogFilesSelection | ( | ) |
Sets all files in the list as unselected.
const std::vector< std::string > & Craplog::getBlacklist | ( | const unsigned & | web_server_id, |
const int & | log_field_id | ||
) | const |
Returns the relative items list.
web_server_id | The ID of the Web Server |
log_field_id | The ID of the log field |
const LogsFormat & Craplog::getCurrentLogFormat | ( | ) | const |
unsigned Craplog::getCurrentWSID | ( | ) | const |
Returns the currently used Web Server ID.
const LogFile & Craplog::getLogFileItem | ( | const QString & | file_name | ) | const |
Returns the LogFile instance of the given file.
file_name | The name of the file |
GenericException |
const LogsFormat & Craplog::getLogsFormat | ( | const unsigned & | web_server_id | ) | const |
Returns the LogsFormat currently set for the given Web Server.
web_server_id | ID of the Web Server |
QString Craplog::getLogsFormatSample | ( | const unsigned & | web_server_id | ) | const |
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 unsigned & | web_server_id | ) | const |
Returns the logs format string for the given Web Server.
web_server_id | ID of the Web Server |
const std::vector< LogFile > & Craplog::getLogsList | ( | ) | const |
Returns the list of log files for the current WebServer.
size_t Craplog::getLogsListSize | ( | ) | const |
Returns the amount of log files in the list.
const std::string & Craplog::getLogsPath | ( | const unsigned & | web_server | ) | const |
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 unsigned & | web_server_id, |
const int & | log_field_id | ||
) | const |
Returns the relative items list.
web_server_id | The ID of the Web Server |
log_field_id | The ID of the log field |
bool Craplog::isBlacklistUsed | ( | const unsigned & | web_server_id, |
const int & | log_field_id | ||
) | const |
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 |
bool Craplog::isFileNameValid | ( | const std::string & | name | ) | const |
Checks if a file name respects the relative criterions.
name | The name of the file |
bool Craplog::isWarnlistUsed | ( | const unsigned & | web_server_id, |
const int & | log_field_id | ||
) | const |
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 |
void Craplog::makeChart | ( | const QChart::ChartTheme & | theme, |
const std::unordered_map< std::string, QFont > & | fonts, | ||
QChartView * | size_chart | ||
) | const |
Builds and draws the chart to be displayed in the main window.
theme | The base theme to use for the Chart |
fonts | The map holding the fonts |
size_chart | The widget which will display the chart |
|
private |
Sanitizes 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 |
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 unsigned & | 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 unsigned & | 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 |
void Craplog::setCurrentLogFormat | ( | ) |
Uses the current Web Server to set the relative logs format.
void Craplog::setCurrentWSID | ( | const unsigned | 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 |
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 |
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 unsigned & | 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 |
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 unsigned & | 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 unsigned & | 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 |
void Craplog::warnlistAdd | ( | const unsigned & | 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 |
int Craplog::warnlistMoveDown | ( | const unsigned & | 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 |
int Craplog::warnlistMoveUp | ( | const unsigned & | 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 unsigned & | 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 |