debug
/* debug masks (32 bits, non-overlapping) */
#define D_BUG 0x00000001
#define D_INFO 0x00000002
#define D_WARNING 0x00000004
#define D_ERROR 0x00000008
#define D_FATAL 0x00000010
#define __MSG__(mask) ((mask) & (__d_info__ | D_WARNING | D_ERROR | D_FATAL)) \
|| ((ylib_dbg & (mask)) && (ylib_sub & DBG_SUBSYS))
#define D_MSG(mask, format, a...) \
do { \
if (__MSG__(mask)) { \
time_t __t = time(NULL); \
char __d_msg_buf[2 * 1024], __d_msg_time[128]; \
strftime(__d_msg_time, 128, "%F %T", localtime(&__t)); \
snprintf(__d_msg_buf, 2 * 1024, \
"%s[%lu]:%s:%d : %s( ):%6lu :%6lu: " format, \
__d_msg_time, (unsigned long)__t, \
__FILE__, __LINE__, __FUNCTION__, \
(unsigned long)getpid( ), \
(unsigned long)pthread_self( ), ##a); \
\
(void) ylog_write(__d_msg_buf); \
} \
} while (0);
#define DINFO(format, a...) D_MSG(D_INFO, "INFO: "format, ## a)
#define DWARN(format, a...) D_MSG(D_WARNING, "WARNING: "format, ## a)
#define DERROR(format, a...) D_MSG(D_ERROR, "ERROR: "format, ## a)
#define DFATAL(format, a...) D_MSG(D_FATAL, "FATAL: "format, ## a)
#ifdef D_MSG_ON
# define DBUG(format, a...) D_MSG(D_BUG, format, ## a)
#else
# define DBUG(format, a...) {}
posted on 2016-04-18 18:22 DayAfterDay 阅读(130) 评论(0) 编辑 收藏 举报