| #!/usr/bin/env perl |
| use Mojo::Base -strict; |
| use Mojo::File qw'path'; |
| |
| our @ARGV; |
| my ($unable, $unable_substring, $unable_offsets) = (0,0,0); |
| |
| my $file = path($ARGV[0]); |
| my $out_fh = path($file->dirname)->child( |
| $file->basename('.log') . '-slim.log' |
| )->open('>'); |
| |
| my $fh = $file->open('<'); |
| |
| # Iterate over file |
| while (!eof($fh)){ |
| local $_ = <$fh>; |
| |
| if ($_ =~ qr!(?: Processed)! && $_ !~ qr!:1\/!) { |
| next; |
| }; |
| |
| if ($_ =~ qr! Unable to process !) { |
| $unable++; |
| next; |
| } |
| elsif ($_ =~ qr! Tokenization with failing offsets !) { |
| $unable_offsets++; |
| next; |
| } |
| elsif ($_ =~ qr! Unable to find substring !) { |
| $unable_substring++; |
| next; |
| } |
| elsif ($_ =~ qr!^Done\.$!) { |
| my $str = 'Done.'; |
| $str .= ' [!Process: ' . $unable . ']' if $unable; |
| $str .= ' [!Offstes: ' . $unable_offsets . ']' if $unable_offsets; |
| $str .= ' [!Substring: ' . $unable_substring . ']' if $unable_substring; |
| $unable = 0; |
| $unable_substring = 0; |
| $unable_offsets = 0; |
| print $out_fh "## $str\n"; |
| next; |
| }; |
| |
| if ($_ =~ qr! Unable to (?:process|find substring) !) { |
| next; |
| } |
| elsif ($_ =~ qr!substr outside of string!) { |
| next; |
| } |
| elsif ($_ =~ qr!with failing offsets!) { |
| next; |
| } |
| elsif ($_ =~ qr! in \/opt\/korap!) { |
| next; |
| }; |
| |
| print $out_fh $_; |
| }; |
| |
| $out_fh->close; |
| $fh->close; |
| |
| __END__ |
| |
| =pod |
| |
| $ slim_korapxml2krill mylog.log |
| |
| =cut |