You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stefan Fritsch <sf...@sfritsch.de> on 2010/06/02 22:42:44 UTC
Per-module / per-dir loglevel configuration version 4
Hi,
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/ ,
both as one file and as a series split into more or less logical
chunks. Comments are very welcome. Also, it would be nice if
someone could try it with a different compiler than gcc.
Do you think the APLOG_USE_MODULE/AP_DECLARE_MODULE macros are
better than having to define AP_MODULE_VAR in every file?
And what do you think about commiting that to trunk before Jim
tags the next alpha?
Cheers,
Stefan
Re: Per-module / per-dir loglevel configuration version 4
Posted by Joe Orton <jo...@redhat.com>.
On Fri, Jun 04, 2010 at 01:40:42PM +0200, "Plüm, Rüdiger, VF-Group" wrote:
> > memset(l->module_levels, val, total_modules +
> > DYNAMIC_MODULE_LIMIT);
>
> Hm, module_levels is int[] and memset works byte wise.
Doh. Sorry, yes, ignore me there.
RE: Per-module / per-dir loglevel configuration version 4
Posted by "Plüm, Rüdiger, VF-Group" <ru...@vodafone.com>.
> -----Original Message-----
> From: Joe Orton
> Sent: Freitag, 4. Juni 2010 13:29
> To: dev@httpd.apache.org
> Subject: Re: Per-module / per-dir loglevel configuration version 4
>
> On Wed, Jun 02, 2010 at 10:42:44PM +0200, Stefan Fritsch wrote:
> > The patch is at
> >
> > http://people.apache.org/~sf/per-module-loglevel-v4/ ,
>
> This looks good to me. Kudos for taking on such a task.
> It's kind of
> hard to review the individual patches with fixes-on-fixes
> separated out,
> or the big patch which jumbles everything up.
>
> The use of an extra per-file static global pointer to the
> module index
> seems awkward at first but turns into a neat hack by the end of the
> story.
>
> I very much like the new "trace" levels, and junking all the
> module-specific logging stuff in mod_rewrite/ssl.
>
> Some very minor nitpicking:
>
> Can you rename "struct logcfg" to something a bit more
> namespace-safe,
> with an ap_ prefix at least? struct ap_log_config, ap_logconf?
>
> In ap_reset_module_loglevels(), is there any reason not to simplify:
>
> + for (i = 0; i < total_modules + DYNAMIC_MODULE_LIMIT; i++)
> + l->module_levels[i] = val;
>
> to:
>
> memset(l->module_levels, val, total_modules +
> DYNAMIC_MODULE_LIMIT);
Hm, module_levels is int[] and memset works byte wise.
So IMHO we would only touch the first total_modules + DYNAMIC_MODULE_LIMIT bytes
of module_levels whereas module_levels is sizeof(int) * (total_modules + DYNAMIC_MODULE_LIMIT)
large. Furthermore the values set will be IMHO wrong as each byte is filled with the same
value and sizeof(int) bytes will be intepreted as an int later.
Regards
Rüdiger
Re: Per-module / per-dir loglevel configuration version 4
Posted by Joe Orton <jo...@redhat.com>.
On Wed, Jun 02, 2010 at 10:42:44PM +0200, Stefan Fritsch wrote:
> The patch is at
>
> http://people.apache.org/~sf/per-module-loglevel-v4/ ,
This looks good to me. Kudos for taking on such a task. It's kind of
hard to review the individual patches with fixes-on-fixes separated out,
or the big patch which jumbles everything up.
The use of an extra per-file static global pointer to the module index
seems awkward at first but turns into a neat hack by the end of the
story.
I very much like the new "trace" levels, and junking all the
module-specific logging stuff in mod_rewrite/ssl.
Some very minor nitpicking:
Can you rename "struct logcfg" to something a bit more namespace-safe,
with an ap_ prefix at least? struct ap_log_config, ap_logconf?
In ap_reset_module_loglevels(), is there any reason not to simplify:
+ for (i = 0; i < total_modules + DYNAMIC_MODULE_LIMIT; i++)
+ l->module_levels[i] = val;
to:
memset(l->module_levels, val, total_modules + DYNAMIC_MODULE_LIMIT);
?
That's all I have... thanks and nice work!
Regards, Joe
Re: Per-module / per-dir loglevel configuration version 4
Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Thursday 03 June 2010, Rainer Jung wrote:
> > The patch is at
> >
> > http://people.apache.org/~sf/per-module-loglevel-v4/ ,
> >
> > both as one file and as a series split into more or less logical
> > chunks. Comments are very welcome. Also, it would be nice if
> > someone could try it with a different compiler than gcc.
>
> Some comments based on visual inspection. Next step
> (building/testing) is on my ToDo list. No major findings, only
> minor stuff.
Thank you very much for the comments. They look very reasonable and I
will integrate them in the next round of patches. Or should I create a
branch in svn? But I think git is easier to use when tracking the
changes in trunk.
> Additional remarks
> ------------------
>
> We need to fix and add some docs
>
> - removed directives for mod_ssl, mod_rewrite and mod_logio
> - new syntax for LogLevel
I have started updating the docs today. Except for mod_ssl, these two
points are done. I have put it as 2000_docs.patch into the directory
above.
> - merging and inheritance of LogLevels between servers and
> modules
This and the handling of per-dir, per-conn, and per-request loglevels
is still missing.
Also, there is infrastructure to use the loglevel from the conn_req,
but no way to set it, yet. Maybe a LogLevelIfIP directive?
> Later possible improvement: should we add the module_name to the
> log line? Since you already know the index, associating the name
> would be easy. The question is, whether the info is important
> enough to add to the log line.
It would be very useful when tuning the loglevel, but by default it
may be too much noise. There are quite a few items in the same
category (PID/TID, microseconds, ...) so a ErrorLogFlags or
ErrorLogFormat directive may be a good idea. But these changes are not
going to change the API/ABI, so IMHO they are less urgent.
Cheers,
Stefan
Re: Per-module / per-dir loglevel configuration version 5
Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Saturday 05 June 2010, Rainer Jung wrote:
> It doesn't compile, two small problems, both in
> include/http_config.h:
> During the build I also noticed, that mod_lua has two lines, where
> it doesn't use APLOG_MARK but instead directly passes two
> file/line args along.
Thanks. It seems I haven't tested recently without --enable-
maintainer-mode and I didn't have mod_lua enabled.
Cheers,
Stefan
Re: Per-module / per-dir loglevel configuration version 5
Posted by Rainer Jung <ra...@kippdata.de>.
On 05.06.2010 21:44, Rainer Jung wrote:
> During the build I also noticed, that mod_lua has two lines, where it
> doesn't use APLOG_MARK but instead directly passes two file/line args
> along.
Patch along the lines of the mod_ssl solution:
http://people.apache.org/~rjung/patches/httpd-trunk-per-module-loglevel-v5-addon-2.patch
Rainer
Re: Per-module / per-dir loglevel configuration version 5
Posted by Rainer Jung <ra...@kippdata.de>.
On 04.06.2010 23:57, Stefan Fritsch wrote:
> On Friday 04 June 2010, Stefan Fritsch wrote:
>> which are either pure bug fixes or pretty trivial. I will create a
>> new patch series without these soon, hopefully tomorrow.
>
> The next iteration is at
>
> http://people.apache.org/~sf/per-module-loglevel-v5/
It doesn't compile, two small problems, both in include/http_config.h:
1) ap_get_module_loglevel still contains (s)->loglevel and
(s)->module_loglevels instead of s->log.level and s->log.module_levels.
Trivial to fix.
2) The do-loops in the macros ap_get_conn_module_loglevel() and
ap_get_request_module_loglevel() break when injected into an expression
in server/log.c lines 584f.
I used nested function macros to fix 2), because that way the logic
seemed to be readable best. At the end the macros for server, conn and
request used a common macro, so I renamed ap_get_module_loglevel() to
ap_get_server_module_loglevel() and used ap_get_module_loglevel() for
the common part. Because of the rename, another three files have small
changes. If you don't like the rename, your welcome to choose some other
name for the new macro :)
Patch on top of your v5 at:
http://people.apache.org/~rjung/patches/httpd-trunk-per-module-loglevel-v5-addon-1.patch
During the build I also noticed, that mod_lua has two lines, where it
doesn't use APLOG_MARK but instead directly passes two file/line args
along. We need to fix those like you did for mod_ssl:
diff --git a/modules/lua/lua_config.c b/modules/lua/lua_config.c
index dd77cd8..f4d6e96 100644
--- a/modules/lua/lua_config.c
+++ b/modules/lua/lua_config.c
@@ -174,7 +174,10 @@ static int cmd_log_at(lua_State *L, int level)
lua_getinfo(L, "Sl", &dbg);
msg = luaL_checkstring(L, 2);
- ap_log_error(dbg.source, dbg.currentline, level, 0, cmd->server, msg);
+/* Needs fixing for per-module-loglevel */
+#if 0
+ ap_log_error(dbg.source, dbg.currentline, level, 0,
cmd->server, msg);
+#endif
return 0;
}
diff --git a/modules/lua/lua_request.c b/modules/lua/lua_request.c
index a18c74d..06609c6 100644
--- a/modules/lua/lua_request.c
+++ b/modules/lua/lua_request.c
@@ -407,7 +407,10 @@ static int req_log_at(lua_State *L, int level)
lua_getinfo(L, "Sl", &dbg);
msg = luaL_checkstring(L, 2);
+/* Needs fixing for per-module-loglevel */
+#if 0
ap_log_rerror(dbg.source, dbg.currentline, level, 0, r, msg);
+#endif
return 0;
}
> Since there has been some positive comments about the changes, I will
> commit before the next alpha (my current plan is Sunday). But anyone
> is of course welcome to review them before then.
With those changes the build runs successful and first tests look good
(I can see new trace log entries and I can reconfigure loglevel with
graceful restart). I agree you should go ahead. Congratulations, very
useful!
Regards,
Rainer
Re: Per-module / per-dir loglevel configuration version 5
Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Friday 04 June 2010, Stefan Fritsch wrote:
> which are either pure bug fixes or pretty trivial. I will create a
> new patch series without these soon, hopefully tomorrow.
The next iteration is at
http://people.apache.org/~sf/per-module-loglevel-v5/
I have included Rainer's and Joe's corrections (thanks again). Apart
from that, there is only comment and docs changes, no code. But the
set is now reduced to 13 patches. I guess I need more git-fu, this is
still too much manual work :-|
Since there has been some positive comments about the changes, I will
commit before the next alpha (my current plan is Sunday). But anyone
is of course welcome to review them before then.
Cheers,
Stefan
Re: Per-module / per-dir loglevel configuration version 4
Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 6/3/2010 7:10 PM, Jeff Trawick wrote:
> On Thu, Jun 3, 2010 at 7:51 PM, Eric Covener <covener@gmail.com
> <ma...@gmail.com>> wrote:
>
> On Thu, Jun 3, 2010 at 7:27 PM, Stefan Fritsch <sf@sfritsch.de
> <ma...@sfritsch.de>> wrote:
> > which are either pure bug fixes or pretty trivial. I will create a new
> > patch series without these soon, hopefully tomorrow.
>
> Appreciate your commitment to getting this in!
>
> +1
+1! - these improvements are going to go a long ways to let 'debug' logging
become usable, instead of the current blight caused by mod_ssl and other
modules guilty of the low S/N ratio.
Re: Per-module / per-dir loglevel configuration version 4
Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, Jun 3, 2010 at 7:51 PM, Eric Covener <co...@gmail.com> wrote:
> On Thu, Jun 3, 2010 at 7:27 PM, Stefan Fritsch <sf...@sfritsch.de> wrote:
> > which are either pure bug fixes or pretty trivial. I will create a new
> > patch series without these soon, hopefully tomorrow.
>
> Appreciate your commitment to getting this in!
>
+1
Re: Per-module / per-dir loglevel configuration version 4
Posted by Eric Covener <co...@gmail.com>.
On Thu, Jun 3, 2010 at 7:27 PM, Stefan Fritsch <sf...@sfritsch.de> wrote:
> which are either pure bug fixes or pretty trivial. I will create a new
> patch series without these soon, hopefully tomorrow.
Appreciate your commitment to getting this in!
--
Eric Covener
covener@gmail.com
Re: Per-module / per-dir loglevel configuration version 4
Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Friday 04 June 2010, William A. Rowe Jr. wrote:
> On 6/3/2010 4:49 PM, Rainer Jung wrote:
> > Indentation in modules/proxy/mod_proxy.h whenever ap_log_error is
> > replaced by ap_log_rerror (argument indentation)
>
> Can we start pre-committing some of these pieces which are simply
> bug fixes, e.g. correcting the loglevel scope?
>
> It will save on review of the 'big picture' patch to get the small
> stuff out of the way, and into svn.
>
Sure. I have commited
0003-Introduce-SSLLOG_MARK-in-preparation-to-redefine-APL.patch
0004-move-find-module-logic-into-separate-function.patch
0012-Remove-loglevel-entry-in-core_dir_config-which-has-b.patch
0017-associate-CONNECT-errors-with-the-request.patch
which are either pure bug fixes or pretty trivial. I will create a new
patch series without these soon, hopefully tomorrow.
> > Later possible improvement: should we add the module_name to the
> > log line? Since you already know the index, associating the name
> > would be easy. The question is, whether the info is important
> > enough to add to the log line.
>
> The construct "mod_foo: The foo module broke" is just sooo common
> it would seem like a waste not to take advantage of the newfound
> intellegence in the error log, and reduce all this verbosity in
> the source code.
Cheers,
Stefan
Re: Per-module / per-dir loglevel configuration version 4
Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 6/3/2010 4:49 PM, Rainer Jung wrote:
>
> Indentation in modules/proxy/mod_proxy.h whenever ap_log_error is
> replaced by ap_log_rerror (argument indentation)
Can we start pre-committing some of these pieces which are simply bug fixes,
e.g. correcting the loglevel scope?
It will save on review of the 'big picture' patch to get the small stuff
out of the way, and into svn.
> Later possible improvement: should we add the module_name to the log
> line? Since you already know the index, associating the name would be
> easy. The question is, whether the info is important enough to add to
> the log line.
The construct "mod_foo: The foo module broke" is just sooo common it would
seem like a waste not to take advantage of the newfound intellegence in the
error log, and reduce all this verbosity in the source code.
Re: Per-module / per-dir loglevel configuration version 4
Posted by Rainer Jung <ra...@kippdata.de>.
On 02.06.2010 22:42, 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:
...
> 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/ ,
>
> both as one file and as a series split into more or less logical
> chunks. Comments are very welcome. Also, it would be nice if
> someone could try it with a different compiler than gcc.
Some comments based on visual inspection. Next step (building/testing)
is on my ToDo list. No major findings, only minor stuff.
0002-Introduce-log-levels-trace1-.-trace8.patch
-----------------------------------------------
Minor: Use of LOG_PRIMASK and APLOG_LEVELMASK: LOG_PRIMASK usually comes
from sys/syslog.h and we set it to "7" if it is not defined. Previously
both masks were the same. Since this is no longer the case, I wouldn't
-#define APLOG_LEVELMASK 7 /* mask off the level value */
+#define APLOG_LEVELMASK ((LOG_PRIMASK << 1) + 1) /* mask off the level
value */
but instead keep our mask at a fixed value:
+#define APLOG_LEVELMASK 15 /* mask off the level value */
and then when using syslog
- syslog(level_and_mask, "%s", errstr);
+ syslog(level_and_mask < APLOG_DEBUG ? level_and_mask : APLOG_DEBUG,
+ "%s", errstr);
instead
+ syslog(level_and_mask < LOG_PRIMASK ? level_and_mask : APLOG_DEBUG,
+ "%s", errstr);
0005-introduce-per-module-log-levels.patch
------------------------------------------
ap_get_module_loglevel() and ap_set_module_loglevel() get the module
index as an argument, but the doc says "get at *their own*
module-specific loglevel". It seems you can get/set the levels for all
modules, not only your own. But well... If you change the wording,
there's an anlogous comment in
0009-add-loglevel-to-request_rec-and-conn_rec.patch.
Identation in the line: "Setting LogLevel for all modules to %s", arg);
(the line is also contained in
0010-Introcduce-per-dir-loglevel-configuration.patch, but unchanged there)
Twice outdated code comments in log_error_core: "* above the server log
level".
0013-Adjust-loglevels-to-log-less-at-levels-INFO-and-DEBU.patch
---------------------------------------------------------------
Indentation: "proxy: HTTP: canonicalising URL %s", url);
Indentation: loglevel = APLOG_INFO;
Indentation in the "new if" block in server/protocol.c
Indentation in modules/ssl/ssl_engine_kernel.c whenever ap_log_error is
replaced by ap_log_cerror (argument indentation)
0017-associate-CONNECT-errors-with-the-request.patch
----------------------------------------------------
Indentation in modules/proxy/mod_proxy.h whenever ap_log_error is
replaced by ap_log_rerror (argument indentation)
Additional remarks
------------------
We need to fix and add some docs
- removed directives for mod_ssl, mod_rewrite and mod_logio
- new syntax for LogLevel
- merging and inheritance of LogLevels between servers and modules
Later possible improvement: should we add the module_name to the log
line? Since you already know the index, associating the name would be
easy. The question is, whether the info is important enough to add to
the log line.
Regards,
Rainer
Re: Per-module / per-dir loglevel configuration version 4
Posted by Ruediger Pluem <rp...@apache.org>.
On 03.06.2010 20:09, Jeff Trawick wrote:
> On Thu, Jun 3, 2010 at 12:49 PM, Stefan Fritsch <sf...@sfritsch.de> wrote:
>>
>>
>> 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
>
+1
Regards
Rüdiger
Re: Per-module / per-dir loglevel configuration version 4
Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, Jun 3, 2010 at 12:49 PM, Stefan Fritsch <sf...@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
Re: Per-module / per-dir loglevel configuration version 4
Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 6/4/2010 4:47 PM, Stefan Fritsch wrote:
>
> Since we are only initializing a pointer into the module struct, it
> really does not matter if the module_index changes or not. If the
> module is not reloaded, the address of the module struct stays the
> same. If the module is reloaded, the pointer is reinitialized.
Then this all seems complete; +1 to commit, thanks again for all your
diligence in making this improvement painless to module developers!
Re: Per-module / per-dir loglevel configuration version 4
Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Friday 04 June 2010, William A. Rowe Jr. wrote:
> This seems to be a very good solution, and the fact that their are
> no constructor-time calls to initialize this should avoid any
> platform quirks.
>
> My only question is; are we assured to have the same module_index
> reassigned on each config/reload phase? The reason I'm worried is
> that this code won't refresh the index, but there may be platforms
> that don't actually do a module unload/reload/reinit heap of
> aplog_module_index to NULL.
Since we are only initializing a pointer into the module struct, it
really does not matter if the module_index changes or not. If the
module is not reloaded, the address of the module struct stays the
same. If the module is reloaded, the pointer is reinitialized.
A module just must not use a module_struct for logging which is in a
different module/shared object. This could lead to segfaults if the
depended upon module is reloaded (if the runtime linker does not
prevent unloading in this case anyway). But only using your own
module_index for logging does not sound like a limitation to me.
Re: Per-module / per-dir loglevel configuration version 4
Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 6/3/2010 11:49 AM, Stefan Fritsch wrote:
>
> 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.
This seems to be a very good solution, and the fact that their are no
constructor-time calls to initialize this should avoid any platform quirks.
My only question is; are we assured to have the same module_index reassigned
on each config/reload phase? The reason I'm worried is that this code
won't refresh the index, but there may be platforms that don't actually
do a module unload/reload/reinit heap of aplog_module_index to NULL.
Re: Per-module / per-dir loglevel configuration version 4
Posted by Stefan Fritsch <sf...@sfritsch.de>.
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/ ,
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.
Cheers,
Stefan