72 lines
1.3 KiB
C
72 lines
1.3 KiB
C
|
|
|
|
|
|
|
|
#include "stdint.h"
|
|
#include "stdio.h"
|
|
|
|
|
|
|
|
|
|
/*r{ 修改日志打印等级 }c*/
|
|
#ifdef DEBUG
|
|
#define DBG_LOG_LEVEL 0
|
|
#else
|
|
#define DBG_LOG_LEVEL 4
|
|
#endif
|
|
|
|
|
|
/*r{ 定义打印数据等级 }c*/
|
|
#define DBG_LEVEL_INFO 0
|
|
#define DBG_LEVEL_LOG 1
|
|
#define DBG_LEVEL_WARN 2
|
|
#define DBG_LEVEL_ERR 3
|
|
|
|
|
|
#if (DBG_LOG_LEVEL<=DBG_LEVEL_INFO)
|
|
#define DBG_INFO( ml_msg_, ...) \
|
|
DBG_LOG_(DBG_LEVEL_INFO, (ml_msg_), ##__VA_ARGS__)
|
|
#else
|
|
#define DBG_INFO( ml_msg_, ...)
|
|
#endif
|
|
#if (DBG_LOG_LEVEL<=DBG_LEVEL_LOG)
|
|
#define DBG_LOG( ml_msg_, ...) \
|
|
DBG_LOG_(DBG_LEVEL_LOG, (ml_msg_), ##__VA_ARGS__)
|
|
#else
|
|
#define DBG_LOG( ml_msg_, ...)
|
|
#endif
|
|
#if (DBG_LOG_LEVEL<=DBG_LEVEL_WARN)
|
|
#define DBG_WARN( ml_msg_, ...) \
|
|
DBG_LOG_(DBG_LEVEL_WARN, (ml_msg_), ##__VA_ARGS__)
|
|
#else
|
|
#define DBG_WARN( ml_msg_, ...)
|
|
#endif
|
|
#if (DBG_LOG_LEVEL<=DBG_LEVEL_ERR)
|
|
#define DBG_ERR( ml_msg_, ...) \
|
|
DBG_LOG_(DBG_LEVEL_ERR, (ml_msg_), ##__VA_ARGS__)
|
|
#else
|
|
#define DBG_ERR( ml_msg_, ...)
|
|
#endif
|
|
|
|
|
|
#define DBG_LOG_(type_,msg_,...)\
|
|
debug_log(__FILE__,__func__,__LINE__,type_,(msg_),##__VA_ARGS__)
|
|
|
|
// #define DBG_LOG_(type_,msg_,...)
|
|
// debug_log("-","-",__LINE__,type_,(msg_),##__VA_ARGS__)
|
|
|
|
#ifdef DEBUG
|
|
|
|
int debug_init(void);
|
|
|
|
void debug_log(const char *file,const char *fun,int line,int level,const char *fmt, ...);
|
|
|
|
#else
|
|
|
|
#define debug_init()
|
|
#define debug_log(...)
|
|
|
|
|
|
#endif
|
|
|