Apache-DBILogConfig

 view release on metacpan or  search on metacpan

DBILogConfig.pm  view on Meta::CPAN


sub logger {

  my $r = shift;
  $r = $r->last; # Handle internal redirects
  $r->subprocess_env; # Setup the environment

  # Connect to the database
  my $source = $r->dir_config('DBILogConfig_data_source');
  my $username = $r->dir_config('DBILogConfig_username');
  my $password = $r->dir_config('DBILogConfig_password');
  my $dbh = DBI->connect($source, $username, $password);
  unless ($dbh) { 
    $r->log_error("Apache::DBILogConfig could not connect to $source - $DBI::errstr");
    return DECLINED;
  } # End unless
  $r->warn("DBILogConfig: Connected to $source as $username");

  # Parse the formats ( %[conditions]{param}format=field [...] )
  my @format_list = (); # List of anon hashes {field, format, param, conditions}
	my $format_string = Apache->request->dir_config('DBILogConfig_log_format');
	while ($format_string =~ /%(!)?([^\{[:alpha:]]*)(?:\{([^\}]+)\})?(\w)=(\S+)/g) {

DBILogConfig.pm  view on Meta::CPAN

=head1 NAME

Apache::DBILogConfig - Logs access information in a DBI database

=head1 SYNOPSIS

 # In httpd.conf
 PerlLogHandler Apache::DBILogConfig
 PerlSetVar DBILogConfig_data_source DBI:Informix:log_data
 PerlSetVar DBILogConfig_username    informix
 PerlSetVar DBILogConfig_password    informix
 PerlSetVar DBILogConfig_table	     mysite_log
 PerlSetVar DBILogConfig_log_format  "%b=bytes_sent %f=filename %h=remote_host %r=request %s=status"

=head1 DESCRIPTION

This module replicates the functionality of the standard Apache module, mod_log_config,
but logs information in a DBI-compliant database instead of a file. (Some documentation has been
borrowed from the mod_log_config documentation.)

=head1 LIST OF TOKENS

DBILogConfig.pm  view on Meta::CPAN

=over 4

=item DBILogConfig_data_source

A DBI data source with a format of "DBI::driver:database"

=item DBILogConfig_username

Username passed to the database driver when connecting

=item DBILogConfig_password

Password passed to the database driver when connecting

=item DBILogConfig_table

Table in the database for logging

=item DBILogConfig_log_format

A string consisting of formats separated by white space that define the data to be logged (see FORMAT STRING below)

README  view on Meta::CPAN

NAME
    Apache::DBILogConfig - Logs access information in a DBI database

SYNOPSIS
     # In httpd.conf
     PerlLogHandler Apache::DBILogConfig
     PerlSetVar DBILogConfig_data_source DBI:Informix:log_data
     PerlSetVar DBILogConfig_username    informix
     PerlSetVar DBILogConfig_password    informix
     PerlSetVar DBILogConfig_table       mysite_log
     PerlSetVar DBILogConfig_log_format  "%b=bytes_sent %f=filename %h=remote_host %r=request %s=status"

DESCRIPTION
    This module replicates the functionality of the standard Apache module,
    mod_log_config, but logs information in a DBI-compliant database instead
    of a file. (Some documentation has been borrowed from the mod_log_config
    documentation.)

LIST OF TOKENS
    DBILogConfig_data_source
        A DBI data source with a format of "DBI::driver:database"

    DBILogConfig_username
        Username passed to the database driver when connecting

    DBILogConfig_password
        Password passed to the database driver when connecting

    DBILogConfig_table
        Table in the database for logging

    DBILogConfig_log_format
        A string consisting of formats separated by white space that define
        the data to be logged (see FORMAT STRING below)

FORMAT STRING



( run in 0.570 second using v1.01-cache-2.11-cpan-49f99fa48dc )