[asterisk-dev] ast_debug() vs ast_log(LOG_DEBUG, ...) vs ast_log(AST_LOG_DEBUG, ...)

Olle E. Johansson oej at edvina.net
Tue Jan 4 04:03:41 CST 2011


4 jan 2011 kl. 10.02 skrev Klaus Darilion:

> 
> 
> Am 03.01.2011 18:07, schrieb Russell Bryant:
>> On Wed, 2010-12-22 at 10:25 -0800, Kirill Katsnelson wrote:
>>> There are 190 invocations of ast_log(LOG_DEBUG,...) on the current trunk
>>> head, and about 3000 of ast_debug(). Are these 190 not gated by debug
>>> level on purpose?
>>> 
>>> I am asking because 1.8 outputs 2 debug lines, want it or not, per every
>>> call. It was a nice feature in 1.6 to be able to enable or disable debug
>>> on the fly in 1.6 by just setting "core set debug N" instead of changing
>>> and reloading logger.conf.
>>> 
>>> If that was not done on purpose, it would be nice to see that fixed.
>>> Those 2 printed out of 6 calls to ast_log() in
>>> ast_set_owners_and_peers() are killing me. I can upload a patch for
>>> these 6, but thought it might be ideal to get it fixed en masse in all
>>> 200 places -- assuming this is not currently right.
>> 
>> I can't think of any reason ast_log(LOG_DEBUG, ...) should be used
>> directly.  They should all be converted to ast_debug().
> 
> I tried reading the code but fail to understand the difference between those two, and why there is this wrapper for DEBUG, but no wrappers for other log levels.
> 
> It would be great if someone can enlighten me.

Debug in 1.4 was often wrapped with

if (option_debug > 3) {
	ast_log(LOG_DEBUG, "Hello Klaus!\n");
}

With the macro we can simply write

	ast_debug(3, "Hello again, Klaus\n");


A simplification making the code less cluttered.

/O


More information about the asterisk-dev mailing list