This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tsg-service-chaining-…/common/include/log.h
2023-10-11 15:20:43 +08:00

72 lines
4.7 KiB
C

#ifndef _LOG_H
#define _LOG_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include <stdio.h>
#include <pthread.h>
#include <MESA/MESA_handle_logger.h>
extern void *g_default_logger;
int LOG_INIT(const char *profile);
void LOG_CLOSE(void);
void LOG_RELOAD(void);
// __FUNCTION__
#define LOG_DEBUG(format, ...) \
do \
{ \
if (g_default_logger) \
{ \
if (MESA_handle_runtime_log_level_enabled(g_default_logger, RLOG_LV_DEBUG)) \
{ \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_DEBUG, __FUNCTION__, format, ##__VA_ARGS__); \
} \
} \
else \
{ \
fprintf(stdout, "DEBUG " format "\n", ##__VA_ARGS__); \
} \
} while (0)
#define LOG_INFO(format, ...) \
do \
{ \
if (g_default_logger) \
{ \
if (MESA_handle_runtime_log_level_enabled(g_default_logger, RLOG_LV_INFO)) \
{ \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_INFO, __FUNCTION__, format, ##__VA_ARGS__); \
} \
} \
else \
{ \
fprintf(stdout, "INFOR " format "\n", ##__VA_ARGS__); \
} \
} while (0)
#define LOG_ERROR(format, ...) \
do \
{ \
if (g_default_logger) \
{ \
if (MESA_handle_runtime_log_level_enabled(g_default_logger, RLOG_LV_FATAL)) \
{ \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_FATAL, __FUNCTION__, format, ##__VA_ARGS__); \
} \
} \
else \
{ \
fprintf(stderr, "ERROR " format "\n", ##__VA_ARGS__); \
} \
} while (0)
#ifdef __cpluscplus
}
#endif
#endif