#ifndef ILOG_H #define ILOG_H #ifdef __cplusplus extern "C" { #endif enum LogType { 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 }; typedef struct LogSetting { const char *fileName; // File name of saving log. const char *maxSize; // Max size of saving log. } LogSetting; enum LogInstance { LOG_SERIAL_PRINT = 0, // for serial print. LOG_EASYLOGGING, // for easylogging++. LOG_INSTANCE_TYPE_END }; #define LogVerbose(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_VERBOSE, __VA_ARGS__) #define LogDebug(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_DEBUG, __VA_ARGS__) #define LogInfo(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_INFORMATION, __VA_ARGS__) #define LogWarning(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_WARNING, __VA_ARGS__) #define LogError(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_ERROR, __VA_ARGS__) #define LogTrace(...) GetLogIntance()->printf(GetLogIntance(), __FUNCTION__, __LINE__, LOG_TYPE_TRACE, __VA_ARGS__) #if 1 // For OpenHarmony log, should delete finally.// TODO: #define LOGD(...) #define LOGI(...) #define LOGW(...) #define LOGE(...) #define LOGF(...) #endif typedef struct i_log ILog; typedef struct i_log { void (*init)(ILog *, const enum LogInstance); void (*free)(ILog *); int (*printf)(ILog *, const char *, const int, const enum LogType, const char *, ...); void (*un_init)(ILog *); } ILog; ILog *GetLogIntance(void); void NewILog(ILog **object); void ResetLogImpl(ILog *impl); static inline void ILogInit(const enum LogInstance log) { return GetLogIntance()->init(GetLogIntance(), log); } static inline void ILogUnInit(void) { return GetLogIntance()->un_init(GetLogIntance()); } static inline void ILogFree(void) { GetLogIntance()->free(GetLogIntance()); } void CreateLogModule(void); void DestroyLogModule(void); #ifdef __cplusplus } #endif #endif