Parse::AccessLogEntry::Accessor - adds accessors to Parse::AccessLogEntry module.


Parse-AccessLogEntry-Accessor documentation Contained in the Parse-AccessLogEntry-Accessor distribution.

Index


Code Index:

NAME

Top

Parse::AccessLogEntry::Accessor - adds accessors to Parse::AccessLogEntry module.

VERSION

Top

Version 0.01

SYNOPSIS

Top

    use Parse::AccessLogEntry::Accessor;
    my $parser = Parse::AccessLogEntry::Accessor->new();

    # $line is a string containing one line of an access log
    $parser->parse($line);
    print $parser->host(), "\n";

DESCRIPTION

Top

This module is an Apache accesslog parser. It's based on Parse::AccessLogEntry module.

The key name of the hushref and the accessor of this name are offered.

CLASS METHODS

Top

new

Create an instance of Parse::AccessLogEntry::Accessor

INSTANCE METHODS

Top

parse

Parse one line of an Apache accesslog

host

Get client ip of the request

user

Get user logged in ("-" for none)

date

Get date of the request

time

Get server time of the request

diffgmt

Get server offset from GMT

rtype

Get type of request (GET, POST, etc)

file

Get file requested

proto

Get protocol used (HTTP/1.1, etc)

code

Get code returned by apache (200, 304, etc)

bytes

Get number of bytes returned to the client

refer

Get referrer

agent

Get user-agent

SEE ALSO

Top

Parse::AccessLogEntry

AUTHOR

Top

Ryoji Tanida, <amarisan@cpan.org>

COPYRIGHT & LICENSE

Top


Parse-AccessLogEntry-Accessor documentation Contained in the Parse-AccessLogEntry-Accessor distribution.

package Parse::AccessLogEntry::Accessor;

use warnings;
use strict;

our $VERSION = '0.01';

use base qw( Parse::AccessLogEntry Class::Accessor::Fast );
__PACKAGE__->mk_ro_accessors(qw(
    host    user  date  time
    diffgmt rtype file  proto
    code    bytes refer agent
));


sub new {
    my $class = shift;
    my $self  = $class->SUPER::new;

    return bless $self;
}

sub parse {
    my $self = shift;
    my $line = shift or die;

    my $ref = $self->SUPER::parse($line);

    while (my ($key, $val) = each %{$ref}) {
        $self->{$key} = $val;
    }
    return $self;
}

1;
__END__