LogDoctor/docs/html/classCraplog.html

95 KiB

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> <head> </head>
LogDoctor 2.00
Parse Apache2/Nginx/IIS logs and create statistics
Loading...
Searching...
No Matches

Craplog. More...

#include <craplog.h>

Inheritance diagram for Craplog:

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

const 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. 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 () const
 Returns the currently used Web Server ID. More...
 
const FormatOps::LogsFormatgetCurrentLogFormat () const
 Returns the currently used LogsFormat. More...
 
const std::string & getLogsPath (const int &web_server) const
 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) const
 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 () const
 Returns the amount of log files in the list. More...
 
const LogFilegetLogFileItem (const QString &file_name) const
 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) const
 Returns the logs format string for the given Web Server. More...
 
const FormatOps::LogsFormatgetLogsFormat (const int &web_server_id) const
 Returns the LogsFormat currently set for the given Web Server. More...
 
const QString getLogsFormatSample (const int &web_server_id) const
 Returns a sample log line for the given Web Server using the relative LogsFormat. More...
 
const unsigned & getWarningSize () const
 Returns the currently set warning size for the log files.
 
void setWarningSize (const unsigned &new_size)
 Sets the new warning size for the log files.
 
const bool & isBlacklistUsed (const int &web_server_id, const int &log_field_id) const
 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) const
 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) const
 Returns the relative items list. More...
 
const std::vector< std::string > & getWarnlist (const int &web_server_id, const int &log_field_id) const
 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 checkStuff ()
 Various checks to be made before starting a new process. More...
 
const bool isParsing () const
 Returns whether the database has been edited or not during the process.
 
const bool editedDatabase () const
 Returns whether the database has been edited or not during the process.
 
const unsigned getParsedSize ()
 Returns the total logs size.
 
const unsigned getParsedLines ()
 Returns the parsed logs lines.
 
const 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. More...
 

Private Member Functions

const std::string sanitizeBWitem (const int &log_field_id, const std::string &new_item) const
 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...
 

Private Attributes

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.
 

Detailed Description

Craplog.

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_idThe ID of the Web Server
log_field_idThe ID of the log field
new_listThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
itemThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
itemThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
itemThe item to remove from the list
See also
BWlist

◆ changeIisLogsBaseNames()

void Craplog::changeIisLogsBaseNames ( const int &  module_id)
private

Changes the name criterions for IIS logs files names depending on the given module.

Parameters
module_idThe 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

◆ getBlacklist()

const std::vector< std::string > & Craplog::getBlacklist ( const int &  web_server_id,
const int &  log_field_id 
) const

Returns the relative items list.

Parameters
web_server_idThe ID of the Web Server
log_field_idThe ID of the log field
Returns
The list of items in the given blacklist
See also
BWlist

◆ getCurrentLogFormat()

const FormatOps::LogsFormat & Craplog::getCurrentLogFormat ( ) const

Returns the currently used LogsFormat.

Returns
The LogsFormat
See also
FormatOps::LogsFormat

◆ getCurrentWSID()

const int & Craplog::getCurrentWSID ( ) const

Returns the currently used Web Server ID.

Returns
The Web Server ID

◆ getLogFileItem()

const Craplog::LogFile & Craplog::getLogFileItem ( const QString &  file_name) const

Returns the LogFile instance of the given file.

Parameters
file_nameThe 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) const

Returns the LogsFormat currently set for the given Web Server.

Parameters
web_server_idID of the Web Server
Returns
The LogsFormat instance
See also
FormatOps::LogsFormat

◆ getLogsFormatSample()

const QString Craplog::getLogsFormatSample ( const int &  web_server_id) const

Returns a sample log line for the given Web Server using the relative LogsFormat.

Parameters
web_server_idID of the Web Server
Returns
The sample of a log line
Exceptions
WebServerException
See also
FormatOps::getApacheLogSample(), FormatOps::getNginxLogSample(), FormatOps::getIisLogSample()

◆ getLogsFormatString()

const std::string & Craplog::getLogsFormatString ( const int &  web_server_id) const

Returns the logs format string for the given Web Server.

Parameters
web_server_idID 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
freshWhether 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 ( ) const

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) const

Returns the logs' path for the given web Server.

Parameters
web_serverThe 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 
) const

Returns the relative items list.

Parameters
web_server_idThe ID of the Web Server
log_field_idThe 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 
) const

Returns whether the relative blacklist is set to be used or not.

Parameters
web_server_idThe ID of the Web Server
log_field_idThe 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) const

Checks if a file name respects the relative criterions.

Parameters
nameThe 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 
) const

Returns whether the relative warnlist is set to be used or not.

Parameters
web_server_idThe ID of the Web Server
log_field_idThe ID of the log field
Returns
Whether the list is used or not
See also
BWlist

◆ makeChart()

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.

Parameters
themeThe theme to use for the Chart
fontsThe map holding the fonts
size_chartThe widget which will display the chart
See also
DonutBreakdown

◆ sanitizeBWitem()

const std::string Craplog::sanitizeBWitem ( const int &  log_field_id,
const std::string &  new_item 
) const
private

Ssnitizes an item removing the unwanted elements.

Called when adding a new item to a list

Parameters
log_field_idThe ID of the log field
new_itemThe 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_stringThe logs format string
Returns
Whether the process was successful or not
See also
FormatOps, FormatOps::LogsFormat, FormatOps::processApacheFormatString()

◆ 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_idThe ID of the Web Server
log_field_idThe ID of the log field
new_listThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
usedWhether the list is to be used or not
See also
BWlist

◆ setCurrentLogFormat()

void Craplog::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_idThe new currently used Web Server

◆ setHashesDatabasePath()

void Craplog::setHashesDatabasePath ( const std::string &  path)

Sets the new path for the log files' Hashes database.

Parameters
Thenew 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_stringThe logs format string
log_moduleThe IIS logs module to be used to parse the format string
Returns
Whether the process was successful or not
See also
FormatOps, FormatOps::LogsFormat, FormatOps::processIisFormatString()

◆ setLogFileSelected()

const bool Craplog::setLogFileSelected ( const QString &  file_name)

Sets a file in the list as selected.

Parameters
file_nameThe 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_serverThe ID of the Web Server
new_pathThe new path

◆ setNginxLogFormat()

const bool Craplog::setNginxLogFormat ( const std::string &  format_string)

Sets the Nginx LogsFormat from the given format string.

Parameters
format_stringThe logs format string
Returns
Whether the process was successful or not
See also
FormatOps, FormatOps::LogsFormat, FormatOps::processNginxFormatString()

◆ setStatsDatabasePath()

void Craplog::setStatsDatabasePath ( const std::string &  path)

Sets the new path for the logs Collection database.

Parameters
Thenew 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_idThe ID of the Web Server
log_field_idThe ID of the log field
new_listThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
usedWhether the list is to be used or not
See also
BWlist

◆ 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_idThe ID of the Web Server
log_field_idThe ID of the log field
new_itemThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
itemThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
itemThe 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_idThe ID of the Web Server
log_field_idThe ID of the log field
itemThe 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 doxygen 1.9.5 </html>