2005/10/19, Nic Ferrier <[EMAIL PROTECTED]>:
Is everyone here called Nic[h]olas?


Nicolas Lehuen <[EMAIL PROTECTED]> writes:

> Nic, there is something I need to understand before giving my advice on the
> subject. I'm not familiar with the logging API, can you tell me how you
> configure Python to use this logging implementation ? Looks like we have to
> manipulate configuration object, set up handlers and so on... If so I guess
> we'd have to add a word or two in the documentation on the best way to do
> this in the mod_python context...

Hmmm... logging is actually very simple if you want it to be.

All you really have to do to use logging from Python is this:

  import logging

  # then sometime later

  logger = logging.getLogger()
  logger.debug("a log message")


lot's more things are possible and the logging API is very
configurable.


From an Apache point of view you do need to configure the default
logger in your handler so that it has access to the apache vhost
logger:


    hdlr = apache_log_handler.ApacheLogHandler(http)
    logging.getLogger().addHandler(hdlr)

once you've done that then any handler which descends from the default
handler (and that's the normal way to do things) will log to Apache.



Nic

In that case, setting up the logging handler should be done by the user, making sure that it is set up only once per interpreter, even in the context of a multi-threaded MPM. It's not a trivial thing ; looks like this is a job for PythonImport.

So my advice is that if the set up is done by the user, then the logging handler should be considered as contrib. If you provide a way for mod_python to directly set up the handler, maybe this could be considered part of mod_python.

Regards,
Nicolas

Reply via email to