65 lines
1.7 KiB
C
65 lines
1.7 KiB
C
#ifndef _IPC_I_LOG_H_
|
|
#define _IPC_I_LOG_H_
|
|
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
|
|
#include "ReturnCode.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define LogVerbose(...) get_log_instance()->log_fmt(get_log_instance(), LOG_TYPE_VERBOSE, __VA_ARGS__)
|
|
#define LogInfo(...) get_log_instance()->log_fmt(get_log_instance(), LOG_TYPE_INFORMATION, __VA_ARGS__)
|
|
#define LogDebug(...) get_log_instance()->log_fmt(get_log_instance(), LOG_TYPE_DEBUG, __VA_ARGS__)
|
|
#define LogError(...) get_log_instance()->log_fmt(get_log_instance(), LOG_TYPE_ERROR, __VA_ARGS__)
|
|
#define LogWarning(...) get_log_instance()->log_fmt(get_log_instance(), LOG_TYPE_WARNING, __VA_ARGS__)
|
|
#define LogTrace(...) get_log_instance()->log_fmt(get_log_instance(), LOG_TYPE_TRACE, __VA_ARGS__)
|
|
|
|
typedef enum LogLeveL {
|
|
LOG_TYPE_VERBOSE = 0,
|
|
LOG_TYPE_DEBUG,
|
|
LOG_TYPE_INFORMATION,
|
|
LOG_TYPE_WARNING,
|
|
LOG_TYPE_ERROR,
|
|
LOG_TYPE_TRACE,
|
|
LOG_TYPE_TEST_TIPS,
|
|
LOG_TYPE_END
|
|
}LogLeveL;
|
|
|
|
typedef enum LogMode {
|
|
LOG_MODE_TERMINAL = 0,
|
|
LOG_MODE_LOGFILE,
|
|
LOG_MODE_BOTH,
|
|
}LogMode;
|
|
|
|
typedef struct iLog ILog;
|
|
struct iLog {
|
|
RETURN_CODE_C (*init)(ILog *);
|
|
RETURN_CODE_C (*unInit)(ILog *);
|
|
void (*free)(ILog *);
|
|
void (*log_fmt)(ILog *, const LogLeveL level, const char *fmt, ...);
|
|
};
|
|
ILog* get_log_instance(void);
|
|
void reset_log_impl(ILog *impl);
|
|
RETURN_CODE_C new_i_Log(ILog **impl);
|
|
|
|
static RETURN_CODE_C i_log_init()
|
|
{
|
|
return get_log_instance()->init(get_log_instance());
|
|
}
|
|
|
|
static RETURN_CODE_C i_log_unInit()
|
|
{
|
|
return get_log_instance()->unInit(get_log_instance());
|
|
}
|
|
|
|
RETURN_CODE_C create_log_module(void);
|
|
RETURN_CODE_C destroy_log_module(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif //_IPC_I_LOG_H_
|