110 KiB
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... | |
Detailed Description
Performs operations related to the logs
Member Function Documentation
◆ blacklistAdd()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field new_list The new items list
- See also
- BWlist
◆ blacklistMoveDown()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field item The item to move
- See also
- BWlist
◆ blacklistMoveUp()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field item The item to move
- See also
- BWlist
◆ blacklistRemove()
void Craplog::blacklistRemove | ( | const int & | web_server_id, |
const int & | log_field_id, | ||
const std::string & | item | ||
) |
Removes an item from the relative list.
- Parameters
-
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
- See also
- BWlist
◆ changeIisLogsBaseNames()
|
private |
Changes the name criterions for IIS logs files names depending on the given module.
- Parameters
-
module_id The ID of the module to use to set the criterions
- Exceptions
-
GenericException
- See also
- LogName
◆ checkStuff()
const bool Craplog::checkStuff | ( | ) |
Various checks to be made before starting a new process.
Checks the databases, the selected files and their size
- Returns
- Whether the checks has been successful or not
- Exceptions
-
GenericException
◆ collectPerfData()
void Craplog::collectPerfData | ( | ) |
Collects performances data from the sub-modules.
◆ getBlacklist()
const std::vector< std::string > & Craplog::getBlacklist | ( | const int & | web_server_id, |
const int & | log_field_id | ||
) |
Returns the relative items list.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field
- Returns
- The list of items in the given blacklist
- See also
- BWlist
◆ getCurrentLogFormat()
const FormatOps::LogsFormat & Craplog::getCurrentLogFormat | ( | ) |
◆ getCurrentWSID()
const int & Craplog::getCurrentWSID | ( | ) |
Returns the currently used Web Server ID.
- Returns
- The Web Server ID
◆ getLogFileItem()
const Craplog::LogFile & Craplog::getLogFileItem | ( | const QString & | file_name | ) |
Returns the LogFile instance of the given file.
- Parameters
-
file_name The name of the file
- Returns
- The LogFile instance
- Exceptions
-
GenericException
- See also
- LogFile, logs_list
◆ getLogsFormat()
const FormatOps::LogsFormat & Craplog::getLogsFormat | ( | const int & | web_server_id | ) |
Returns the LogsFormat currently set for the given Web Server.
- Parameters
-
web_server_id ID of the Web Server
- Returns
- The LogsFormat instance
- See also
- FormatOps::LogsFormat
◆ getLogsFormatSample()
const QString Craplog::getLogsFormatSample | ( | const int & | web_server_id | ) |
Returns a sample log line for the given Web Server using the relative LogsFormat.
- Parameters
-
web_server_id ID of the Web Server
- Returns
- The sample of a log line
- Exceptions
-
WebServerException
◆ getLogsFormatString()
const std::string & Craplog::getLogsFormatString | ( | const int & | web_server_id | ) |
Returns the logs format string for the given Web Server.
- Parameters
-
web_server_id ID of the Web Server
- Returns
- The format string
- See also
- FormatOps::LogsFormat
◆ getLogsList()
const std::vector< Craplog::LogFile > & Craplog::getLogsList | ( | const bool & | fresh = false | ) |
Returns the list of log files.
- Parameters
-
fresh Whether to refresh the list before to return it or not
- Returns
- The list of log files
- See also
- LogFile, logs_list, scanLogsDir()
◆ getLogsListSize()
const int Craplog::getLogsListSize | ( | ) |
Returns the amount of log files in the list.
- Returns
- The number of files actually in the list
- See also
- logs_list
◆ getLogsPath()
const std::string & Craplog::getLogsPath | ( | const int & | web_server | ) |
Returns the logs' path for the given web Server.
- Parameters
-
web_server The ID of the Web Server
- Returns
- The path of the logs' folder
◆ getWarnlist()
const std::vector< std::string > & Craplog::getWarnlist | ( | const int & | web_server_id, |
const int & | log_field_id | ||
) |
Returns the relative items list.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field
- Returns
- The list of items in the givenwarnlist
- See also
- BWlist
◆ isBlacklistUsed()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field
- Returns
- Whether the list is used or not
- See also
- BWlist
◆ isFileNameValid()
const bool Craplog::isFileNameValid | ( | const std::string & | name | ) |
Checks if a file name respects the relative criterions.
- Parameters
-
name The name of the file
- Returns
- Wheter it does respect the criterions or not
- See also
- LogName
◆ isWarnlistUsed()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field
- Returns
- Whether the list is used or not
- See also
- BWlist
◆ joinLogLines()
|
private |
Reads the selected files and append the resulting lines to the list.
- Exceptions
-
GenericException
◆ makeChart()
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.
- Parameters
-
theme The theme to use for the Chart fonts The map holding the fonts size_chart The widget which will display the chart
- See also
- DonutBreakdown
◆ parseLogLines()
|
private |
Parses the lines in the list and stores their data in the data collection.
- See also
- LogOps::parseLines()
◆ printableSize()
|
private |
Returns a printable size to be displayed in the chart, including the suffix.
- Parameters
-
bytes The size in bytes
- Returns
- The string to be displayed
- See also
- makeChart()
◆ run()
void Craplog::run | ( | ) |
Main work method.
Manages the operations which need to be done to parse the logs when the START button is pressed
◆ sanitizeBWitem()
|
private |
Ssnitizes an item removing the unwanted elements.
Called when adding a new item to a list
- Parameters
-
log_field_id The ID of the log field new_item The item to be sanitized
- Returns
- The sanitized item
- Exceptions
-
BWlistException,GenericException
- See also
- BWlist
◆ setApacheLogFormat()
const bool Craplog::setApacheLogFormat | ( | const std::string & | format_string | ) |
Sets the Apache2 LogsFormat from the given format string.
- Parameters
-
format_string The logs format string
- Returns
- Whether the process was successful or not
◆ setBlacklist()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field new_list The new items list
- See also
- BWlist
◆ setBlacklistUsed()
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.
- Parameters
-
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
- See also
- BWlist
◆ setCurrentLogFormat()
|
private |
Uses the current Web Server to set the relative logs format.
- See also
- LogOps::LogsFormat
◆ setCurrentWSID()
void Craplog::setCurrentWSID | ( | const int & | web_server_id | ) |
Sets the currently used Web Server ID.
- Parameters
-
web_server_id The new currently used Web Server
◆ setHashesDatabasePath()
void Craplog::setHashesDatabasePath | ( | const std::string & | path | ) |
Sets the new path for the log files' Hashes database.
- Parameters
-
The new path of the database file
◆ setIisLogFormat()
const bool Craplog::setIisLogFormat | ( | const std::string & | format_string, |
const int & | log_module | ||
) |
Sets the IIS LogsFormat from the given format string.
- Parameters
-
format_string The logs format string log_module The IIS logs module to be used to parse the format string
- Returns
- Whether the process was successful or not
◆ setLogFileSelected()
const bool Craplog::setLogFileSelected | ( | const QString & | file_name | ) |
Sets a file in the list as selected.
- Parameters
-
file_name The name of the file
- Returns
- Wheter the given file name has been found in the list
- See also
- LogFile, logs_list
◆ setLogsPath()
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.
- Parameters
-
web_server The ID of the Web Server new_path The new path
◆ setNginxLogFormat()
const bool Craplog::setNginxLogFormat | ( | const std::string & | format_string | ) |
Sets the Nginx LogsFormat from the given format string.
- Parameters
-
format_string The logs format string
- Returns
- Whether the process was successful or not
◆ setStatsDatabasePath()
void Craplog::setStatsDatabasePath | ( | const std::string & | path | ) |
Sets the new path for the logs Collection database.
- Parameters
-
The new path of the database file
◆ setWarnlist()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field new_list The new items list
- See also
- BWlist
◆ setWarnlistUsed()
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.
- Parameters
-
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
- See also
- BWlist
◆ startWorking()
|
private |
Sets the working state.
- See also
- isWorking()
◆ stopWorking()
|
private |
Un-sets the working state.
- See also
- isWorking()
◆ storeLogLines()
|
private |
Stores the data collection in the database.
- See also
- StoreOps::storeData()
◆ warnlistAdd()
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.
- Parameters
-
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
- See also
- BWlist
◆ warnlistMoveDown()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field item The item to move
- See also
- BWlist
◆ warnlistMoveUp()
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.
- Parameters
-
web_server_id The ID of the Web Server log_field_id The ID of the log field item The item to move
- See also
- BWlist
◆ warnlistRemove()
void Craplog::warnlistRemove | ( | const int & | web_server_id, |
const int & | log_field_id, | ||
const std::string & | item | ||
) |
Removes an item from the relative list.
- Parameters
-
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
- See also
- BWlist
The documentation for this class was generated from the following files:
- logdoctor/modules/craplog/craplog.h
- logdoctor/modules/craplog/craplog.cpp
Generated by 1.9.5 </html>