embedded-framework/test/utils/Log/src/ILogTest.cpp
2024-07-26 01:21:18 +08:00

57 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
#include "ILog.h"
// #include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace ILogTest
{
// ../output_files/test/bin/LogTest --gtest_filter=ILogTest.Demo
TEST(ILogTest, Demo)
{
CreateLogModule();
ILogInit(LOG_INSTANCE_TYPE_END);
LogInfo("hello world.");
LogError("create ... failed.");
LogDebug("a = %d b = %s", 124, "apple");
ILogUnInit();
DestroyLogModule();
}
} // namespace ILogTest
*/
#define ELPP_THREAD_SAFE
#include "easylogging++.h"
#include <gtest/gtest.h>
#include <gmock/gmock.h>
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