FossilOrigin-Name: 4f1f8f238cb3fd097504bfba3b51805d359135256160fe8fdba34908495ec50bbsdmakefiles
parent
93914678e0
commit
d4fa4269e7
@ -0,0 +1,26 @@ |
||||
|
||||
#include "dbg.h" |
||||
|
||||
/**
|
||||
* Set debug level |
||||
* @param level debug level to set, allowed values are enumberated in #cw_dbg_levels structure. |
||||
* @param on 1: turns the specified debug level on, 0: turns the specified debug level off. |
||||
*/ |
||||
|
||||
void cw_dbg_set_level (int level, int on) |
||||
{ |
||||
switch (level) { |
||||
case DBG_ALL: |
||||
if (on) |
||||
cw_dbg_opt_level = 0xffffffff; |
||||
else |
||||
cw_dbg_opt_level = 0; |
||||
break; |
||||
default: |
||||
if (on) |
||||
cw_dbg_opt_level |= (1 << (level)); |
||||
else
|
||||
cw_dbg_opt_level &= (0xffffffff) ^ (1 << (level)); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,30 @@ |
||||
|
||||
#include "dbg.h" |
||||
|
||||
int cw_dbg_set_level_from_str(const char *level) |
||||
{ |
||||
int blevel,on; |
||||
const char *slevel; |
||||
|
||||
switch(*level){ |
||||
case '-': |
||||
case '!': |
||||
on =0; |
||||
slevel=level+1; |
||||
break; |
||||
case '+': |
||||
slevel=level+1; |
||||
on=1; |
||||
break; |
||||
default: |
||||
slevel=level; |
||||
on=1; |
||||
} |
||||
|
||||
blevel = cw_strlist_get_id(cw_dbg_strings, slevel); |
||||
if (blevel==-1) |
||||
return 0; |
||||
|
||||
cw_dbg_set_level(blevel,on); |
||||
return 1; |
||||
} |
@ -1,29 +0,0 @@ |
||||
#include <stdarg.h> |
||||
#include "debug.h" |
||||
|
||||
#include "dbg.h" |
||||
#include "log.h" |
||||
|
||||
|
||||
|
||||
void cw_debug(const char * file, int line, struct dbg_Context *ctx, int level,
|
||||
const char * format, ...){ |
||||
va_list args; |
||||
if (!(cw_dbg_is_level(level))) |
||||
return; |
||||
|
||||
/* char fbuf[1024];
|
||||
|
||||
sprintf(fbuf, "DBG:%s%s %s%s%s", |
||||
get_dbg_color_on(level), |
||||
get_dbg_prefix(level), |
||||
get_dbg_color_ontext(level), format, get_dbg_color_off(level) |
||||
); |
||||
|
||||
*/ |
||||
|
||||
va_start(args, format); |
||||
cw_log_console_writer.write(LOG_DEBUG,format,args,&cw_log_console_writer); |
||||
va_end(args); |
||||
} |
||||
|
@ -1,92 +0,0 @@ |
||||
#ifndef __DEBUG_H |
||||
#define __DEBUG_H |
||||
|
||||
/**
|
||||
* Debug levels |
||||
*/
|
||||
enum cw_dbg_levels{ |
||||
/** Show headers of incomming CAPWAP packets */ |
||||
DBG_PKT_IN=0, |
||||
/** Show headers of outgoing CAPWAP packets */ |
||||
DBG_PKT_OUT, |
||||
|
||||
/** Incomming CAPWAP packets with errors, wich would
|
||||
usually silently discarded */
|
||||
DBG_PKT_ERR, |
||||
|
||||
/** Dump content of incomming packets */ |
||||
DBG_PKT_DMP, |
||||
|
||||
/** Display incomming CAPWAP/LWAPP messages */ |
||||
DBG_MSG_IN, |
||||
|
||||
/** Display outgoing CAPWAP/LWAPP messages */ |
||||
DBG_MSG_OUT, |
||||
|
||||
/** Message errors */ |
||||
DBG_MSG_ERR, |
||||
|
||||
/** Show message elements */ |
||||
DBG_ELEM, |
||||
|
||||
/** Show message element details */ |
||||
DBG_ELEM_DETAIL, |
||||
|
||||
/** Error in msg elements */ |
||||
DBG_ELEM_ERR, |
||||
|
||||
/** Show subelements */ |
||||
DBG_SUBELEM, |
||||
|
||||
/** Show dump of subelements */ |
||||
DBG_SUBELEM_DMP, |
||||
|
||||
/** hex dump elements */
|
||||
DBG_ELEM_DMP, |
||||
|
||||
/** General infos, like CAPWAP state */ |
||||
DBG_INFO,
|
||||
|
||||
/** Misc. warnings */ |
||||
DBG_WARN, |
||||
|
||||
/** RFC related */ |
||||
DBG_RFC, |
||||
|
||||
/** DTLS related messages */ |
||||
DBG_DTLS, |
||||
|
||||
/** DTLS BIOs in/out */ |
||||
DBG_DTLS_BIO, |
||||
|
||||
/** Dump DTLS BIO i/o */ |
||||
DBG_DTLS_BIO_DMP, |
||||
|
||||
/** Show DTLS Details */ |
||||
DBG_DTLS_DETAIL, |
||||
|
||||
/** Debug Mods */ |
||||
DBG_MOD, |
||||
|
||||
DBG_X |
||||
}; |
||||
|
||||
|
||||
#define DBG_LN __FILE__,__LINE__ |
||||
|
||||
|
||||
struct dbg_Context{ |
||||
int level; |
||||
}; |
||||
|
||||
|
||||
void cw_debug( const char * file, int line, struct dbg_Context *ctx, int level, |
||||
const char * format, ...); |
||||
|
||||
|
||||
#define DBG_START(ctx,level) cw_debug(__FILE__,__LINE__,ctx,level, |
||||
#define DBG_END ); |
||||
|
||||
|
||||
|
||||
#endif |
Loading…
Reference in new issue