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
tsg-packetadapter/common/include/log.h

74 lines
4.9 KiB
C

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