my $time_pattern = qr/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/;
my $cur_pid = '';
+ my @matches = ();
+ my $goon = 0;
while (my $line = <$lfile>) {
$cursize += length($line);
chomp($line);
}
}
+ %prefix_vars = ();
+
# Parse syslog lines
if ($format =~ /syslog/) {
- my @matches = ($line =~ $compiled_prefix);
+ @matches = ($line =~ $compiled_prefix);
if ($#matches >= 0) {
# Jump to the last line parsed if required
next if (!&check_incremental_position($prefix_vars{'t_date'}, $line));
$cur_pid = $prefix_vars{'t_pid'};
+ $goon = 1;
# Store the current timestamp of the log line
if (!$first_log_date || ($first_log_date > $prefix_vars{'t_date'})) {
&parse_query();
}
- } elsif ($line =~ $other_syslog_line) {
+ } elsif ($goon && ($line =~ $other_syslog_line)) {
$cur_pid = $8;
my $t_query = $10;
}
# Collect orphans lines of multiline queries
- } elsif ($line !~ $orphan_syslog_line) {
+ } elsif ($cur_pid && ($line !~ $orphan_syslog_line)) {
if ($cur_info{$cur_pid}{statement}) {
$cur_info{$cur_pid}{statement} .= "\n" . $line;
} elsif ($format eq 'stderr') {
- %prefix_vars = ();
- my @matches = ($line =~ $compiled_prefix);
+ @matches = ($line =~ $compiled_prefix);
if ($#matches >= 0) {
for (my $i = 0 ; $i <= $#prefix_params ; $i++) {
$prefix_vars{$prefix_params[$i]} = $matches[$i];
}
# Collect orphans lines of multiline queries
- } elsif ($line !~ $orphan_stderr_line) {
+ } elsif ($cur_pid && ($line !~ $orphan_stderr_line)) {
if ($cur_info{$cur_pid}{statement}) {
$cur_info{$cur_pid}{statement} .= "\n" . $line;
$cur_info{$cur_pid}{query} .= "\n" . $line;
}
- } elsif ($cur_info{$cur_pid}{query}) {
+ } elsif ($cur_pid && ($cur_info{$cur_pid}{query})) {
$cur_info{$cur_pid}{query} .= "\n" . $line;
}