From 0177d1906d774a4b075d7530decc0f6a97f1bbb1 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Mon, 2 Oct 2023 18:13:05 -0600 Subject: [PATCH] Changes on log result --- pandora_agents/pc/pandora_agent | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index 798d0ba5af..58b415ba0e 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -1883,11 +1883,14 @@ sub grep_logs { # Create index file if it does not exist my $idx_file = $idx_dir.$module_name."_".basename($log_file).".idx"; if (! -e $idx_file) { - create_idx(); - } else { + return if create_idx() == 1; + } else{ return if load_idx() == 1; + my $result = parse_log(); - return if parse_log() == 1; + return if $result == 1; + + return $result; } # Start the function definition @@ -1920,7 +1923,7 @@ sub grep_logs { log_message("module_logger", "Error opening file $idx_file: ". $!); return 1; } - + print (IDXFILE $idx_pos . " " . $idx_ino); close(IDXFILE); @@ -1957,6 +1960,7 @@ sub grep_logs { } sub parse_log { + my $result = ""; my $line; log_message("module_logger", "Parsing log file $log_file"); @@ -1970,10 +1974,10 @@ sub grep_logs { # Go to starting position. seek(LOGFILE, $idx_pos, 0); - print STDOUT "\n"; - print STDOUT "\n"; - print STDOUT "\n"; - print STDOUT "\n"; + $result = $result . "\n"; + $result = $result . "\n"; + $result = $result . "\n"; + $result = $result . "\n"; # Parse log file while ($line = ) { @@ -1981,20 +1985,21 @@ sub grep_logs { # Remove the trailing '\n' chop($line); - print STDOUT "\n"; + $result = $result . "\n"; } } - print STDOUT "\n"; - print STDOUT "\n"; + $result = $result . "\n"; + $result = $result . "\n"; $idx_pos = tell(LOGFILE); close(LOGFILE); + print($result); # Save the index file return 1 if save_idx() == 1; - return 0; + return $result; } }