diff --git a/test/utils/Log/CMakeLists.txt b/test/utils/Log/CMakeLists.txt index 277058e2..d9249b23 100644 --- a/test/utils/Log/CMakeLists.txt +++ b/test/utils/Log/CMakeLists.txt @@ -6,11 +6,13 @@ include_directories( . ./src ./include - ${UTILS_SOURCE_PATH}/Log/include + ${UTILS_SOURCE_PATH}/Log/src/easyloggingpp ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include + ) + link_directories( ${LIBS_OUTPUT_PATH} ${EXTERNAL_LIBS_OUTPUT_PATH} diff --git a/test/utils/Log/src/ILogTest.cpp b/test/utils/Log/src/ILogTest.cpp index 4e3bb5b6..055ca0c5 100644 --- a/test/utils/Log/src/ILogTest.cpp +++ b/test/utils/Log/src/ILogTest.cpp @@ -1,3 +1,4 @@ +/* #include "ILog.h" // #include #include @@ -14,4 +15,43 @@ namespace ILogTest ILogUnInit(); DestroyLogModule(); } +} // namespace ILogTest +*/ + +#define ELPP_THREAD_SAFE +#include "easylogging++.h" +#include +#include + +INITIALIZE_EASYLOGGINGPP + +namespace ILogTest +{ + TEST(ILogTest, Demo) + { + + + // 如果你使用的是配置文件,确保它已正确设置并加载 + // 否则,你可以在这里通过编程方式配置elpp + + // 示例:动态设置配置以启用颜色输出(注意:这只是一个示例,实际配置可能不同) + // el::Configurations defaultConf; + // defaultConf.setToDefault(); + // defaultConf.set(el::Level::Global, + // el::ConfigurationType::Format, + // "%datetime %level %msg %func %loc"); + // defaultConf.set(el::Level::Global, + // el::ConfigurationType::EnableColoredLogMessages, + // "true"); + // el::Loggers::reconfigureLogger("default", defaultConf); + + // 使用easylogging++的日志宏 + LOG(INFO) << "hello world..."; + LOG(ERROR) << "create ... failed."; + LOG(DEBUG) << "a = " << 124 << " b = " << "apple"; + + // 注意:在单元测试中,你可能不需要初始化或销毁日志模块, + // 因为easylogging++已经为你处理了这些。 + // 但是,如果你有自己的日志封装或初始化代码,你应该根据需要进行调整。 + } } // namespace ILogTest \ No newline at end of file diff --git a/test/utils/Log/src/easylogging++.xml b/test/utils/Log/src/easylogging++.xml new file mode 100644 index 00000000..5d78fccd --- /dev/null +++ b/test/utils/Log/src/easylogging++.xml @@ -0,0 +1,34 @@ + + + + + + true + + + + + %datetime %level %msg + + + + + + + true + + + + + + + + + + + + + + + + \ No newline at end of file