mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Log变颜色
This commit is contained in:
parent
363172042a
commit
20e127d7df
|
@ -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}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
#include "ILog.h"
|
||||
// #include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
@ -15,3 +16,42 @@ namespace ILogTest
|
|||
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
|
34
test/utils/Log/src/easylogging++.xml
Normal file
34
test/utils/Log/src/easylogging++.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<!-- 启用颜色输出 -->
|
||||
<colored>
|
||||
<value>true</value>
|
||||
</colored>
|
||||
|
||||
<!-- 设置日志格式 -->
|
||||
<formats>
|
||||
<pattern>%datetime %level %msg</pattern>
|
||||
</formats>
|
||||
|
||||
<!-- 其他配置... -->
|
||||
|
||||
<appenders>
|
||||
<console name="Stdout">
|
||||
<enabled>true</enabled>
|
||||
<!-- 对于控制台输出,通常不需要设置颜色,因为<colored>标签已经启用了颜色 -->
|
||||
</console>
|
||||
|
||||
<!-- 如果你还配置了文件输出等其他appender,可以在这里设置 -->
|
||||
|
||||
</appenders>
|
||||
|
||||
<loggers>
|
||||
<root>
|
||||
<level value="debug" />
|
||||
<appender-ref ref="Stdout" />
|
||||
<!-- 引用其他appender(如果有的话) -->
|
||||
</root>
|
||||
</loggers>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user