From 9f047a14ca748ce095d9c3b38b03c5e8017384b0 Mon Sep 17 00:00:00 2001 From: zhaowenli Date: Thu, 7 Mar 2024 07:14:00 +0000 Subject: [PATCH] =?UTF-8?q?hilog=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaowenli Change-Id: I80b437a4531a1fd5e38a0ee53573fff4b0c094a5 --- bundle.json | 1 + frameworks/BUILD.gn | 6 ++-- frameworks/common/include/sec_comp_log.h | 35 ++++++++----------- .../inner_api/security_component/BUILD.gn | 3 +- .../security_component_service/sa/BUILD.gn | 2 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/bundle.json b/bundle.json index c3244e1..6aba587 100644 --- a/bundle.json +++ b/bundle.json @@ -34,6 +34,7 @@ "hitrace", "graphic_2d", "ipc", + "json", "safwk", "samgr", "window_manager" diff --git a/frameworks/BUILD.gn b/frameworks/BUILD.gn index 94f7ec0..fcce45a 100644 --- a/frameworks/BUILD.gn +++ b/frameworks/BUILD.gn @@ -35,7 +35,6 @@ ohos_source_set("security_component_framework_src_set") { "common/include", "security_component/include", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", - "//third_party/json/include", ] sources = [ @@ -53,6 +52,7 @@ ohos_source_set("security_component_framework_src_set") { external_deps = [ "c_utils:utils", "hilog:libhilog", + "json:nlohmann_json_static", ] cflags_cc = [ @@ -66,7 +66,6 @@ config("security_component_enhance_adapter_src_set_config") { "common/include", "enhance_adapter/include", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", - "//third_party/json/include", ] } @@ -83,7 +82,6 @@ ohos_source_set("security_component_enhance_adapter_src_set") { "common/include", "enhance_adapter/include", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", - "//third_party/json/include", ] sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ] @@ -97,6 +95,8 @@ ohos_source_set("security_component_enhance_adapter_src_set") { "ipc:ipc_single", ] + public_external_deps = [ "json:nlohmann_json_static" ] + cflags_cc = [ "-DHILOG_ENABLE", "-fvisibility=hidden", diff --git a/frameworks/common/include/sec_comp_log.h b/frameworks/common/include/sec_comp_log.h index a366b4e..b0d85a7 100644 --- a/frameworks/common/include/sec_comp_log.h +++ b/frameworks/common/include/sec_comp_log.h @@ -19,31 +19,26 @@ #include "hilog/log.h" -#ifndef __cplusplus - #undef LOG_DOMAIN #define LOG_DOMAIN 0xD005A05 -#define SC_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) - -#else - static constexpr unsigned int SECURITY_DOMAIN_SECURITY_COMPONENT = 0xD005A05; -#define SC_LOG_DEBUG(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Debug(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_INFO(label, fmt, ...) OHOS::HiviewDFX::HiLog::Info(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_WARN(label, fmt, ...) OHOS::HiviewDFX::HiLog::Warn(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_ERROR(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Error(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SC_LOG_FATAL(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Fatal(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) - -#endif // __cplusplus +#define SC_LOG_FATAL(label, fmt, ...) \ + ((void)HILOG_IMPL(label.type, LOG_FATAL, label.domain, label.tag, \ + "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__)) +#define SC_LOG_ERROR(label, fmt, ...) \ + ((void)HILOG_IMPL(label.type, LOG_ERROR, label.domain, label.tag, \ + "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__)) +#define SC_LOG_WARN(label, fmt, ...) \ + ((void)HILOG_IMPL(label.type, LOG_WARN, label.domain, label.tag, \ + "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__)) +#define SC_LOG_INFO(label, fmt, ...) \ + ((void)HILOG_IMPL(label.type, LOG_INFO, label.domain, label.tag, \ + "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__)) +#define SC_LOG_DEBUG(label, fmt, ...) \ + ((void)HILOG_IMPL(label.type, LOG_DEBUG, label.domain, label.tag, \ + "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__)) #else diff --git a/interfaces/inner_api/security_component/BUILD.gn b/interfaces/inner_api/security_component/BUILD.gn index 73f98c5..2469ff9 100644 --- a/interfaces/inner_api/security_component/BUILD.gn +++ b/interfaces/inner_api/security_component/BUILD.gn @@ -22,7 +22,6 @@ config("sec_comp_config") { "${sec_comp_root_dir}/frameworks/common/include", "${sec_comp_root_dir}/frameworks/enhance_adapter/include/", "${sec_comp_root_dir}/interfaces/inner_api/enhance_kits/include", - "//third_party/json/include", ] } @@ -68,6 +67,8 @@ ohos_shared_library("libsecurity_component_sdk") { "samgr:samgr_proxy", ] + public_external_deps = [ "json:nlohmann_json_static" ] + cflags_cc = [ "-DHILOG_ENABLE", "-fvisibility=hidden", diff --git a/services/security_component_service/sa/BUILD.gn b/services/security_component_service/sa/BUILD.gn index 7ea81ab..12a900a 100644 --- a/services/security_component_service/sa/BUILD.gn +++ b/services/security_component_service/sa/BUILD.gn @@ -117,6 +117,6 @@ ohos_shared_library("security_component_service") { "${sec_comp_root_dir}/frameworks:security_component_enhance_adapter_src_set", "${sec_comp_root_dir}/frameworks:security_component_framework_src_set", ] - + external_deps = [ "hilog:libhilog" ] public_configs = [ ":security_component_service_config" ] } -- Gitee