perf: 将MESA_handle_runtime_log封装为宏函数,先判断日志级别再拼接字符串
This commit is contained in:
@@ -48,16 +48,44 @@
|
|||||||
extern void * g_default_logger;
|
extern void * g_default_logger;
|
||||||
extern bool g_print_to_stderr;
|
extern bool g_print_to_stderr;
|
||||||
|
|
||||||
#define TFE_LOG_ERROR(handler, fmt, ...) \
|
#define TFE_LOG_ERROR(handler, fmt, ...) \
|
||||||
do { if(g_print_to_stderr) fprintf(stderr, fmt "\n" , ##__VA_ARGS__); \
|
do \
|
||||||
MESA_handle_runtime_log((struct log_handle_t *)handler, RLOG_LV_FATAL, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0)
|
{ \
|
||||||
|
if (g_print_to_stderr) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
if (MESA_handle_runtime_log_level_enabled(handler, RLOG_LV_FATAL)) \
|
||||||
|
{ \
|
||||||
|
MESA_handle_runtime_log(handler, RLOG_LV_FATAL, __FUNCTION__, fmt, ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TFE_LOG_INFO(handler, fmt, ...) \
|
#define TFE_LOG_INFO(handler, fmt, ...) \
|
||||||
do { if(g_print_to_stderr) fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
|
do \
|
||||||
MESA_handle_runtime_log((struct log_handle_t *)handler, RLOG_LV_INFO, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) \
|
{ \
|
||||||
|
if (g_print_to_stderr) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
if (MESA_handle_runtime_log_level_enabled(handler, RLOG_LV_INFO)) \
|
||||||
|
{ \
|
||||||
|
MESA_handle_runtime_log(handler, RLOG_LV_INFO, __FUNCTION__, fmt, ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TFE_LOG_DEBUG(handler, fmt, ...) \
|
#define TFE_LOG_DEBUG(handler, fmt, ...) \
|
||||||
do { MESA_handle_runtime_log((struct log_handle_t *)handler, RLOG_LV_DEBUG, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) \
|
do \
|
||||||
|
{ \
|
||||||
|
if (g_print_to_stderr) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
if (MESA_handle_runtime_log_level_enabled(handler, RLOG_LV_DEBUG)) \
|
||||||
|
{ \
|
||||||
|
MESA_handle_runtime_log(handler, RLOG_LV_DEBUG, __FUNCTION__, fmt, ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define CHECK_OR_EXIT(condition, fmt, ...) \
|
#define CHECK_OR_EXIT(condition, fmt, ...) \
|
||||||
do { if(!(condition)) { TFE_LOG_ERROR(g_default_logger, fmt, ##__VA_ARGS__); exit(EXIT_FAILURE); } } while(0) \
|
do { if(!(condition)) { TFE_LOG_ERROR(g_default_logger, fmt, ##__VA_ARGS__); exit(EXIT_FAILURE); } } while(0) \
|
||||||
|
|||||||
Reference in New Issue
Block a user