Nic Ferrier wrote ..
> "Graham Dumpleton" <[EMAIL PROTECTED]> writes:
> 
> > Nic wrote:
> >> Programmers may or may not want to redirect logging through Apache.
> If
> >> mod_python used the system you describe there would either have to be:
> >>
> >> 1. config syntax to allow module 'logging' glue to be turned off
> >> 
> >> 2. removal of the apache log handler in all code that didn't want it
> >> 
> >> I don't like either of those.
> >> 
> >> I can think of lots and lots of reasons why code using logging
> >> wouldn't want to log to Apache.
> >
> > I attached the log handler to the "mod_python" logger. Thus you have
> > to select that logger explicitly for it to be redirected to Apache. If
> a user
> > wants other loggers to redirect to Apache, within a PythonImport module
> > they could grab the global log handler instance from where it is kept
> > and add it against other loggers as they see fit. They could still also
> > create their own instance of the Apache log handler as well, as the
> > request cache isn't within the instance anyway and so doesn't matter
> > if there is more than one.
> >
> > Thus, use of logging to Apache is optional.
> 
> I don't believe this is as useful.

Hmmm, it puts it at about the same level of usefulness, if not slightly
more than your original proposal.

At its core, the only real difference is that the log handler uses a
separate global request cache rather than a distinct log handler
instance needing to be exist for each request.

Either way, to get the flexibility you want, user code still has to do
the association of a log handler to a specific logger at some point, eg.
preferably in a PythonImport module and only once. Adding a default
apache log handler against "mod_python" was to serve as an example
and possibly as a convenience when wanting to quickly put stuff together.

> One major benefit of logging is that it is hierarchial. The reason
> that I wanted the glue in the first place is that I have app code that
> I want to interface to the web. The app code uses logging so it's
> natural to try to make the logging go through Apache.
> 
> But I wouldn't want to have to change all my loggers to use the new
> handler... that would be significant effort.

It may well be if you are already using this scheme whereby you have
separate log handlers for each request with uniquely named loggers for
each request/thread as well. I would say that that isn't an ideal design
to begin with. The code I suggested mean't request objects and threading
were handled transparently. This would simplify your code such that it
could use the same logger name all the time. You then only have to have
in one place the association of log handler to logger. The code would
be simpler to understand then.

> Your system *is* useful for more casual logging in the mod_python
> context, say in an add-on handler framework.
> 
> But such frameworks could take the time to do their own logging
> integration in whatever way makes sense for them.

You are starting to make good points for why logging shouldn't be in
mod_python to begin with. That is, that a user is always probably
going to want to handle it in some special way, making it very hard
to provide a generic solution. :-)

Graham

Reply via email to