From a7442cb0ca064d95bd78c53a4cd21603e66942ac Mon Sep 17 00:00:00 2001 From: luocai Date: Mon, 25 Dec 2023 18:52:51 +0800 Subject: [PATCH] Update boost log init parameters. --- .vscode/c_cpp_properties.json | 17 +++++++++++++++++ CMakeLists.txt | 6 ++++++ UnitTest/CMakeLists.txt | 16 ++++++++++++++++ UnitTest/main.cpp | 2 ++ Universal/BoostLog.cpp | 6 +++--- Universal/BoostLog.h | 9 ++++++++- resource/deploy.sh | 10 +++++----- 7 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 UnitTest/CMakeLists.txt create mode 100644 UnitTest/main.cpp diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..93f54e3 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/opt/Libraries/boost_1_84_0/include" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index afc990e..8b8e970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.15) project(Kylin) +option(UNIT_TEST "do unit test" OFF) + set(OpenSSL_LIBRARY ssl crypto) @@ -20,3 +22,7 @@ endif() if(TARGET Boost::log) add_subdirectory(Universal) endif() + +if(UNIT_TEST) + add_subdirectory(UnitTest) +endif() \ No newline at end of file diff --git a/UnitTest/CMakeLists.txt b/UnitTest/CMakeLists.txt new file mode 100644 index 0000000..763d656 --- /dev/null +++ b/UnitTest/CMakeLists.txt @@ -0,0 +1,16 @@ +find_package(Boost REQUIRED COMPONENTS unit_test_framework) + +# --detect_memory_leak=0 --run_test=MarkdownParserTest,ProcessUtilityTest +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(UnitTest main.cpp +) + +target_compile_definitions(UnitTest + PUBLIC LOG_FILTER_LEVEL=1 +) + +target_link_libraries(UnitTest + PRIVATE Boost::unit_test_framework +) diff --git a/UnitTest/main.cpp b/UnitTest/main.cpp new file mode 100644 index 0000000..4cd512b --- /dev/null +++ b/UnitTest/main.cpp @@ -0,0 +1,2 @@ +#define BOOST_TEST_MODULE KylinLibraryTest +#include "boost/test/included/unit_test.hpp" diff --git a/Universal/BoostLog.cpp b/Universal/BoostLog.cpp index 61c6703..5fd5608 100644 --- a/Universal/BoostLog.cpp +++ b/Universal/BoostLog.cpp @@ -17,7 +17,7 @@ BOOST_LOG_GLOBAL_LOGGER_INIT(location_logger, LocationLoggeradd_sink(sink); #else std::ostringstream oss; - oss << name << "_%Y-%m-%d_%H.%M.%S_%N.log"; + oss << filename << "_%Y-%m-%d_%H.%M.%S_%N.log"; auto fileSink = - add_file_log(keywords::file_name = oss.str(), keywords::auto_flush = true, keywords::target = "logs"); + add_file_log(keywords::file_name = oss.str(), keywords::auto_flush = true, keywords::target = target); fileSink->set_formatter(&logFormatter); #endif initialized = true; diff --git a/Universal/BoostLog.h b/Universal/BoostLog.h index 53fab16..6b727ad 100644 --- a/Universal/BoostLog.h +++ b/Universal/BoostLog.h @@ -52,8 +52,15 @@ #define LOG_FILTER_LEVEL (boost::log::trivial::info) #endif +/** + * @brief + * + * @param filename log file path + * @param target path for rotated log files + * @param filter + */ void initBoostLog( - const std::string &name = "app", + const std::string &filename = "logs/app", const std::string &target = "logs", boost::log::trivial::severity_level filter = static_cast(LOG_FILTER_LEVEL)); namespace AmassKeywords { diff --git a/resource/deploy.sh b/resource/deploy.sh index c6b4339..5bf71f6 100644 --- a/resource/deploy.sh +++ b/resource/deploy.sh @@ -1,6 +1,7 @@ #!/bin/bash base_path=$(pwd) +qt_prefix_path="/opt/Qt/6.6.1/gcc_64" libraries_root="/opt/Libraries" if [ $base_path == /home/* ] || [ -n "${DRONE}" ]; then build_path=${base_path}/build @@ -9,8 +10,7 @@ else fi echo "build directory: $build_path" -if [ -d "/opt/Qt/6.5.2/gcc_64" ]; then - qt_prefix_path="/opt/Qt/6.5.2/gcc_64" +if [ -d ${qt_prefix_path} ]; then # 先找Qt6 cmake_qt_parameters="-DCMAKE_PREFIX_PATH=${qt_prefix_path} \ -DQT_QMAKE_EXECUTABLE=${qt_prefix_path}/bin/qmake \ -DQT_DIR=${qt_prefix_path}/lib/cmake/Qt6 \ @@ -35,7 +35,7 @@ elif [ -d "/opt/Qt/5.15.2/gcc_64" ]; then -DQt5Svg_DIR=${qt_prefix_path}/lib/cmake/Qt5Svg " else cmake_qt_parameters="" - echo "please install qt6.5.2 or qt5.15.2 ..." + echo "please install qt6.6.1 or qt5.15.2 ..." fi function cmake_scan() { @@ -47,7 +47,7 @@ function cmake_scan() { -S ${base_path} \ -B ${build_path} \ -DCMAKE_BUILD_TYPE=Debug \ - -DBOOST_ROOT=${libraries_root}/boost_1_83_0 \ + -DBOOST_ROOT=${libraries_root}/boost_1_84_0 \ -DZeroMQ_ROOT=${libraries_root}/zeromq-4.3.4_debug \ ${cmake_qt_parameters} } @@ -77,4 +77,4 @@ function main() { esac } -main $@ \ No newline at end of file +main $@