Fix log enum type parameter.

This commit is contained in:
xiaojiazhu 2023-09-08 20:51:00 -07:00
parent 3c52037560
commit 3daf05fa02
5 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,5 @@
#include "Log.h" #include "ILog.h"
#include "IHal.h" #include "IHal.h"
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -8,7 +8,7 @@ namespace IHalTest
// ../out/test/bin/IHalTest --gtest_filter=IHalTest.Demo // ../out/test/bin/IHalTest --gtest_filter=IHalTest.Demo
TEST(IHalTest, Demo) TEST(IHalTest, Demo)
{ {
InitLog(LOG_EASYLOGGING, nullptr); ILogInit(LOG_EASYLOGGING);
create_hal_module(); create_hal_module();
StatusCode code = IHalInit(); StatusCode code = IHalInit();
if (IsCodeOK(code)) if (IsCodeOK(code))
@ -17,6 +17,6 @@ namespace IHalTest
} }
IHalUnInit(); IHalUnInit();
destroy_hal_module(); destroy_hal_module();
UnInitLog(); ILogUnInit();
} }
} }

View File

@ -1,7 +1,7 @@
# cmake_minimum_required(VERSION 2.8.0) # cmake_minimum_required(VERSION 2.8.0)
#Compile gtest for test code. #Compile gtest for test code.
add_subdirectory(ReturnCode) # add_subdirectory(ReturnCode)
add_subdirectory(Log) add_subdirectory(Log)

View File

@ -11,7 +11,7 @@ namespace ILogTest
LogInfo("hello world."); LogInfo("hello world.");
LogError("create ... failed."); LogError("create ... failed.");
LogDebug("a = %d b = %s", 124, "apple"); LogDebug("a = %d b = %s", 124, "apple");
IHalUnInit(); ILogUnInit();
DestroyLogModule(); DestroyLogModule();
} }
} // namespace ILogTest } // namespace ILogTest

View File

@ -1,7 +1,7 @@
#include "ILog.h" #include "ILog.h"
#include "ILogCpp.h" #include "ILogCpp.h"
#include <string.h> #include <string.h>
static void ILogInitCallBack(ILog *object, const int log) static void ILogInitCallBack(ILog *object, const enum LogInstance log)
{ {
return ILogCpp::GetInstance()->Init(log); return ILogCpp::GetInstance()->Init(log);
} }

View File

@ -35,7 +35,7 @@ extern "C"
typedef struct i_log ILog; typedef struct i_log ILog;
typedef struct i_log typedef struct i_log
{ {
void (*init)(ILog *, const int); void (*init)(ILog *, const enum LogInstance);
void (*free)(ILog *); void (*free)(ILog *);
int (*printf)(ILog *, const char *, const int, const int, const char *, ...); int (*printf)(ILog *, const char *, const int, const int, const char *, ...);
void (*un_init)(ILog *); void (*un_init)(ILog *);
@ -43,11 +43,11 @@ extern "C"
ILog *GetLogIntance(void); ILog *GetLogIntance(void);
void NewILog(ILog **object); void NewILog(ILog **object);
void ResetLogImpl(ILog *impl); void ResetLogImpl(ILog *impl);
static inline void ILogInit(const int log) static inline void ILogInit(const enum LogInstance log)
{ {
return GetLogIntance()->init(GetLogIntance(), log); return GetLogIntance()->init(GetLogIntance(), log);
} }
static inline void ILolUnInit(void) static inline void ILogUnInit(void)
{ {
return GetLogIntance()->un_init(GetLogIntance()); return GetLogIntance()->un_init(GetLogIntance());
} }