第一种LOG函数
printf("[%s] ", log_level); \
printf(format,
printf("\n");
第二种LOG函数
UINT1 g_log_level;
#define GN_LOG(log_level, format, arguments...)
{
if(log_level >= g_log_level)
{
switch(log_level)
{
case LOG_DEBUG:
printf("[DEBUG] ");
break;
case LOG_INFO:
printf("[INFO] ");
break;
case LOG_WARNING:
printf("[WARNING] ");
break;
case LOG_ERROR:
printf("[ERROR] ");
break;
case LOG_FATAL:
printf("[FATAL] ");
break;
default:
printf("[WARNING] ");
break;
}
printf(format, ##arguments);
printf("\n");
}
}
第三种LOG函数
#define LOG_INFO(log_level, format, arguments...) \
printf("[INFO] "); \
printf(format, ##arguments); \
printf("\n");
#define LOG_DEBUG(log_level, format, arguments...) \
printf("[DEBUG] "); \
printf(format, ##arguments); \
printf("\n");
#define LOG_WARNING(log_level, format, arguments...) \
printf("[WARNING] "); \
printf(format, ##arguments); \
printf("\n");
#define LOG_ERROR(log_level, format, arguments...) \
printf("[ERROR] "); \
printf(format, ##arguments); \
printf("\n");
enum LOG_LEVEL
{
LOG_DEBUG = 0,
LOG_INFO = 1,
LOG_WARNING = 2,
LOG_ERROR = 3,
LOG_FATAL = 4
};
*/