App::Hachero::Plugin::Parse::Common - parses common apache logs


App-Hachero documentation Contained in the App-Hachero distribution.

Index


Code Index:

NAME

Top

App::Hachero::Plugin::Parse::Common - parses common apache logs

SYNOPSYS

Top

  ---
  plugins:
    - module: Parse::Common
      config:
        format: ':common'

DESCRIPTION

Top

parses common apache logs

implemented hooks

* parse

AUTHOR

Top

Takaaki Mizuno <cpan@takaaki.info>

Nobuo Danjou <nobuo.danjou@gmail.com>

SEE ALSO

Top

App::Hachero

Regexp::Log::Common


App-Hachero documentation Contained in the App-Hachero distribution.

package App::Hachero::Plugin::Parse::Common;
use strict;
use warnings;
use base qw(App::Hachero::Plugin::Base);
use Regexp::Log::Common;

sub initialize : Hook {
    my ($self, $context) = @_;
    my $config = $self->config->{config};
    for (keys %{$config->{REGEXP}}) {
        $Regexp::Log::Common::REGEXP{$_} = $config->{REGEXP}->{$_};
    }
    my $regexp = Regexp::Log::Common->new(
        format => $config->{format} || ':extended',
        ($config->{capture} ? (capture => $config->{capture}) : ()),
    );
    $self->{re} = $regexp->regexp;
    @{$self->{capture}} = $regexp->capture;
}

sub parse : Hook {
    my ($self, $context, $args) = @_;
    my %data;
    @data{@{$self->{capture}}} = $context->currentline =~ /$self->{re}/;
    $context->currentlog(\%data);
}

1;
__END__