[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-devel] #undef LWIP_DEBUGF
From: |
Gisle Vanem |
Subject: |
Re: [lwip-devel] #undef LWIP_DEBUGF |
Date: |
Tue, 29 Nov 2011 22:10:14 +0100 |
"Kieran Mansley" <address@hidden> wrote:
To be honest, I'd rather simplify the LWIP_DEBUGF macro so it wasn't
incomprehensible. I don't think anyone really makes use of the complexity
it offers, and we could achieve the useful bits with a far simpler version.
Okay, may I suggest a usage something like this:
LWIP_DEBUGF(DNS_DEBUG, LWIP_DBG_LEVEL_WARNING,
("dns_send returned error: %s\n", lwip_strerr(err)));
I.e. print a debug-statement only if 'DNS_DEBUG != 0' and a global
var 'lwip_dbg_level' >= LWIP_DBG_LEVEL_WARNING. And keep as now:
#define LWIP_DBG_LEVEL_WARNING 0x01
#define LWIP_DBG_LEVEL_SERIOUS 0x02
#define LWIP_DBG_LEVEL_SEVERE 0x03
but drop these:
LWIP_DBG_MASK_LEVEL, LWIP_DBG_LEVEL_OFF,
LWIP_DBG_LEVEL_ALL and LWIP_DBG_MIN_LEVEL.
Thus the macro could be (in <lwip/debug.h>):
extern int lwip_dbg_level;
#define LWIP_DEBUGF(debug, level, message) do { \
if ((debug) & (lwip_dbg_level >= (level)))
\
printf message; \
} while (0)
(the printf could be some other var-arg function).
--gv