From 029d4a97b3967e2ac6f150562c7f2a15bca7fec6 Mon Sep 17 00:00:00 2001 From: Heisenberg Date: Thu, 19 Sep 2019 15:12:46 +0800 Subject: [PATCH] MS-573 Enable log in knowhere Former-commit-id: 7b60e5fc6edcaabea9e967ba4f3312a17533c986 --- cpp/src/core/test/CMakeLists.txt | 9 ++++++--- cpp/src/core/test/test_nsg/CMakeLists.txt | 1 + cpp/src/core/test/utils.cpp | 9 +++++++++ cpp/src/core/test/utils.h | 3 +++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cpp/src/core/test/CMakeLists.txt b/cpp/src/core/test/CMakeLists.txt index 5b8dca2e..d7000722 100644 --- a/cpp/src/core/test/CMakeLists.txt +++ b/cpp/src/core/test/CMakeLists.txt @@ -22,6 +22,9 @@ set(basic_libs gomp gfortran pthread ) +set(util_srcs + ${MILVUS_ENGINE_SRC}/utils/easylogging++.cc + ) # set(ivf_srcs @@ -35,7 +38,7 @@ set(ivf_srcs utils.cpp ) if(NOT TARGET test_ivf) - add_executable(test_ivf test_ivf.cpp ${ivf_srcs}) + add_executable(test_ivf test_ivf.cpp ${ivf_srcs} ${util_srcs}) endif() target_link_libraries(test_ivf ${depend_libs} ${unittest_libs} ${basic_libs}) @@ -51,7 +54,7 @@ set(idmap_srcs utils.cpp ) if(NOT TARGET test_idmap) - add_executable(test_idmap test_idmap.cpp ${idmap_srcs}) + add_executable(test_idmap test_idmap.cpp ${idmap_srcs} ${util_srcs}) endif() target_link_libraries(test_idmap ${depend_libs} ${unittest_libs} ${basic_libs}) @@ -68,7 +71,7 @@ set(kdt_srcs utils.cpp ) if(NOT TARGET test_kdt) - add_executable(test_kdt test_kdt.cpp ${kdt_srcs}) + add_executable(test_kdt test_kdt.cpp ${kdt_srcs} ${util_srcs}) endif() target_link_libraries(test_kdt SPTAGLibStatic diff --git a/cpp/src/core/test/test_nsg/CMakeLists.txt b/cpp/src/core/test/test_nsg/CMakeLists.txt index 9ee8e765..17b62cd4 100644 --- a/cpp/src/core/test/test_nsg/CMakeLists.txt +++ b/cpp/src/core/test/test_nsg/CMakeLists.txt @@ -34,6 +34,7 @@ if(NOT TARGET test_nsg) test_nsg.cpp ${interface_src} ${nsg_src} + ${util_srcs} ) endif() diff --git a/cpp/src/core/test/utils.cpp b/cpp/src/core/test/utils.cpp index 97f4600c..4e240f5f 100644 --- a/cpp/src/core/test/utils.cpp +++ b/cpp/src/core/test/utils.cpp @@ -18,6 +18,15 @@ #include "utils.h" +INITIALIZE_EASYLOGGINGPP + +void InitLog() { + el::Configurations defaultConf; + defaultConf.setToDefault(); + defaultConf.set(el::Level::Debug, + el::ConfigurationType::Format, "[%thread-%datetime-%level]: %msg (%fbase:%line)"); + el::Loggers::reconfigureLogger("default", defaultConf); +} void DataGen::Init_with_default() { Generate(dim, nb, nq); diff --git a/cpp/src/core/test/utils.h b/cpp/src/core/test/utils.h index b9db01de..df7f11d6 100644 --- a/cpp/src/core/test/utils.h +++ b/cpp/src/core/test/utils.h @@ -24,6 +24,7 @@ #include #include "knowhere/adapter/structure.h" +#include "knowhere/common/Log.h" class DataGen { protected: @@ -65,6 +66,8 @@ extern void GenBase(const int64_t &dim, float *xb, int64_t *ids); +extern void InitLog(); + zilliz::knowhere::DatasetPtr generate_dataset(int64_t nb, int64_t dim, float *xb, long *ids); -- GitLab