接口定义:
#define INFOLEVEL 1
#define DEBUGLEVEL 2
#define WARNINGLEVEL 3
#define ERRORLEVEL 4
#define SDK_PRINT(level,fmt,...)\
do {\
if (level > DEBUGLEVEL) {\
printf("%s:%s(%d): " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);fflush(stdout); \
}\
}\
while (0)
使用方法:
我们可以动态修改if (level > DEBUGLEVEL) {\来调节打印日志的级别
SDK_PRINT(DEBUG,"Failed to open fd, error:%s.\n",strerror(errno))