LogDoctor/docs/html/classCraplog.html

94 KiB

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

Craplog. More...

#include <craplog.h>

Inheritance diagram for Craplog:

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 LogsFormatgetCurrentLogFormat () 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 LogFilegetLogFileItem (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 LogsFormatgetLogsFormat (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.
 

Detailed Description

Craplog.

Performs operations related to the logs

Member Function Documentation

◆ blacklistAdd()

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.

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

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.

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

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.

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 unsigned &  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()

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

◆ clearLogFilesSelection()

void Craplog::clearLogFilesSelection ( )

Sets all files in the list as unselected.

Returns
Wheter the given file name has been found in the list
See also
LogFile, logs_list

◆ getBlacklist()

const std::vector< std::string > & Craplog::getBlacklist ( const unsigned &  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 LogsFormat & Craplog::getCurrentLogFormat ( ) const

Returns the currently used LogsFormat.

Returns
The LogsFormat
See also
LogsFormat

◆ getCurrentWSID()

unsigned Craplog::getCurrentWSID ( ) const

Returns the currently used Web Server ID.

Returns
The Web Server ID

◆ getLogFileItem()

const 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 LogsFormat & Craplog::getLogsFormat ( const unsigned &  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
LogsFormat

◆ getLogsFormatSample()

QString Craplog::getLogsFormatSample ( const unsigned &  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 unsigned &  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< LogFile > & Craplog::getLogsList ( ) const

Returns the list of log files for the current WebServer.

Returns
The list of log files
See also
LogFile, logs_list

◆ getLogsListSize()

size_t 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 unsigned &  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 unsigned &  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()

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.

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

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

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.

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 base theme to use for the Chart
fontsThe map holding the fonts
size_chartThe widget which will display the chart
See also
DonutBreakdown

◆ sanitizeBWitem()

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

Sanitizes 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()

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 unsigned &  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 unsigned &  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 ( )

Uses the current Web Server to set the relative logs format.

See also
LogsFormat

◆ setCurrentWSID()

void Craplog::setCurrentWSID ( const unsigned  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()

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

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 unsigned &  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()

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 unsigned &  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 unsigned &  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 unsigned &  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()

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.

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

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.

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 unsigned &  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.8 </html>