#include<stdio.h> #define BUG_POWER #ifdef BUG_POWER #define ENTRY 5 #define DEBUG 4 #define INFO 3 #define WARN 2 #define ERROR 1 #define PRINT_LEVEL ENTRY #define pri(Level, ...) do{ if(Level <=PRINT_LEVEL){ printf( "["#Level"] " __VA_ARGS__ ); } }while(0); #define pri_err(...) pri(ERROR,##__VA_ARGS__) #define pri_warn(...) pri(WARN, ##__VA_ARGS__) #define pri_info(...) pri(INFO, ##__VA_ARGS__) #define pri_bug(...) pri(DEBUG,##__VA_ARGS__) #define pri_entry(inout) pri(ENTRY, "%s() %s", __func__, #inout) #else #define pri_err(...) #define pri_warn(...) #define pri_info(...) #define pri_bug(...) #define pri_entry(inout) #endif int main(void) { pri_bug ("FILE:%s FUN:%s LINE:%d DATE:%s TIME:%s text ok!\n", __FILE__, __FUNCTION__, __LINE__, __DATE__, __TIME__); pri_info("FILE:%s FUN:%s LINE:%d DATE:%s TIME:%s text ok!\n", __FILE__, __FUNCTION__, __LINE__, __DATE__, __TIME__); pri_warn("FILE:%s FUN:%s LINE:%d DATE:%s TIME:%s text ok!\n", __FILE__, __FUNCTION__, __LINE__, __DATE__, __TIME__); pri_err ("FILE:%s FUN:%s LINE:%d DATE:%s TIME:%s text ok!\n", __FILE__, __FUNCTION__, __LINE__, __DATE__, __TIME__); return 0; }