mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 11:19:26 +02:00
Added code to init advanced filters automatically in report classes
This commit is contained in:
parent
ac54dc1d28
commit
d6621372e1
@ -111,6 +111,11 @@ abstract class Report {
|
||||
public abstract function RemoveReport();
|
||||
|
||||
|
||||
/**
|
||||
* This function will init advanced settings from _customFilters string
|
||||
*/
|
||||
public abstract function InitAdvancedSettings();
|
||||
|
||||
/**
|
||||
* verifyDataSource, verifies if data is accessable and
|
||||
* contains what we need
|
||||
@ -235,6 +240,9 @@ abstract class Report {
|
||||
// Set new Outputtype
|
||||
$this->_customFilters = $newAdvancedOptions;
|
||||
|
||||
// Call report function to init advanced settings!
|
||||
$this->InitAdvancedSettings();
|
||||
|
||||
// echo "TODO SetCustomFilters";
|
||||
// exit;
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ class Report_monilog extends Report {
|
||||
'DescriptLangID'=> 'ln_report_maxHosts_description',
|
||||
FILTER_TYPE => FILTER_TYPE_NUMBER,
|
||||
'DefaultValue' => 20,
|
||||
'MinValue' => 0,
|
||||
'MaxValue' => 0,
|
||||
'MinValue' => 1,
|
||||
/* 'MaxValue' => 0,*/
|
||||
);
|
||||
$this->_arrCustomFilters['_maxEventsPerHost'] =
|
||||
array ( 'InternalID' => '_maxEventsPerHost',
|
||||
@ -95,8 +95,8 @@ class Report_monilog extends Report {
|
||||
'DescriptLangID'=> 'ln_report_maxEventsPerHost_description',
|
||||
FILTER_TYPE => FILTER_TYPE_NUMBER,
|
||||
'DefaultValue' => 100,
|
||||
'MinValue' => 0,
|
||||
'MaxValue' => 0,
|
||||
'MinValue' => 1,
|
||||
/* 'MaxValue' => 0,*/
|
||||
);
|
||||
$this->_arrCustomFilters['_colorThreshold'] =
|
||||
array ( 'InternalID' => '_colorThreshold',
|
||||
@ -104,8 +104,8 @@ class Report_monilog extends Report {
|
||||
'DescriptLangID'=> 'ln_report_colorThreshold_description',
|
||||
FILTER_TYPE => FILTER_TYPE_NUMBER,
|
||||
'DefaultValue' => 10,
|
||||
'MinValue' => 0,
|
||||
'MaxValue' => 0,
|
||||
'MinValue' => 1,
|
||||
/* 'MaxValue' => 0,*/
|
||||
);
|
||||
|
||||
|
||||
@ -235,6 +235,59 @@ class Report_monilog extends Report {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init advanced settings from _customFilters string
|
||||
*/
|
||||
public function InitAdvancedSettings()
|
||||
{
|
||||
// Parse and Split _customFilters
|
||||
if ( strlen($this->_customFilters) > 0 )
|
||||
{
|
||||
// First of all split by comma
|
||||
$tmpFilterValues = explode( ",", $this->_customFilters );
|
||||
|
||||
//Loop through mappings
|
||||
foreach ($tmpFilterValues as &$myFilterValue )
|
||||
{
|
||||
// Split subvalues
|
||||
$tmpArray = explode( "=>", $myFilterValue );
|
||||
|
||||
// Set into temporary array
|
||||
$tmpfilterid = trim($tmpArray[0]);
|
||||
|
||||
// Set advanced property
|
||||
if ( isset($this->_arrCustomFilters[$tmpfilterid]) )
|
||||
{
|
||||
// Copy New value first!
|
||||
$szNewVal = trim($tmpArray[1]);
|
||||
|
||||
// Negated logic
|
||||
if (
|
||||
$this->_arrCustomFilters[$tmpfilterid][FILTER_TYPE] == FILTER_TYPE_NUMBER &&
|
||||
!(isset($this->_arrCustomFilters[$tmpfilterid]['MinValue']) && intval($szNewVal) < $this->_arrCustomFilters[$tmpfilterid]['MinValue']) &&
|
||||
!(isset($this->_arrCustomFilters[$tmpfilterid]['MaxValue']) && intval($szNewVal) >= $this->_arrCustomFilters[$tmpfilterid]['MaxValue'])
|
||||
)
|
||||
{
|
||||
if ( $tmpfilterid == '_maxHosts' )
|
||||
$_maxHosts = $nNewVal;
|
||||
else if ( $tmpfilterid == '_maxEventsPerHost' )
|
||||
$_maxEventsPerHost = $nNewVal;
|
||||
else if ( $tmpfilterid == '_colorThreshold' )
|
||||
$_colorThreshold = $nNewVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write to debuglog
|
||||
OutputDebugMessage("Failed setting advanced report option property '" . $tmpfilterid . "', value not in value range!", DEBUG_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- Private functions...
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user