On Thu, Jun 3, 2010 at 12:49 PM, Stefan Fritsch <s...@sfritsch.de> wrote:
> On Wednesday 02 June 2010, Stefan Fritsch wrote: > > I have updated my patch to the latest trunk and to use the variant > > where the module for logging is selected with APLOG_USE_MODULE and > > AP_DECLARE_MODULE macros: > > > > APLOG_USE_MODULE(foo) > > > > expands to > > > > extern module AP_MODULE_DECLARE_DATA foo_module; > > static int * const aplog_module_index = > > &(foo_module.module_index) > > > > and > > > > AP_DECLARE_MODULE(foo) > > > > expands to > > > > APLOG_USE_MODULE(foo); > > module AP_MODULE_DECLARE_DATA foo_module > > > > So, a single-file module only needs to do: > > > > AP_DECLARE_MODULE(foo) = > > { > > STANDARD20_MODULE_STUFF, > > ... > > > > Multi-file modules have to use APLOG_USE_MODULE in the other > > files. > > > > The patch is at > > > > > > http://people.apache.org/~sf/per-module-loglevel-v4/<http://people.apache.org/%7Esf/per-module-loglevel-v4/>, > > I have added two additional patches (filenames 10*) to fix a segfault. > In addition, I now have this in http_log.h: > > #define APLOG_NO_MODULE -1 > > static int * const aplog_module_index; > #define APLOG_MODULE_INDEX \ > (aplog_module_index ? *aplog_module_index : APLOG_NO_MODULE) > > > This means, if some source file does not initialize aplog_module_index > with APLOG_USE_MODULE, logging will simply default to the global > loglevel. This works because static pointers are initialized to NULL > if no explicit initialization is given. > > I think that's a nice solution. Modules from 2.2.x continue to work > without changes. But in order to benefit from per-module loglevel > configuration, they have to use the new macros. > sounds very reasonable to me