[bind10-dev] consider log4cplus for logging

Stephen Morris stephen at isc.org
Tue May 3 19:44:35 UTC 2011


On 03/05/2011 19:37, Michal 'vorner' Vaner wrote:

> 
> Yes, it seems that would be one such place. But we're still limited for one arg
> there, which isn't nice.

True - of course we are unable to overload macros.

> If we omitted the { } around the call and the
> semicolon, we could use the thing with .arg calls. But then, strange things
> could happen with else statement, unless we would do something really strange
> like:
> 
> #define LOG_DEBUG(LOGGER, LEVEL, ID) \
>   if (!(LOGGER).isDebugEnabled(LEVEL)) { \
>     /* Here be nothing */ \
>   } else { \
>     (LOGGER).debug((LEVEL), (ID))
> 
> Then we could write it like
> LOG_DEBUG(logger, 5, FANCY_FUNCTION).arg(5).arg("Hello");

The alternative I had been thinking of was:

#define LOG_DEBUG(LOGGER, ARG) \
   if ((LOGGER).isDebugEnabled()) { \
	(LOGGER).debug ARG; \
   }

... where ARG is the set of arguments (dbglevel, ID, arg1 ...) actually
enclosed in parentheses.  In other words, we would write:

LOG_DEBUG(logger, (dbglevel, msgid, arg1));

The advantage is that multi-argument versions would also work, i.e.

LOG_DEBUG(logger, (dbglevel, msgid, arg1, arg2));


However, the temporary object method does have the advantage in that you
can have an arbitrary number of arguments.  I can't think of any case
where the "really strange" construct you suggest has an adverse effect,
so I think that is the way to go.


Stephen



More information about the bind10-dev mailing list