Hello mod_python developers. I just joined this list (at the suggestion of Graham Dumpleton) to try and get you guys to consider adding some glue to connect python >2.2 logging to Apache's logging.
This means adding a small extra source file to the mod_python codebase. Here's my example: # A log handler for mod-python import logging from mod_python import apache class ProxyLogThing: """A proxy for default Apache logging.""" def __init__(self): # No need to do anything. pass def log_error(msg, lvl): apache.log_error(msg, lvl) class ApacheLogHandler(logging.Handler): """A handler class which sends all logging to Apache.""" def __init__(self, ref = None): """ Initialize the handler (does nothing) """ logging.Handler.__init__(self) if ref == None: self.ref = ProxyLogThing() else: self.ref = ref # Set up the thing self.level_mapping = { } # self.level_mapping[logging.CRITICAL] = apache.APLOG_ERR self.level_mapping[logging.ERROR] = apache.APLOG_ERR self.level_mapping[logging.WARNING] = apache.APLOG_WARNING self.level_mapping[logging.INFO] = apache.APLOG_INFO self.level_mapping[logging.debug] = apache.APLOG_DEBUG def emit(self, record): """Emit a record.""" self.ref.log_error(record.msg, record.levelno) # End As far as I can see there is no reason not to do this: it does not create a dependency problem for anyone not using a Python without logging; it's use is purely optional. A very good reason for doing it is that it reduces dependancies for anyone wanting to do this (and it's a very obvious thing to want to do in any mod_python code). I wonder what you all think about this? BTW I'd be happy to maintain and support this if you agreed to include it. Nic Ferrier