mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 11:19:26 +02:00
Implemented displaying filters in reports
This commit is contained in:
parent
d2eb2bb0bf
commit
3d1d88a4aa
@ -527,6 +527,15 @@ abstract class LogStream {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to obtain internal Filters Array
|
||||
*/
|
||||
public function ReturnFiltersArray()
|
||||
{
|
||||
return $this->_filters;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* --- PIRVATE HELPERS!
|
||||
*/
|
||||
|
@ -271,6 +271,128 @@ abstract class Report {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper function to set the FilterString
|
||||
*/
|
||||
public function SetCommonContentVariables()
|
||||
{
|
||||
global $content, $fields;
|
||||
|
||||
$content["report_title"] = $this->GetCustomTitle();
|
||||
$content["report_comment"] = $this->GetCustomComment();
|
||||
$content["report_version"] = $this->GetReportVersion();
|
||||
|
||||
// Create array for readable filters display
|
||||
$myFilters = $this->_streamObj->ReturnFiltersArray();
|
||||
if ( $myFilters != null )
|
||||
{
|
||||
// Enable display of filters
|
||||
$content["report_filters_enabled"] = true;
|
||||
|
||||
foreach ( $myFilters as $myFieldID => $myFieldFilters )
|
||||
{
|
||||
// Init Filterstring entry
|
||||
$aNewDisplayFilter = array();
|
||||
$aNewDisplayFilter['FilterDisplay'] = "";
|
||||
$aNewDisplayFilter['FieldID'] = $myFieldID;
|
||||
if ( isset($fields[$myFieldID]['FieldCaption']) )
|
||||
$aNewDisplayFilter['FilterCaption'] = $fields[$myFieldID]['FieldCaption'];
|
||||
else
|
||||
$aNewDisplayFilter['FilterCaption'] = $myFieldID;
|
||||
|
||||
|
||||
|
||||
foreach ( $myFieldFilters as $tmpFilter )
|
||||
{
|
||||
// Date field means special handling!
|
||||
if ( $myFieldID == SYSLOG_DATE )
|
||||
{
|
||||
// Set Filtertype Display
|
||||
$aNewDisplayFilter['FilterType'] = $content['LN_REPORT_FILTERTYPE_DATE'];
|
||||
|
||||
// Append Datefilter to Title
|
||||
// $content["report_title"] .=
|
||||
|
||||
if ( $tmpFilter[FILTER_DATEMODE] == DATEMODE_LASTX )
|
||||
{
|
||||
$aNewDisplayFilter['FilterDisplay'] = $content['LN_FILTER_DATELASTX'] . " ";
|
||||
switch ( $tmpFilter[FILTER_VALUE] )
|
||||
{
|
||||
case DATE_LASTX_HOUR:
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "'" . $content['LN_DATE_LASTX_HOUR'] . "'";
|
||||
break;
|
||||
case DATE_LASTX_12HOURS:
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "'" . $content['LN_DATE_LASTX_12HOURS'] . "'";
|
||||
break;
|
||||
case DATE_LASTX_24HOURS:
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "'" . $content['LN_DATE_LASTX_24HOURS'] . "'";
|
||||
break;
|
||||
case DATE_LASTX_7DAYS:
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "'" . $content['LN_DATE_LASTX_7DAYS'] . "'";
|
||||
break;
|
||||
case DATE_LASTX_31DAYS:
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "'" . $content['LN_DATE_LASTX_31DAYS'] . "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( $tmpFilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
|
||||
$aNewDisplayFilter['FilterDisplay'] = $content["LN_FILTER_DATEFROM"] . " " . GetFormatedDate( $tmpFilter[FILTER_VALUE] );
|
||||
else if ( $tmpFilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
|
||||
$aNewDisplayFilter['FilterDisplay'] = $content["LN_FILTER_DATETO"] . " " . GetFormatedDate( $tmpFilter[FILTER_VALUE] );
|
||||
|
||||
// Add to title!
|
||||
$content["report_title"] .= " - " . $aNewDisplayFilter['FilterDisplay'];
|
||||
}
|
||||
else if ( $tmpFilter[FILTER_TYPE] == FILTER_TYPE_STRING )
|
||||
{
|
||||
// Set Filtertype Display
|
||||
$aNewDisplayFilter['FilterType'] = $content['LN_REPORT_FILTERTYPE_STRING'];
|
||||
|
||||
// Set Filterdisplay
|
||||
$aNewDisplayFilter['FilterDisplay'] .= $aNewDisplayFilter['FilterCaption'] . " ";
|
||||
if ( $tmpFilter[FILTER_MODE] & FILTER_MODE_INCLUDE )
|
||||
{
|
||||
if ( $tmpFilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL )
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "equals '" . $tmpFilter[FILTER_VALUE] . "'";
|
||||
else
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "contains '" . $tmpFilter[FILTER_VALUE] . "'";
|
||||
}
|
||||
else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE )
|
||||
{
|
||||
if ( $tmpFilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL )
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "does not equal '" . $tmpFilter[FILTER_VALUE] . "'";
|
||||
else
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "does not contain '" . $tmpFilter[FILTER_VALUE] . "'";
|
||||
}
|
||||
}
|
||||
else if ( $tmpFilter[FILTER_TYPE] == FILTER_TYPE_NUMBER )
|
||||
{
|
||||
// Set Filtertype Display
|
||||
$aNewDisplayFilter['FilterType'] = $content['LN_REPORT_FILTERTYPE_NUMBER'];
|
||||
|
||||
// Set Filterdisplay
|
||||
$aNewDisplayFilter['FilterDisplay'] .= $aNewDisplayFilter['FilterCaption'] . " ";
|
||||
if ( $tmpFilter[FILTER_MODE] & FILTER_MODE_INCLUDE )
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "== " . $tmpFilter[FILTER_VALUE];
|
||||
else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE )
|
||||
$aNewDisplayFilter['FilterDisplay'] .= "!= " . $tmpFilter[FILTER_VALUE];
|
||||
}
|
||||
|
||||
// Add to display filter array
|
||||
if ( strlen($aNewDisplayFilter['FilterDisplay']) > 0 )
|
||||
$content["report_filters"][] = $aNewDisplayFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable display of filters
|
||||
$content["report_filters_enabled"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper function to return the BaseFileName
|
||||
*/
|
||||
|
@ -112,14 +112,11 @@ class Report_monilog extends Report {
|
||||
// // Verify Datasource first!
|
||||
// if ( $this->verifyDataSource() == SUCCESS )
|
||||
// {
|
||||
// Get Settings and set to global content variable
|
||||
$content["report_title"] = $this->GetCustomTitle();
|
||||
$content["report_comment"] = $this->GetCustomComment();
|
||||
$content["report_version"] = $this->GetReportVersion();
|
||||
// Set to common content variables
|
||||
$this->SetCommonContentVariables();
|
||||
|
||||
// --- Report logic starts here
|
||||
$content["report_rendertime"] = "";
|
||||
|
||||
|
||||
// Step 1: Gather Summaries
|
||||
// Obtain data from the logstream!
|
||||
|
@ -18,6 +18,27 @@
|
||||
<tr>
|
||||
<td class="titleSecond" width="100%" align="left">{report_comment}</td>
|
||||
</tr>
|
||||
<!-- IF report_filters_enabled="true" -->
|
||||
<tr>
|
||||
<td class="tableBackground" width="100%" align="left">
|
||||
|
||||
<table width="50%" cellpadding="0" cellspacing="1" border="0" align="left" class="with_border_alternate">
|
||||
<tr>
|
||||
<td class="cellmenu1" colspan="2" align="center">{LN_REPORT_FILTERS}</td>
|
||||
</tr>
|
||||
<!-- BEGIN report_filters -->
|
||||
<tr>
|
||||
<td class="cellmenu2">{FilterType}</td>
|
||||
<td class="line1" align="left"><b>{FilterDisplay}</b></td>
|
||||
</tr>
|
||||
<!-- END report_filters -->
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<!-- ENDIF report_filters_enabled="true" -->
|
||||
</table>
|
||||
|
||||
<br/><br/>
|
||||
@ -42,7 +63,7 @@
|
||||
<!-- END report_summary -->
|
||||
</table>
|
||||
|
||||
<table width="600" cellpadding="0" cellspacing="1" border="0" align="right" class="with_border_alternate">
|
||||
<table width="50%" cellpadding="0" cellspacing="1" border="0" align="right" class="with_border_alternate">
|
||||
<tr>
|
||||
<td class="cellmenu1" colspan="2" align="center">{ln_report_computer_summary}</td>
|
||||
</tr>
|
||||
@ -59,6 +80,8 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="with_border">
|
||||
<tr>
|
||||
<td class="title" width="100%" nowrap><B>{ln_report_consolidation}</B></td>
|
||||
@ -68,7 +91,6 @@
|
||||
|
||||
|
||||
<!-- BEGIN report_consdata -->
|
||||
<br/><br/>
|
||||
<h3><a name="{FROMHOST}">{FROMHOST}</a></h3>
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="1" border="0" align="center" class="with_border_alternate">
|
||||
|
@ -341,8 +341,11 @@ $content['LN_ORACLE_WHOIS'] = "WHOIS Lookup for '%1' value '%2'";
|
||||
$content['LN_GEN_ERROR_WHILEREPORTGEN'] = "Error occured while generating report";
|
||||
$content['LN_GEN_ERROR_REPORT_NODATA'] = "No data found for report generation";
|
||||
$content['LN_GEN_ALL_OTHER_EVENTS'] = "All other events";
|
||||
$content['LN_REPORT_FOOTER_ENDERED'] = "Report rendered in:";
|
||||
|
||||
$content['LN_REPORT_FOOTER_ENDERED'] = "Report rendered in";
|
||||
$content['LN_REPORT_FILTERS'] = "List of used filters";
|
||||
$content['LN_REPORT_FILTERTYPE_DATE'] = "Date";
|
||||
$content['LN_REPORT_FILTERTYPE_NUMBER'] = "Number";
|
||||
$content['LN_REPORT_FILTERTYPE_STRING'] = "String";
|
||||
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user