I don't know if this is possible or not, but I took parts of DBILogger and wanted to 
extend what I could
do with it.  What I would like to do is for a given request to a cgi program (or 
mason) if the script causes
an internal error (which should not happen in production, but does) I would like to 
capture the parameters
that were called from the cgi form so that later on I can look to see what cgi program 
it was that caused
the problems and what parameters the user used to cause the problem.
 
So far what I have works, except for getting information from $r->content(), what I 
have done is placed the
directive "PerlLogHandler Apache::ErrorLogger" which calls the script below, which is 
placing information
into the logfile.  The $r->args() call works, when I place parameters in the URL after 
the '?' it does get this
information.  What I really need though is the content in the content() call.
 
The form does have 'application/x-www-form-urlencoded' in the form tag.  Is the 
content() not coming through
because apache redirects to the error page ?  
 
 
package Apache::ErrorLogger;
 
use strict;
use Apache::Constants qw( :common );
use Apache::Log;
use Apache::Request;
use Date::Format; 
 
sub handler {
        
        my $r = shift->last;
        my $s = $r->server;
        my $c = $r->connection;
 
        my %data = (
                    'host'      => "xrayfish-ssl",
                    'server'    => $s->server_hostname,
                    'bytes'     => $r->bytes_sent,
                    'filename'  => $r->filename || '',
                    'remotehost'=> $c->remote_host || '',
                    'remoteip'  => $c->remote_ip || '',
                    'status'    => $r->status || '',
                    'urlpath'   => $r->uri || '',
                    'referer'   => $r->header_in("Referer") || '',
                    'useragent' => $r->header_in('User-Agent') || '',
                    'timeserved'=> time2str("%Y-%m-%d %X", time),
                    'contenttype' => $r->content_type || ''
        );
 
        my $content = $r->content();
        my $args = $r->args();
 
        $data{usertrack} = $r->notes('cookie') || '';
        
        my $error_msg =  %data->{'host'}." >^..^< ".%data->{'server'}." >^..^< ".
                         %data->{'bytes'}." >^..^< ".%data->{'filename'}." >^..^< ".
                         %data->{'remotehost'}." >^..^< ".%data->{'remoteip'}." >^..^< 
".
                         %data->{'status'}." >^..^< ".%data->{'urlpath'}." >^..^< ".
                         %data->{'referer'}." >^..^< ".%data->{'useragent'}." >^..^< ".
                         %data->{'timeserved'}." >^..^< ".%data->{'contenttype'}." 
>^..^< ".
                         %data->{'usertrack'}." >^..^< ".$content." args ".$args;
 

        if($r->status eq '500')
        {
          # Bomb is just a generic error logger that sends this information to the 
specified logfile.
          &Bomb({display=>0, footer=>0, level=>3,  exit=>0, output=>'text',
                       error=>"Internal Server Error >^..^< $error_msg",
                       logfile=>'/var/apache_errorlogfile'
                      });
 
        }
 
        return OK;
}
 
 
 



** ** **  PRIVILEGED AND CONFIDENTIAL  ** ** **
This email transmission contains privileged and confidential information 
intended only for the use of the individual or entity named above.  Any 
unauthorized review, use, disclosure or distribution is prohibited and 
may be a violation of law.  If you are not the intended recipient or a 
person responsible for delivering this message to an intended recipient, 
please delete the email and immediately notify the sender via the email 
return address or mailto:[EMAIL PROTECTED]  Thank you.

Reply via email to