Re: Path to my module and APR::Socket::send() usage

André Warnier <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
Alexander Farber wrote:
> Even though my logs show that 1 send-call usually suffices
> (I have a site with 1 visitor/3 min), I've updated my script.
> 
> Not sure if returning DECLINED is a good idea.
> 
> And if you know a way to log into access_log
> instead of error_log, please tell me.

No. I have been looking into that too, without success so far.
About the "warn" : you can use "notice" instead, which will log no matter what the 
LogLevel is.

Also about logging : you can use your own PerlLogHandler, to log wherever you want. 
return DECLINED from it to have Apache log normally.

An example I just created :

PerlSetVar StatsLogPath "/var/log/apache2/stats.log"
PerlLogHandler my::package->logger


package my::package;
...
sub logger {
     my ($self, $r) = @_;
     my $debug = $r->dir_config("Debug") || 0;
     my $logger = $r->log;
     my $pnotes = $r->pnotes;
     my $stats = $pnotes->{'stats'}; # set previously by another handler
     unless (defined($stats) && ($stats ne '')) {
         return DECLINED;
     }

     my $log_path = $r->dir_config('StatsLogPath');
     unless (defined($log_path) && ($log_path ne '')) {
         $logger->error("config error : StatsLogPath is not defined !");
         return SERVER_ERROR;
     }
     my $fh;
     unless (open($fh,'>>:utf8',$log_path)) {
         $logger->error("cannot open [$log_path] : $!");
         return SERVER_ERROR;
     }
     flock $fh, LOCK_EX;
     print $fh "[GETOBJ] $stats \n";
     close $fh;

     return OK;

}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.