宏定义 注意

#define _ALERT         0
#define _CRIT          1
#define _ERR           2
#define _WARNING       3
#define _NOTICE        4
#define _INFO          5
#define _DEBUG         6

#define DP_ALERT_TEXT       "ALERT:"
#define DP_CRIT_TEXT        "CRITICAL:"
#define DP_ERR_TEXT         "ERROR:"
#define DP_WARNING_TEXT     "WARNING:"
#define DP_NOTICE_TEXT      "NOTICE:"
#define DP_INFO_TEXT        "INFO:"
#define DP_DEBUG_TEXT       "DEBUG:"

static int debug_level;

#define DEBUG(lev, fmt, args...) \
    do { \
        if (debug_level > (lev)){ \
            fprintf(stderr, "%d [%d] " DP##lev##_TEXT fmt, time(), getpid(), __FUNCTION__, ## args); \
        } \
    }while(0)

#define LM_ALERT(fmt, args...)      DEBUG(_ALERT, fmt, ##args)
#define LM_CRIT(fmt, args...)       DEBUG(_CRIT, fmt, ##args)
#define LM_ERR(fmt, args...)        DEBUG(_ERR, fmt, ##args)
#define LM_WARN(fmt, args...)       DEBUG(_WARNING, fmt, ##args)
#define LM_NOTICE(fmt, args...)     DEBUG(_NOTICE, fmt, ##args)
#define LM_INFO(fmt, args...)       DEBUG(_INFO, fmt, ##args)
#define LM_DBG(fmt, args...)        DEBUG(_DEBUG, fmt, ##args)

http://blog.csdn.net/dotphoenix/article/details/4345174

http://blog.csdn.net/liangwei88624/article/details/6300544

http://hi.baidu.com/_kouu/blog/item/ff6d8fc3f663cc3ce5dd3b2d.html

原文地址:https://www.cnblogs.com/moonflow/p/2462228.html