diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt index 513eeb898f61eb46941b747426a1502dab8bd814..d38f325fdb919798e060b8915a6b1a1acca2e17a 100644 --- a/base/CMakeLists.txt +++ b/base/CMakeLists.txt @@ -102,7 +102,7 @@ target_link_libraries(rt2_registry_objects PRIVATE $ c_sec - slog + unified_dlog static_mmpa PUBLIC metadef_headers diff --git a/cmake/modules/Findslog.cmake b/cmake/modules/Findslog.cmake index cf1ca521d145b9350e36ae0f95791abdadcf99d9..d23d684a201260bedfd3005008ce281ae2d426e5 100644 --- a/cmake/modules/Findslog.cmake +++ b/cmake/modules/Findslog.cmake @@ -15,7 +15,7 @@ endif() set(_cmake_targets_defined "") set(_cmake_targets_not_defined "") set(_cmake_expected_targets "") -foreach(_cmake_expected_target IN ITEMS slog alog slog_headers) +foreach(_cmake_expected_target IN ITEMS slog alog old_slog_headers) list(APPEND _cmake_expected_targets "${_cmake_expected_target}") if(TARGET "${_cmake_expected_target}") list(APPEND _cmake_targets_defined "${_cmake_expected_target}") @@ -81,19 +81,19 @@ if(slog_FOUND) add_library(slog SHARED IMPORTED) set_target_properties(slog PROPERTIES INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG" - INTERFACE_LINK_LIBRARIES "slog_headers" + INTERFACE_LINK_LIBRARIES "old_slog_headers" IMPORTED_LOCATION "${slog_SHARED_LIBRARY}" ) add_library(alog SHARED IMPORTED) set_target_properties(alog PROPERTIES INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG" - INTERFACE_LINK_LIBRARIES "slog_headers" + INTERFACE_LINK_LIBRARIES "old_slog_headers" IMPORTED_LOCATION "${alog_SHARED_LIBRARY}" ) - add_library(slog_headers INTERFACE IMPORTED) - set_target_properties(slog_headers PROPERTIES + add_library(old_slog_headers INTERFACE IMPORTED) + set_target_properties(old_slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${slog_INCLUDE_DIR};${slog_INCLUDE_DIR}/slog;${slog_INCLUDE_DIR}/slog/toolchain" ) @@ -104,7 +104,7 @@ if(slog_FOUND) cmake_print_properties(TARGETS alog PROPERTIES INTERFACE_COMPILE_DEFINITIONS INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION ) - cmake_print_properties(TARGETS slog_headers + cmake_print_properties(TARGETS old_slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ) endif() diff --git a/cmake/modules/Findunified_dlog.cmake b/cmake/modules/Findunified_dlog.cmake index 9cf28c87590fca361c6d070fc0618850b9ea0cba..260d511e41b1857c93552d961913fda0d76b8292 100644 --- a/cmake/modules/Findunified_dlog.cmake +++ b/cmake/modules/Findunified_dlog.cmake @@ -15,7 +15,7 @@ endif() set(_cmake_targets_defined "") set(_cmake_targets_not_defined "") set(_cmake_expected_targets "") -foreach(_cmake_expected_target IN ITEMS unified_dlog unified_dlog_headers) +foreach(_cmake_expected_target IN ITEMS unified_dlog slog_headers) list(APPEND _cmake_expected_targets "${_cmake_expected_target}") if(TARGET "${_cmake_expected_target}") list(APPEND _cmake_targets_defined "${_cmake_expected_target}") @@ -43,8 +43,9 @@ unset(_cmake_targets_defined) unset(_cmake_targets_not_defined) unset(_cmake_expected_targets) -find_path(_INCLUDE_DIR - NAMES toolchain/dlog_pub.h +find_path(_INCLUDE_DIR_DLOG_PUB + NAMES dlog_pub.h + PATH_SUFFIXES pkg_inc/base NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) @@ -59,12 +60,12 @@ find_package_handle_standard_args(unified_dlog FOUND_VAR unified_dlog_FOUND REQUIRED_VARS - _INCLUDE_DIR + _INCLUDE_DIR_DLOG_PUB unified_dlog_SHARED_LIBRARY ) if(unified_dlog_FOUND) - set(unified_dlog_INCLUDE_DIR "${_INCLUDE_DIR}") + set(unified_dlog_INCLUDE_DIR "${_INCLUDE_DIR_DLOG_PUB}") include(CMakePrintHelpers) message(STATUS "Variables in unified_dlog module:") cmake_print_variables(unified_dlog_INCLUDE_DIR) @@ -72,23 +73,23 @@ if(unified_dlog_FOUND) add_library(unified_dlog SHARED IMPORTED) set_target_properties(unified_dlog PROPERTIES - INTERFACE_LINK_LIBRARIES "unified_dlog_headers" + INTERFACE_LINK_LIBRARIES "slog_headers" IMPORTED_LOCATION "${unified_dlog_SHARED_LIBRARY}" ) - add_library(unified_dlog_headers INTERFACE IMPORTED) - set_target_properties(unified_dlog_headers PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${unified_dlog_INCLUDE_DIR};${unified_dlog_INCLUDE_DIR}/toolchain" + add_library(slog_headers INTERFACE IMPORTED) + set_target_properties(slog_headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${unified_dlog_INCLUDE_DIR}" ) include(CMakePrintHelpers) cmake_print_properties(TARGETS unified_dlog PROPERTIES INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION ) - cmake_print_properties(TARGETS unified_dlog_headers + cmake_print_properties(TARGETS slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ) endif() # Cleanup temporary variables. -set(_INCLUDE_DIR) \ No newline at end of file +set(_INCLUDE_DIR_DLOG_PUB) \ No newline at end of file diff --git a/cmake/modules/sub_module/Findslog.cmake b/cmake/modules/sub_module/Findslog.cmake index 718d162d5778a873578126424bea1c23c0818fa9..d23d684a201260bedfd3005008ce281ae2d426e5 100644 --- a/cmake/modules/sub_module/Findslog.cmake +++ b/cmake/modules/sub_module/Findslog.cmake @@ -15,7 +15,7 @@ endif() set(_cmake_targets_defined "") set(_cmake_targets_not_defined "") set(_cmake_expected_targets "") -foreach(_cmake_expected_target IN ITEMS slog alog slog_headers) +foreach(_cmake_expected_target IN ITEMS slog alog old_slog_headers) list(APPEND _cmake_expected_targets "${_cmake_expected_target}") if(TARGET "${_cmake_expected_target}") list(APPEND _cmake_targets_defined "${_cmake_expected_target}") @@ -44,7 +44,7 @@ unset(_cmake_targets_not_defined) unset(_cmake_expected_targets) find_path(_INCLUDE_DIR - NAMES pkg_inc/base/dlog_pub.h + NAMES experiment/slog/toolchain/slog.h NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) @@ -71,7 +71,7 @@ find_package_handle_standard_args(slog ) if(slog_FOUND) - set(slog_INCLUDE_DIR "${_INCLUDE_DIR}") + set(slog_INCLUDE_DIR "${_INCLUDE_DIR}/experiment") include(CMakePrintHelpers) message(STATUS "Variables in slog module:") cmake_print_variables(slog_INCLUDE_DIR) @@ -81,20 +81,20 @@ if(slog_FOUND) add_library(slog SHARED IMPORTED) set_target_properties(slog PROPERTIES INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG" - INTERFACE_LINK_LIBRARIES "slog_headers" + INTERFACE_LINK_LIBRARIES "old_slog_headers" IMPORTED_LOCATION "${slog_SHARED_LIBRARY}" ) add_library(alog SHARED IMPORTED) set_target_properties(alog PROPERTIES INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG" - INTERFACE_LINK_LIBRARIES "slog_headers" + INTERFACE_LINK_LIBRARIES "old_slog_headers" IMPORTED_LOCATION "${alog_SHARED_LIBRARY}" ) - add_library(slog_headers INTERFACE IMPORTED) - set_target_properties(slog_headers PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${slog_INCLUDE_DIR};${slog_INCLUDE_DIR}/pkg_inc;${slog_INCLUDE_DIR}/pkg_inc/base" + add_library(old_slog_headers INTERFACE IMPORTED) + set_target_properties(old_slog_headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${slog_INCLUDE_DIR};${slog_INCLUDE_DIR}/slog;${slog_INCLUDE_DIR}/slog/toolchain" ) include(CMakePrintHelpers) @@ -104,7 +104,7 @@ if(slog_FOUND) cmake_print_properties(TARGETS alog PROPERTIES INTERFACE_COMPILE_DEFINITIONS INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION ) - cmake_print_properties(TARGETS slog_headers + cmake_print_properties(TARGETS old_slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ) endif() diff --git a/cmake/modules/sub_module/Findunified_dlog.cmake b/cmake/modules/sub_module/Findunified_dlog.cmake index 00b1d5d418da53a0bfcac15dff67943452f44f09..260d511e41b1857c93552d961913fda0d76b8292 100644 --- a/cmake/modules/sub_module/Findunified_dlog.cmake +++ b/cmake/modules/sub_module/Findunified_dlog.cmake @@ -15,7 +15,7 @@ endif() set(_cmake_targets_defined "") set(_cmake_targets_not_defined "") set(_cmake_expected_targets "") -foreach(_cmake_expected_target IN ITEMS unified_dlog unified_dlog_headers) +foreach(_cmake_expected_target IN ITEMS unified_dlog slog_headers) list(APPEND _cmake_expected_targets "${_cmake_expected_target}") if(TARGET "${_cmake_expected_target}") list(APPEND _cmake_targets_defined "${_cmake_expected_target}") @@ -43,8 +43,9 @@ unset(_cmake_targets_defined) unset(_cmake_targets_not_defined) unset(_cmake_expected_targets) -find_path(_INCLUDE_DIR - NAMES pkg_inc/base/dlog_pub.h +find_path(_INCLUDE_DIR_DLOG_PUB + NAMES dlog_pub.h + PATH_SUFFIXES pkg_inc/base NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) @@ -59,12 +60,12 @@ find_package_handle_standard_args(unified_dlog FOUND_VAR unified_dlog_FOUND REQUIRED_VARS - _INCLUDE_DIR + _INCLUDE_DIR_DLOG_PUB unified_dlog_SHARED_LIBRARY ) if(unified_dlog_FOUND) - set(unified_dlog_INCLUDE_DIR "${_INCLUDE_DIR}") + set(unified_dlog_INCLUDE_DIR "${_INCLUDE_DIR_DLOG_PUB}") include(CMakePrintHelpers) message(STATUS "Variables in unified_dlog module:") cmake_print_variables(unified_dlog_INCLUDE_DIR) @@ -72,23 +73,23 @@ if(unified_dlog_FOUND) add_library(unified_dlog SHARED IMPORTED) set_target_properties(unified_dlog PROPERTIES - INTERFACE_LINK_LIBRARIES "unified_dlog_headers" + INTERFACE_LINK_LIBRARIES "slog_headers" IMPORTED_LOCATION "${unified_dlog_SHARED_LIBRARY}" ) - add_library(unified_dlog_headers INTERFACE IMPORTED) - set_target_properties(unified_dlog_headers PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${unified_dlog_INCLUDE_DIR};${unified_dlog_INCLUDE_DIR}/pkg_inc;${unified_dlog_INCLUDE_DIR}/pkg_inc/base" + add_library(slog_headers INTERFACE IMPORTED) + set_target_properties(slog_headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${unified_dlog_INCLUDE_DIR}" ) include(CMakePrintHelpers) cmake_print_properties(TARGETS unified_dlog PROPERTIES INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION ) - cmake_print_properties(TARGETS unified_dlog_headers + cmake_print_properties(TARGETS slog_headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ) endif() # Cleanup temporary variables. -set(_INCLUDE_DIR) \ No newline at end of file +set(_INCLUDE_DIR_DLOG_PUB) \ No newline at end of file diff --git a/tests/depends/slog/src/slog_stub.cc b/tests/depends/slog/src/slog_stub.cc index 4e6ee13672f36c030451e02f2513f3805adb8d41..39a840dd3e57fa1f3778d5ac618af9f409782a37 100644 --- a/tests/depends/slog/src/slog_stub.cc +++ b/tests/depends/slog/src/slog_stub.cc @@ -8,8 +8,6 @@ * ===================================================================================================================*/ #include "slog_stub.h" -#include "toolchain/dlog_pub.h" -#include "toolchain/plog.h" #include #include @@ -19,7 +17,7 @@ #include namespace ge { -int ge_log_level = DLOG_ERROR; +int ge_log_level = ge::GeLogLevel::kDlogError; auto ins = ge::SlogStub::GetInstance(); // 让log提前初始化 class DefaultSlogStub : public SlogStub { public: @@ -28,7 +26,7 @@ class DefaultSlogStub : public SlogStub { if (log_level != nullptr) { SetLevel(atoi(log_level)); } else { - SetLevel(DLOG_ERROR); + SetLevel(ge::GeLogLevel::kDlogError); } auto log_event_level = getenv("ASCEND_GLOBAL_EVENT_ENABLE"); if (log_event_level != nullptr) { @@ -40,7 +38,7 @@ class DefaultSlogStub : public SlogStub { if ((!log_init) || (level < GetLevel())) { return; } - if (level == DLOG_EVENT && GetEventLevel() < 1) { + if (level == ge::GeLogLevel::kDlogEvent && GetEventLevel() < 1) { return; } char fmt_buff[1536] = {0}; @@ -52,7 +50,7 @@ class DefaultSlogStub : public SlogStub { SlogStub::~SlogStub() { log_init = false; - ge_log_level = DLOG_ERROR; + ge_log_level = ge::GeLogLevel::kDlogError; } void SlogStub::SetEventLevel(int event_level) { @@ -139,7 +137,7 @@ void DlogRecord(int moduleId, int level, const char *fmt, ...) { va_list valist; va_start(valist, fmt); if (moduleId & RUN_LOG_MASK) { - ge::SlogStub::GetInstance()->Log(moduleId & (~RUN_LOG_MASK), DLOG_EVENT, fmt, valist); + ge::SlogStub::GetInstance()->Log(moduleId & (~RUN_LOG_MASK), ge::GeLogLevel::kDlogEvent, fmt, valist); } else { ge::SlogStub::GetInstance()->Log(moduleId, level, fmt, valist); } @@ -149,14 +147,14 @@ void DlogRecord(int moduleId, int level, const char *fmt, ...) { void DlogErrorInner(int module_id, const char *fmt, ...) { va_list valist; va_start(valist, fmt); - ge::SlogStub::GetInstance()->Log(module_id, DLOG_ERROR, fmt, valist); + ge::SlogStub::GetInstance()->Log(module_id, ge::GeLogLevel::kDlogError, fmt, valist); va_end(valist); } void DlogWarnInner(int module_id, const char *fmt, ...) { va_list valist; va_start(valist, fmt); - ge::SlogStub::GetInstance()->Log(module_id, DLOG_WARN, fmt, valist); + ge::SlogStub::GetInstance()->Log(module_id, ge::GeLogLevel::kDlogWarn, fmt, valist); va_end(valist); } @@ -164,9 +162,9 @@ void DlogInfoInner(int module_id, const char *fmt, ...) { va_list valist; va_start(valist, fmt); if (module_id & RUN_LOG_MASK) { - ge::SlogStub::GetInstance()->Log(module_id & (~RUN_LOG_MASK), DLOG_EVENT, fmt, valist); + ge::SlogStub::GetInstance()->Log(module_id & (~RUN_LOG_MASK), ge::GeLogLevel::kDlogEvent, fmt, valist); } else { - ge::SlogStub::GetInstance()->Log(module_id, DLOG_INFO, fmt, valist); + ge::SlogStub::GetInstance()->Log(module_id, ge::GeLogLevel::kDlogInfo, fmt, valist); } va_end(valist); } @@ -174,14 +172,14 @@ void DlogInfoInner(int module_id, const char *fmt, ...) { void DlogDebugInner(int module_id, const char *fmt, ...) { va_list valist; va_start(valist, fmt); - ge::SlogStub::GetInstance()->Log(module_id, DLOG_DEBUG, fmt, valist); + ge::SlogStub::GetInstance()->Log(module_id, ge::GeLogLevel::kDlogDebug, fmt, valist); va_end(valist); } void DlogEventInner(int module_id, const char *fmt, ...) { va_list valist; va_start(valist, fmt); - ge::SlogStub::GetInstance()->Log((module_id & (~RUN_LOG_MASK)), DLOG_EVENT, fmt, valist); + ge::SlogStub::GetInstance()->Log((module_id & (~RUN_LOG_MASK)), ge::GeLogLevel::kDlogEvent, fmt, valist); va_end(valist); } diff --git a/tests/depends/slog/src/slog_stub.h b/tests/depends/slog/src/slog_stub.h index 42ae52cecf041c3f4296570f661275b4a353cafe..d4352e6f9e639b683d0570229a69d2a20555888d 100644 --- a/tests/depends/slog/src/slog_stub.h +++ b/tests/depends/slog/src/slog_stub.h @@ -13,8 +13,16 @@ #include #include #include -#include "toolchain/slog.h" +#include "dlog_pub.h" namespace ge { +enum GeLogLevel : int { + kDlogDebug = 0, + kDlogInfo = 1, + kDlogWarn = 2, + kDlogError = 3, + kDlogNull = 4, + kDlogEvent = 5 +}; class SlogStub { public: SlogStub() { @@ -59,26 +67,25 @@ class SlogStub { void SetLevel(int level); void SetEventLevel(int event_level); void SetLevelDebug() { - SetLevel(DLOG_DEBUG); + SetLevel(GeLogLevel::kDlogDebug); } void SetLevelInfo() { - SetLevel(DLOG_INFO); + SetLevel(GeLogLevel::kDlogInfo); } protected: bool log_init = false; private: - int log_level_ = DLOG_ERROR; + int log_level_ = GeLogLevel::kDlogError; int event_log_level_ = 0; std::map level_str = { - {DLOG_DEBUG, "[DEBUG]"}, - {DLOG_INFO, "[INFO]"}, - {DLOG_WARN, "[WARNING]"}, - {DLOG_ERROR, "[ERROR]"}, - {DLOG_DEBUG, "[TRACE]"}, - {DLOG_NULL, "[NULL]"}, - {DLOG_EVENT, "[EVENT]"} + {GeLogLevel::kDlogDebug, "[DEBUG]"}, + {GeLogLevel::kDlogInfo, "[INFO]"}, + {GeLogLevel::kDlogWarn, "[WARNING]"}, + {GeLogLevel::kDlogError, "[ERROR]"}, + {GeLogLevel::kDlogNull, "[NULL]"}, + {GeLogLevel::kDlogEvent, "[EVENT]"} }; std::map module_id_str = { {GE, "GE"}, diff --git a/tests/ut/base/CMakeLists.txt b/tests/ut/base/CMakeLists.txt index ddd108f7bee2dfc7a38f2d0b4a28cf69a0c9a195..28a175c721ad9448f3946a10ff91d0ee6fd7a4e7 100644 --- a/tests/ut/base/CMakeLists.txt +++ b/tests/ut/base/CMakeLists.txt @@ -45,7 +45,6 @@ target_compile_definitions(ut_metadef PRIVATE target_link_libraries(ut_metadef PRIVATE intf_pub -lgcov -Wl,--no-as-needed - slog slog_headers metadef_headers metadef opp_registry error_manager GTest::gtest GTest::gtest_main ascend_protobuf slog_stub c_sec json mmpa_stub -lrt -ldl diff --git a/tests/ut/register/CMakeLists.txt b/tests/ut/register/CMakeLists.txt index 51505b534037d846a467d8947b7964802a608819..7f4ffac976929c88973782406beb32b29aebfc3a 100644 --- a/tests/ut/register/CMakeLists.txt +++ b/tests/ut/register/CMakeLists.txt @@ -38,7 +38,6 @@ target_link_libraries(ut_register intf_pub metadef_headers runtime_headers - slog slog_headers msprof_headers metadef exe_graph mmpa