Apache-Log-Spread

 view release on metacpan or  search on metacpan

Spread.pm  view on Meta::CPAN

    $hashref->{V} = $r->hostname;
}

sub MLS_LogFormat($$$$) 
{
    my ($cfg, $parms, $format, $name, $env) = @_;
   $cfg->{logformat}->{$name}= $format;
}

sub MLS_Log($$$$;$)
{
    my ($cfg, $parms, $fname, $format, $mask) = @_;
    my $env;
    eval "\$env = sub { my \$r = shift; $mask}"; 
    push @{$cfg->{mls_logs}}, { name => $fname, format => $format, mask => $env};
}

sub SpreadDaemon($$$)
{
    my ($cfg, $parms, $daemon) = @_;
    $cfg->{spreaddaemon} = $daemon;
}
	
1;
__END__

=head1 NAME

Apache::Log::Spread - Perl implementation of mod_log_spread for multicasting access logs.

=head1 SYNOPSIS

# In httpd.conf
PerlModule Apache::Log::Spread
PerlLogHandler 'Apache::Log::Spread->handler'
SpreadDaemon 4903
MLS_LogFormat "%h %{$cookie->isVisitor?'V':'U'}perl %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" custom
MLS_Log www custom

=head1 DESCRIPTION

Apache::Log::Spread provides logging handlers to allow for Apache access logs to
be multocast to a spread group.  The configuration interface is a super-set of
the Apache mod_log_config interface and allows for expansion of perl code.

=head1 Configuration Directives

=over 4

=item SpreadDaemon port[@host]

The location of the spread daemon to connect to.

=item MLS_LogFormat formatstring formatname

formatstring is a standard mod_log_config format line, the standard format options are all accepted (see the mod_log_config documentation for details), as well as the special tag %{...code...}perl, which evals the contained code and substitutes the r...

=item MLS_Log groupname formatname [should_print]

groupname is the name of the spread group to which logs should be multicast.  formatname is the name of the MLS_LogFormat to use.  should_print is an optional environment
string to toggle transmission of logs.  This can be used the way that mod_setenvif 
environment variables are used, or with a complete code block.  For example, to only
multicast requests for '.html' files we can use:

MLS_Log    www custom "return ($r->uri =~ /\.html/) || ($r->uri =~ /$\//));"

=back

=head1 EXTENDING

Apache::Log::Spread is deigned to be extended to provide custom format string expansions.  To extend it in ithis fashion, simply override the _interpolate_log_string function.

An example is

=over 4

package My::SpreadLogger;
use strict;

use Apache::Logger::Spread;
use My::Cookies;

use vars qw( @ISA);
@ISA = qw(Logger::Spread);

sub handler($$)
{
    my $self = shift;
    my $ar = shift;
    Apache::Log::Spread::handler($self, $ar);
}

sub _interpolate_log_string {
    my ($self, $logref) = @_;
    my $cookie = My::Cookie->new();
    $$logref =~ s/%\{([\w-]+)\}cookie/$cookie->{$1} || '-'/ego;
}

=back


=head1 AUTHOR

George Schlossnagle <george@omniti.com>

=cut



( run in 1.015 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )