Suponho que o seu arquivo de log é assim?
example.log:
[09:44:22] [main] ERROR [url/location] - A ONE LINE ERROR
[09:44:22] [main] ERROR [url/location] - A MULTI LINE ERROR
with whitepace indention
[09:44:22] [main] ERROR [url/location] - A MULTI LINE ERROR
with tab indention
[09:44:22] [main] SOMETHING DIFFERENT
[09:44:22] [main] SOMETHING DIFFERENT
with tab indention
[09:44:22] [main] WARN [url/location] - ANOTHER ONE LINE WARN
É certo que não é um de uma linha e perl, mas deve fazer o trabalho:
logsifter.pl:
#!/usr/bin/perl
use warnings;
use strict;
my $buffer="";
while(my $line= <>){
chomp $line;
if($line=~/ERROR|INFO|WARN/){
print "$buffer\n" if $buffer;
$buffer = $line;
}
elsif($line=~/^\s+(.*)$/){
$buffer .= $1 if $buffer;
}
else{
if($buffer){
print "$buffer\n";
$buffer ="";
}
}
}
print "$buffer\n";
chame como:
perl logsifter.pl < example.log
[09:44:22] [main] ERROR [url/location] - A ONE LINE ERROR
[09:44:22] [main] ERROR [url/location] - A MULTI LINE ERROR with whitepace indention
[09:44:22] [main] ERROR [url/location] - A MULTI LINE ERROR with tab indention
[09:44:22] [main] WARN [url/location] - ANOTHER ONE LINE WARN