"Graham Dumpleton" <[EMAIL PROTECTED]> writes: > That is, a global log handler instance is created once only. No instance per > request handler invocation. > > As you point out you need though to do caching of request objects. I have > previously posted on a safe way of doing this which works for internal > redirects. See: > > http://www.modpython.org/pipermail/mod_python/2005-September/019071.html > > Other solutions I have seen people describe for request caching didn't > consider internal redirects properly. One also can't use thread local > storage as Python 2.3 doesn't support it. > > I have already pointed out how this sort of request caching will probably > be needed in mod_python 3.3 when various of the problems with the > module loading system hopefully will be fixed. Thus, any logger system > could harness what would then be builtin functionality at no cost.
This is interesting... how does it play with non-thread mpms? > In terms of seamless integration, I am coming to the conclusion that > having mod_python internally create the single global log handler as part > of mod_python.apache being imported would be best. It only gets done > once, so insignificant overhead. Any code therefore doesn't need to > worry about that and just needs to get the logger and log their messages. > Beyond the creation of the one log handler, there is no overhead unless > handlers actually use logging, as the request caching will need to be > done for other reasons anyway associated with module importing. I specifically rejected that option myself. 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. > Apart from the benefit of individual request handlers not having to create > log handler instances and all the cleanup problems with that etc, I don't believe it is onerous to have to specifically attach the Apache log handling glue in the handler. I think I have solved the cleanup problems. My module makes logging available like any other cost based resource (eg: database connections). > this logging mechanism is still usuable from global scope of a > module and messages logged at that point when a module is being > imported due to a request, will still be logged against the request > object. Another advantage of your system is that the logging config file syntax could be used to assign loggers (I think). Nic