Dan Thomas wrote:
> Hi,
> 
> I'm in the process of shifting some old mod_perl1 code over to
> Apache2.2 and mod_perl2. Part of it is using Apache::LogFile to write
> to a custom log. Well.. actually, it pipes the data to a little script
> that collects up lines and forks off processes to deal with them when
> it's got a handful (it gets hit a couple of million times per day, and
> processing them one by one isn't particularly efficient). But that's
> not entirely relevant, I suppose.
> 
> As far as I can tell, Apache::LogFile was never ported to mp2, and I
> can't find anything that will let me define my own logfile. The
> Apache::LogFile solution was very convenient, as it shuts down and
> restarts the collector script with the daemon, but as my C skills are
> practically non-existent, I doubt very much I'd be able to port it
> myself, so I'm looking for an alternative.

Porting it to mod_perl 2 would certainly possible, but require some
surgery and XS/C code, unfortunately. On the bright side, the Apache
logging api in 2.0 is much nicer, so it would most likely end up being
less code.

> Ideally, I want a single filehandle that will be opened and closed
> when Apache starts up and shuts down, that I can write to from a
> handler, but I'm not really sure where to start. Can anyone point me
> in the right direction?

You could probably handle it nicely from a LogHandler

http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler

Load your module at startup, opening your file then. Collect the information
you are interested in logging any way you see fit ($r->notes, $r->pnotes are
good candidate), then use a LogHandler to do the final step. Buffer up to
a certain amount of data, check the filehandle is still good (if not, fix it),
then proceed to do whatever you used to.

Not quite as elegant as Apache::LogFile, but would work just fine. Porting
Apache::LogFile would be nicer still,...

------------------------------------------------------------------------
Philippe M. Chiasson     GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/       m/gozer\@(apache|cpan|ectoplasm)\.org/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to