[asterisk-dev] ast_debug() vs ast_log(LOG_DEBUG, ...) vs ast_log(AST_LOG_DEBUG, ...)
Russell Bryant
russell at digium.com
Tue Jan 4 10:29:01 CST 2011
On Tue, 2011-01-04 at 11:03 +0100, Olle E. Johansson wrote:
> 4 jan 2011 kl. 10.02 skrev Klaus Darilion:
> >> 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.
ast_debug() does a little bit more than check option_debug. You can
also enable debug messages for specific Asterisk modules. The
ast_debug() and ast_verb() macros implement the handling of those
options, as well.
--
Russell Bryant
Digium, Inc. | Engineering Manager, Open Source Software
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
jabber: rbryant at digium.com -=- skype: russell-bryant
www.digium.com -=- www.asterisk.org -=- blogs.asterisk.org
More information about the asterisk-dev
mailing list