printf的定义
1. printf的宏定义
#define XXX_ERROR 0
#define XXX_WARNING 1
#define XXX_INFO 2
#define XXX_DEBUG 3
#define XXX_NONE 0xFF
#define XXX_DEBUG_LEVEL XXX_DEBUG
#if (XXX_DEBUG_LEVEL >= XXX_NONE)
#define xxx_printf(level, fmt, arg...)
#else
#define xxx_printf(level, fmt, arg...) \
do {\
if (level <= XXX_DEBUG_LEVEL) {\
switch(level)\
{\
case XXX_ERROR :\
printf("\r\n[Error] "fmt, ##arg);\
break;\
case XXX_WARNING :\
printf("\r\n[Warning] "fmt, ##arg);\
break;\
case XXX_INFO :\
printf("\r\n[Info] "fmt, ##arg);\
break;\
case XXX_DEBUG :\
printf("\r\n[Debug] "fmt, ##arg);\
break;\
default :\
printf("\r\n[Level] "fmt, ##arg);\
break;\
}\
}\
}while(0)
#endif