parent
73f4512a45
commit
d34d122d1f
|
@ -27,6 +27,8 @@ Craplog::Craplog()
|
|||
////////////////////////
|
||||
//// INITIALIZATION ////
|
||||
////////////////////////
|
||||
// shared mutex
|
||||
this->logOps.setMutex( &this->mutex );
|
||||
// blacklists / whitelists
|
||||
for ( int i=this->APACHE_ID; i<=this->IIS_ID; i++ ) {
|
||||
this->warnlists.emplace( i, std::unordered_map<int, BWlist>() );
|
||||
|
@ -665,6 +667,7 @@ const bool Craplog::isFileNameValid( const std::string& name ) const
|
|||
//// WORKK ////
|
||||
void Craplog::startWorking()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
this->working = true;
|
||||
this->parsing = true;
|
||||
this->proceed = true;
|
||||
|
@ -683,15 +686,18 @@ void Craplog::startWorking()
|
|||
}
|
||||
void Craplog::stopWorking()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
this->working = false;
|
||||
this->parsing = false;
|
||||
}
|
||||
const bool& Craplog::isWorking() const
|
||||
const bool& Craplog::isWorking()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
return this->working;
|
||||
}
|
||||
const bool& Craplog::isParsing() const
|
||||
const bool& Craplog::isParsing()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
return this->parsing;
|
||||
}
|
||||
const bool& Craplog::editedDatabase() const
|
||||
|
@ -700,39 +706,45 @@ const bool& Craplog::editedDatabase() const
|
|||
}
|
||||
|
||||
// performances
|
||||
const unsigned int &Craplog::getPerfSize() const
|
||||
const unsigned &Craplog::getPerfSize()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
return this->perf_size;
|
||||
}
|
||||
/*void Craplog::sumPerfSize( const unsigned& size )
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
this->perf_size += size;
|
||||
this->parsed_size += size;
|
||||
}*/
|
||||
const unsigned int &Craplog::getTotalSize() const
|
||||
const unsigned &Craplog::getTotalSize()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
return this->total_size;
|
||||
}
|
||||
/*const unsigned int &Craplog::getParsedSize()
|
||||
/*const unsigned &Craplog::getParsedSize()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
return this->parsed_size;
|
||||
}*/
|
||||
const unsigned int &Craplog::getParsedLines() const
|
||||
const unsigned &Craplog::getParsedLines()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
return this->parsed_lines;
|
||||
}
|
||||
|
||||
void Craplog::sumWarningsSize( const unsigned int& size )
|
||||
void Craplog::sumWarningsSize( const unsigned& size )
|
||||
{
|
||||
this->warnlisted_size += size;
|
||||
}
|
||||
void Craplog::sumBlacklistededSize( const unsigned int& size )
|
||||
void Craplog::sumBlacklistededSize( const unsigned& size )
|
||||
{
|
||||
this->blacklisted_size += size;
|
||||
}
|
||||
|
||||
void Craplog::collectPerfData()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( this->mutex );
|
||||
this->parsed_size = this->logOps.getParsedSize();
|
||||
this->parsed_lines = this->logOps.getParsedLines();
|
||||
this->perf_size = this->parsed_size;
|
||||
|
@ -1071,7 +1083,7 @@ void Craplog::storeLogLines()
|
|||
}
|
||||
|
||||
|
||||
const QString Craplog::printableSize( const unsigned int& bytes ) const
|
||||
const QString Craplog::printableSize( const unsigned& bytes ) const
|
||||
{
|
||||
std::string size_str, size_sfx=" B";
|
||||
float size = (float)bytes;
|
||||
|
|
|
@ -410,10 +410,10 @@ public:
|
|||
void clearDataCollection();
|
||||
|
||||
//! Returns whether the process is still running or not
|
||||
const bool& isWorking() const;
|
||||
const bool& isWorking();
|
||||
|
||||
//! Returns whether the process is still parsing or not
|
||||
const bool& isParsing() const;
|
||||
const bool& isParsing();
|
||||
|
||||
|
||||
//////////////////////
|
||||
|
@ -434,13 +434,13 @@ public:
|
|||
/*void sumPerfSize( const unsigned& size );*/
|
||||
|
||||
//! Returns the size to be displayed in the main window
|
||||
const unsigned int& getPerfSize() const;
|
||||
const unsigned int& getPerfSize();
|
||||
|
||||
//! Returns the total logs size
|
||||
const unsigned int& getTotalSize() const;
|
||||
const unsigned int& getTotalSize();
|
||||
|
||||
//! Returns the parsed logs lines
|
||||
const unsigned int& getParsedLines() const;
|
||||
const unsigned int& getParsedLines();
|
||||
|
||||
/*const unsigned int& getParsedSize();*/
|
||||
|
||||
|
@ -485,6 +485,7 @@ private:
|
|||
bool working = false;
|
||||
bool parsing = false;
|
||||
bool proceed = false;
|
||||
std::mutex mutex;
|
||||
|
||||
//! Sets the working state
|
||||
/*!
|
||||
|
|
|
@ -13,6 +13,12 @@ LogOps::LogOps()
|
|||
}
|
||||
|
||||
|
||||
void LogOps::setMutex( std::mutex* craplog_mutex )
|
||||
{
|
||||
this->mutex = craplog_mutex;
|
||||
}
|
||||
|
||||
|
||||
const LogOps::LogType LogOps::defineFileType( const std::vector<std::string>& lines, const FormatOps::LogsFormat& format ) const
|
||||
{
|
||||
if ( lines.size() == 0 ) {
|
||||
|
@ -255,7 +261,10 @@ const std::unordered_map<int, std::string> LogOps::parseLine( const std::string&
|
|||
}
|
||||
|
||||
// process the field
|
||||
this->parsed_size += fld_str.size();
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( *this->mutex );
|
||||
this->parsed_size += fld_str.size();
|
||||
}
|
||||
|
||||
if ( fld_str != "" ) {
|
||||
int fld_id = this->field2id.at(fld);
|
||||
|
@ -410,9 +419,11 @@ const std::unordered_map<int, std::string> LogOps::parseLine( const std::string&
|
|||
|
||||
// set the default warning mark ( 0=false ) to default status
|
||||
data.emplace( 99, "0" );
|
||||
|
||||
this->total_size += line_size;
|
||||
this->parsed_lines ++;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( *this->mutex );
|
||||
this->total_size += line_size;
|
||||
this->parsed_lines ++;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -451,15 +462,18 @@ void LogOps::resetPerfData()
|
|||
this->parsed_size = 0;
|
||||
this->parsed_lines = 0;
|
||||
}
|
||||
const unsigned LogOps::getTotalSize() const
|
||||
const unsigned LogOps::getTotalSize()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( *this->mutex );
|
||||
return this->total_size;
|
||||
}
|
||||
const unsigned LogOps::getParsedSize() const
|
||||
const unsigned LogOps::getParsedSize()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( *this->mutex );
|
||||
return this->parsed_size;
|
||||
}
|
||||
const unsigned LogOps::getParsedLines() const
|
||||
const unsigned LogOps::getParsedLines()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock( *this->mutex );
|
||||
return this->parsed_lines;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
|
||||
#include "modules/craplog/modules/formats.h"
|
||||
|
||||
|
@ -17,6 +18,14 @@ class LogOps
|
|||
public:
|
||||
explicit LogOps();
|
||||
|
||||
|
||||
//! Receives the mutex to be shared with Craplog
|
||||
/*!
|
||||
\param craplog_mutex The mutex from Craplog
|
||||
*/
|
||||
void setMutex( std::mutex* craplog_mutex=nullptr );
|
||||
|
||||
|
||||
//! Enumerates log file types
|
||||
/*!
|
||||
File types used to decide whether a file should be considered valid or not
|
||||
|
@ -66,9 +75,9 @@ public:
|
|||
void resetPerfData();
|
||||
|
||||
// share perf data with craplog
|
||||
const unsigned getTotalSize() const; //!< Returns the total size of the logs lines. \see total_size
|
||||
const unsigned getParsedSize() const; //!< Returns the parsed logs size. \see parsed_size
|
||||
const unsigned getParsedLines() const; //!< Returns the number of parsed log lines. \see parsed_lines
|
||||
const unsigned getTotalSize(); //!< Returns the total size of the logs lines. \see total_size
|
||||
const unsigned getParsedSize(); //!< Returns the parsed logs size. \see parsed_size
|
||||
const unsigned getParsedLines(); //!< Returns the number of parsed log lines. \see parsed_lines
|
||||
|
||||
private:
|
||||
|
||||
|
@ -146,6 +155,9 @@ private:
|
|||
const FormatOps::LogsFormat& format
|
||||
);
|
||||
|
||||
// a mutex shared with craplog
|
||||
std::mutex* mutex = nullptr;
|
||||
|
||||
// temporary vars
|
||||
unsigned total_size=0; //!< Total size of the parsed logs. \see getTotalSize()
|
||||
unsigned parsed_size=0; //!< Size of the parsed logs. \see getParsedSize()
|
||||
|
|
Loading…
Reference in New Issue