perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alden DoRosario <adorosa...@chitika.com>
Subject Modifying the Apache Log Entry
Date Tue, 09 Jan 2007 23:18:11 GMT
In modperl 1.99 I used to use the code below to append a bunch of 
parameters to the log entry for a request.

Example: A request to /handler?client=demo would be written to the log 
as: (notice how sysinfo has been appended to the log)

fios.verizon.net - - [09/Jan/2007:16:39:17 -0500] "GET 
/handler?client=demo&sysinfo=servtime%3D3.976863 HTTP/1.1" 200 1893 "-" 
"Mozilla/5.0 Firefox/1.0.6 (ax)" 4098034 -

sub append_to_log {
  my ($r, $plog) = @_;
  my $uri = "";
  if ($r->the_request =~ / (.*) /) {
    $uri = $1;
  } else {
    return;
  }
  my $info = "&sysinfo=" . uri_escape(join("&", @{$plog}));
  (my $request_line = $r->the_request) =~ s/ (.*) / $uri$info /;
  $r->the_request($request_line);
}

Problem is: In Modperl 2.0+, the method the_request suddenly became 
read-only and the code stopped working.

From: http://search.cpan.org/dist/mod_perl/Changes
Apache::RequestRec methods changes [Stas] - readwrite => readonly:

    connection, canonical_filename, header_only, main, next, prev,
    pool, per_dir_config, request_config, proto_num, protocol,
    request_time, server, the_request, unparsed_uri


Can anyone suggest an alternate way of modifying the log entry ? In 
other words, what way does MP2 allow for us to control what gets logged 
to the Apache access_log ?

Alternatively: Can the_request in Apache::RequestRec be made writable 
again so that it works like before ?

Any help is really appreciated. Thanks.

-- 
Alden DoRosario
CTO
Chitika, Inc.
www.chitika.com



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message