]> git.puffer.fish Git - mirror/frr.git/commit
lib: add convenience debugging macros 1860/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 9 Mar 2018 17:07:25 +0000 (12:07 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 12 Mar 2018 15:17:02 +0000 (11:17 -0400)
commit688818844fe662dea093082c2717481779319f43
treedb9387109c39e480d2df960d9a38ac1444708b0a
parentaea03ad6e8198a91578f550cb0c835020e673031
lib: add convenience debugging macros

* Add DEBUG*() macros

This set of macros allows you to write printf-like debugging lines that
automatically check whether a debug is on before printing. This should
eliminate the need for explicit checks in simple cases. For example:

if (SUCH_AND_SUCH_DEBUG_IS_ON) {
zlog_warn(...);
}

Becomes:

DEBUG(warn, such_and_such, ...);

Or, equivalently,

DEBUGE(such_and_such, ...);

The levels passed to DEBUG are expanded into the names of zlog_*
functions, so the same zlog levels are available. There's also a set of
macros that have the level built into them; DEBUGE for errors, DEBUGW
for warnings, etc. Good for brevity.

* Add singular setting macros

Change the 'SET' macros to accept a boolean indicating whether the
provided bits should be set or unset, and map on/off macros to them.
Helps condense code where you already have a boolean condition that
tells you what you want to do as you can avoid writing the branch.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/debug.h