diff --git a/interfaces/innerkits/lsamgr/BUILD.gn b/interfaces/innerkits/lsamgr/BUILD.gn index 932b647b5e92c6b84d318ff39c96a4cfd58838a3..67f58589f0c70b403bf8d61e59268f6256c57030 100755 --- a/interfaces/innerkits/lsamgr/BUILD.gn +++ b/interfaces/innerkits/lsamgr/BUILD.gn @@ -30,7 +30,7 @@ ohos_shared_library("lsamgr") { configs = [ ":config_samgr" ] if (is_standard_system) { external_deps = [ - "hiviewdfx_hilog_native:libhilog", + "hiviewdfx_hilog_native:libhilog_base", "ipc:ipc_core", ] part_name = "samgr_standard" diff --git a/interfaces/innerkits/samgr_proxy/BUILD.gn b/interfaces/innerkits/samgr_proxy/BUILD.gn index 47f0b41b9256b0b50c71196fb41464a6f1e3b1a6..035a9393e701a795361ff4c76379bbcc1cff8ccd 100755 --- a/interfaces/innerkits/samgr_proxy/BUILD.gn +++ b/interfaces/innerkits/samgr_proxy/BUILD.gn @@ -48,7 +48,7 @@ ohos_shared_library("samgr_proxy") { if (is_standard_system) { external_deps = [ - "hiviewdfx_hilog_native:libhilog", + "hiviewdfx_hilog_native:libhilog_base", "ipc:ipc_core", ] diff --git a/interfaces/innerkits/samgr_proxy/include/sam_log.h b/interfaces/innerkits/samgr_proxy/include/sam_log.h index f8b202ac1449008d081087b34f872608a89869ae..9921979cd308f7d98cff727adf0962f861fa942c 100644 --- a/interfaces/innerkits/samgr_proxy/include/sam_log.h +++ b/interfaces/innerkits/samgr_proxy/include/sam_log.h @@ -16,14 +16,9 @@ #ifndef SERVICES_SAMGR_NATIVE_INCLUDE_SAM_LOG_H_ #define SERVICES_SAMGR_NATIVE_INCLUDE_SAM_LOG_H_ -#include "hilog/log.h" +#include "hilog_base/log_base.h" namespace OHOS { -static constexpr OHOS::HiviewDFX::HiLogLabel SYSTEM_ABLILITY_MGR_LABEL = { - LOG_CORE, - 0xD001800, - "SAMGR" -}; #ifdef HILOGF #undef HILOGF @@ -45,11 +40,13 @@ static constexpr OHOS::HiviewDFX::HiLogLabel SYSTEM_ABLILITY_MGR_LABEL = { #undef HILOGD #endif -#define HILOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(SYSTEM_ABLILITY_MGR_LABEL, __VA_ARGS__) -#define HILOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(SYSTEM_ABLILITY_MGR_LABEL, __VA_ARGS__) -#define HILOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(SYSTEM_ABLILITY_MGR_LABEL, __VA_ARGS__) -#define HILOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(SYSTEM_ABLILITY_MGR_LABEL, __VA_ARGS__) -#define HILOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(SYSTEM_ABLILITY_MGR_LABEL, __VA_ARGS__) +#define SAMGR_LOG(level, ...) HiLogBasePrint(LOG_CORE, level, 0xD001800, "SAMGR", ##__VA_ARGS__) + +#define HILOGF(...) SAMGR_LOG(LOG_FATAL, ##__VA_ARGS__) +#define HILOGE(...) SAMGR_LOG(LOG_ERROR, ##__VA_ARGS__) +#define HILOGW(...) SAMGR_LOG(LOG_WARN, ##__VA_ARGS__) +#define HILOGI(...) SAMGR_LOG(LOG_INFO, ##__VA_ARGS__) +#define HILOGD(...) SAMGR_LOG(LOG_DEBUG, ##__VA_ARGS__) } // namespace OHOS #endif // #ifndef SERVICES_SAMGR_NATIVE_INCLUDE_SAM_LOG_H_ diff --git a/services/lsamgr/include/local_ability_manager_proxy.h b/services/lsamgr/include/local_ability_manager_proxy.h index 647b7f106317986b7fec73ce0b45a7efbf12baa8..733ebc429028757071b1048e97b6d56884efed9f 100755 --- a/services/lsamgr/include/local_ability_manager_proxy.h +++ b/services/lsamgr/include/local_ability_manager_proxy.h @@ -18,7 +18,6 @@ #include #include "if_local_ability_manager.h" -#include "hilog/log.h" namespace OHOS { class LocalAbilityManagerProxy : public IRemoteProxy { @@ -30,7 +29,6 @@ public: bool StartAbility(int32_t saId); private: static inline BrokerDelegator delegator_; - OHOS::HiviewDFX::HiLogLabel label_ = { LOG_CORE, 0xD001800, "SA" }; }; } #endif // !defined(LOCAL_ABILITY_MANAGER_PROXY_H_) diff --git a/services/lsamgr/src/local_ability_manager_proxy.cpp b/services/lsamgr/src/local_ability_manager_proxy.cpp index e5be03b7c5c8f7807ea722a924047f2077efb469..f813699393242b3109d15bb779ad63d346e9f073 100755 --- a/services/lsamgr/src/local_ability_manager_proxy.cpp +++ b/services/lsamgr/src/local_ability_manager_proxy.cpp @@ -16,32 +16,35 @@ #include "local_ability_manager_proxy.h" #include "ipc_types.h" #include "parcel.h" +#include "hilog_base/log_base.h" using namespace std; -using namespace OHOS::HiviewDFX; + +#define HiLogBase(level, fmt, args...) \ + (void)HiLogBasePrint(LOG_CORE, level, 0xD001800, "SA", fmt, ##args) namespace OHOS { bool LocalAbilityManagerProxy::StartAbility(int32_t systemAbilityId) { if (systemAbilityId <= 0) { - HiLog::Warn(label_, "StartAbility systemAbilityId invalid."); + HiLogBase(LOG_WARN, "StartAbility systemAbilityId invalid."); return false; } sptr iro = Remote(); if (iro == nullptr) { - HiLog::Error(label_, "StartAbility Remote return null"); + HiLogBase(LOG_ERROR, "StartAbility Remote return null"); return false; } MessageParcel data; if (!data.WriteInterfaceToken(LOCAL_ABILITY_MANAGER_INTERFACE_TOKEN)) { - HiLog::Warn(label_, "StartAbility interface token check failed"); + HiLogBase(LOG_WARN, "StartAbility interface token check failed"); return false; } bool ret = data.WriteInt32(systemAbilityId); if (!ret) { - HiLog::Warn(label_, "StartAbility write systemAbilityId failed!"); + HiLogBase(LOG_WARN, "StartAbility write systemAbilityId failed!"); return false; } @@ -49,7 +52,7 @@ bool LocalAbilityManagerProxy::StartAbility(int32_t systemAbilityId) MessageOption option(MessageOption::TF_ASYNC); int32_t status = iro->SendRequest(START_ABILITY_TRANSACTION, data, reply, option); if (status != NO_ERROR) { - HiLog::Error(label_, "StartAbility SendRequest failed, return value : %{public}d", status); + HiLogBase(LOG_ERROR, "StartAbility SendRequest failed, return value : %{public}d", status); return false; } return true; diff --git a/services/samgr/native/BUILD.gn b/services/samgr/native/BUILD.gn index b8433036c16364e332c41da2531c5691ca29d737..04fc7e6d9aae2a71aeaa6c5265a29721941d9226 100755 --- a/services/samgr/native/BUILD.gn +++ b/services/samgr/native/BUILD.gn @@ -19,7 +19,6 @@ config("distributed_store_config") { include_dirs = [ "//foundation/distributedschedule/samgr/services/samgr/native/include", "//third_party/json/include", - "//foundation/distributedschedule/dmsfwk/services/dtbdecidefwk/include", ] } @@ -78,7 +77,7 @@ ohos_executable("samgr") { if (is_standard_system) { external_deps = [ "eventhandler:libeventhandler", - "hiviewdfx_hilog_native:libhilog", + "hiviewdfx_hilog_native:libhilog_base", "ipc:ipc_core", "ipc:libdbinder", ] diff --git a/services/samgr/native/source/service_registry.cpp b/services/samgr/native/source/service_registry.cpp index 7e8411422cd15e00ac5327a3eee7b6d3463692c0..e2634d3ec320f3df238ddc37480a707c05a484d0 100755 --- a/services/samgr/native/source/service_registry.cpp +++ b/services/samgr/native/source/service_registry.cpp @@ -21,14 +21,20 @@ #include "ipc_skeleton.h" #include "ipc_types.h" #include "parcel.h" -#include "parcel_helper.h" - #include "sam_log.h" #include "string_ex.h" #include "system_ability_manager_proxy.h" +#define PARCEL_WRITE_HELPER_RET(parcel, type, value, failRet) \ + do { \ + bool ret = parcel.Write##type((value)); \ + if (!ret) { \ + HILOGE("%{public}s write value failed!", __func__); \ + return failRet; \ + } \ + } while (0) + namespace OHOS { -using namespace OHOS::HiviewDFX; namespace { constexpr int32_t MASK = 0x100; @@ -113,8 +119,6 @@ public: return err; } -private: - static constexpr HiLogLabel LABEL = { LOG_CORE, 0xD001800, "ServiceRegistry" }; }; std::mutex ServiceRegistry::serviceRegistryLock_;