Adding new option log_module

This commit is contained in:
alejandro 2022-04-21 10:31:20 +02:00
parent 73bee44d93
commit 8845e37447
1 changed files with 37 additions and 20 deletions

View File

@ -469,6 +469,11 @@ sub parse_log ($$$$$$$$) {
# Go to starting position # Go to starting position
seek(LOGFILE, $Idx_pos, 0); seek(LOGFILE, $Idx_pos, 0);
if ($type eq "log_module"){
$buffer = "<log_module>\n";
$buffer .= "<source><![CDATA[" . $Module_name . "]]></source>\n";
$buffer .= "<data><![CDATA[";
} else {
$buffer .= "<module>\n"; $buffer .= "<module>\n";
$buffer .= "<name><![CDATA[" . $Module_name . "]]></name>\n"; $buffer .= "<name><![CDATA[" . $Module_name . "]]></name>\n";
$buffer .= "<description><![CDATA[" . $Description . "]]></description>\n"; $buffer .= "<description><![CDATA[" . $Description . "]]></description>\n";
@ -479,6 +484,7 @@ sub parse_log ($$$$$$$$) {
$buffer .= "<type><![CDATA[async_string]]></type>\n"; $buffer .= "<type><![CDATA[async_string]]></type>\n";
$buffer .= "<datalist>\n"; $buffer .= "<datalist>\n";
} }
}
while ($line = <LOGFILE>) { while ($line = <LOGFILE>) {
while (my ($key, $value) = each (%{$regexp_collection})) { while (my ($key, $value) = each (%{$regexp_collection})) {
@ -503,6 +509,11 @@ sub parse_log ($$$$$$$$) {
$buffer .= "<data><value><![CDATA[".$line."]]></value></data>\n"; $buffer .= "<data><value><![CDATA[".$line."]]></value></data>\n";
} }
if ($type eq "log_module") {
$line =~ s/\]\]/]]]]><![CDATA[/g;
$buffer .= $line."\n";
}
# Critical severity will prevail over other matches # Critical severity will prevail over other matches
if ($severity eq ""){ if ($severity eq ""){
$severity = $value->{"severity"}; $severity = $value->{"severity"};
@ -515,18 +526,20 @@ sub parse_log ($$$$$$$$) {
} }
} }
} }
if ($type ne "log_module"){
if ($type eq "return_ocurrences"){ if ($type eq "return_ocurrences"){
$buffer .= "<data><![CDATA[".$count."]]></data>\n"; $buffer .= "<data><![CDATA[".$count."]]></data>\n";
} else { } else {
$buffer .= "</datalist>\n"; $buffer .= "</datalist>\n";
} }
}
# Execute action if any match (always for last match) # Execute action if any match (always for last match)
if ($count > 0){ if ($count > 0){
`$action`; `$action`;
} }
if ($type ne "log_module"){
# Write severity field in XML # Write severity field in XML
if ($severity ne ""){ if ($severity ne ""){
$buffer .= "<status>$severity</status>\n"; $buffer .= "<status>$severity</status>\n";
@ -534,6 +547,10 @@ sub parse_log ($$$$$$$$) {
# End XML # End XML
$buffer .= "</module>\n"; $buffer .= "</module>\n";
}else {
$buffer .= "]]></data>\n";
$buffer .= "</log_module>\n";
}
# Update Index # Update Index
$Idx_pos = tell(LOGFILE); $Idx_pos = tell(LOGFILE);