Title: RE: Module for simple processing of "log" files

> I've found myself writing the same script again and again for
> a client.
>
> Given a set of log files, if such and such field match such and such
> condition, then process them in a certain way. I've put the logic
> in a module, and I'm now looking for a name for it. I'd also like
> to know if this module looks useful to others (it was to me, since it
> allowed me to write a CGI that "grepped" through numerous log files
> and returned a subset of them as an HTML or CSV file).
>
> The module works like this:
>
>     use Blah;    # not a very good name for CPAN :-)
>
>     my $blah = Blah->new(
>         delimiter => ':',
>         fields    => [qw( bap clank glipp plop )],
>         show      => \&show_my_data,
>     );
>
>     # quelques infos utiles
>     $blah->add_filter(
>         bap   => 'eq "zlopp"',
>         clank => '!~ /clunk_eth/',
>     );
>     $blah->add_file( glob "*.log" );
>
>     $blah->run;
>
> When the run() method is called, the object compute a piece of Perl
> code which is then eval()ed (with a localised @ARGV). The computed
> code is the following (note the use of arrays for the selection pass
> and of a hash for the processing):
>
>     while(<>) {
>         chomp;
>         my @data = "" qr{:};
>         if(    ( $data[1] !~ /clunk_eth/ )
>             && ( $data[0] eq "zlopp" ) )
>         {
>             my %data;
>             @data{qw(bap clank glipp plop)} = @data;
>             $self->{show}->(\%data);
>         }
>     }
>
> In future versions, I may add support for regular expressions for
> parsing the fields (thus allowing a nice connection with my
> other module
> Regexp::Log), the possibility to keep using an array for processing,
> and have a better interface to add conditions (this is very crude,
> and open to attacks if people using this module are not very careful).
>
> I haven't been very successful in finding a name for this module.
> Sébastien Aperghis-Tramoni proposed Log::Process, but maybe a name
> like Log::Processor would be better.
>
> Any other name ideas or comments about the module and its interface?

I started working on a project like this but never got around to finishing it. I called it "Generic Record Processing System" IE GRPS. The point being that this isnt a facility related to parsing log files, its a facility relating to processing any file of parsable records in a mechanical way.

Interesting rules would be stuff like set membership "is field x in set Y" (which would be implemented as a hash lookup etc). Also interesting would be a framwork for specifiying which ruleset to apply based on filename/directory conventions. Additionally stuff like record transformation, prefix matching and logical evaluation would be cool too.

Cheers,
Yves

Reply via email to