You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Magnús Þór Jónsson <ma...@adlib.is> on 2002/01/04 13:18:45 UTC

Error log executing scripts?

Hello,
I was wondering if there is any way of making the error log in Apache to
execute a script when an error is occurred, perhaps instead of writing the
error directly to the log.

For example, if there is a image missing Apache excutes a script that
generates a replacement image?

Thanx in advance
Maggi
maggi@adlib.is


Re: Error log executing scripts?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Magnús Þór Jónsson wrote:
> 
> Hello,
> I was wondering if there is any way of making the error log in Apache to
> execute a script when an error is occurred, perhaps instead of writing the
> error directly to the log.
> 
> For example, if there is a image missing Apache excutes a script that
> generates a replacement image?

well, you can do just about anything you want :)

however, althoughit is possible to intercept the actual errors Apache
(and mod_perl) generates, it is rather complex, and really not the
proper approach here.

the better way is to just write your own handler to add the logic you
are seeking.

for instance, you could write a PerlFixupHandler that

$r->filename('/some/other/file') unless -e $r->finfo;

or whatnot.

if you want a script to run, you could replace the $r->filename('foo')
call with something like

$r->set_handlers(PerlHandler => 'My::ImageGenerating::Package');
$r->handler('perl-script');

or some combination that changed $r->uri if you wanted to use a
Registry script I suppose.

HTH

--Geoff