diff --git a/baselib/utils/include/utils_log.h b/baselib/utils/include/utils_log.h index 0ec4343828f266f2a510b4f3e5d05b268f177228..4cbf33a3709b855856b24e27f62f39e577772f64 100644 --- a/baselib/utils/include/utils_log.h +++ b/baselib/utils/include/utils_log.h @@ -18,7 +18,6 @@ #include "hilog/log.h" -#ifndef __cplusplus #ifdef LOG_TAG #undef LOG_TAG #endif @@ -35,19 +34,4 @@ #define SECURITY_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) #define SECURITY_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#else // __cplusplus -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD002F05, "DSLM_SERVICE"}; - -#define SECURITY_LOG_DEBUG(fmt, ...) \ - OHOS::HiviewDFX::HiLog::Debug(LABEL, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SECURITY_LOG_INFO(fmt, ...) \ - OHOS::HiviewDFX::HiLog::Info(LABEL, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SECURITY_LOG_WARN(fmt, ...) \ - OHOS::HiviewDFX::HiLog::Warn(LABEL, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SECURITY_LOG_ERROR(fmt, ...) \ - OHOS::HiviewDFX::HiLog::Error(LABEL, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define SECURITY_LOG_FATAL(fmt, ...) \ - OHOS::HiviewDFX::HiLog::Fatal(LABEL, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) - -#endif // __cplusplus #endif // SEC_UTILS_LOG_H diff --git a/interfaces/inner_api/src/standard/device_security_info.cpp b/interfaces/inner_api/src/standard/device_security_info.cpp index d2edb45a6bcb1f344c4c333dc7cb9ee0c414b806..fb43e161d150334cfd9b0d738474829ce2b88ef3 100644 --- a/interfaces/inner_api/src/standard/device_security_info.cpp +++ b/interfaces/inner_api/src/standard/device_security_info.cpp @@ -33,7 +33,7 @@ static int32_t RequestDeviceSecurityInfoAsyncImpl(const DeviceIdentify *identify const ResultCallback &callback) { if (identify == nullptr || callback == nullptr) { - HiLog::Error(LABEL, "GetDeviceSecurityInfo input error."); + HILOG_ERROR(LOG_CORE, "GetDeviceSecurityInfo input error."); return ERR_INVALID_PARA; } @@ -44,13 +44,13 @@ static int32_t RequestDeviceSecurityInfoAsyncImpl(const DeviceIdentify *identify option = &defaultOption; } if (option->timeout > MAX_KEEP_LEN) { - HiLog::Error(LABEL, "GetDeviceSecurityInfo input error, timeout too len."); + HILOG_ERROR(LOG_CORE, "GetDeviceSecurityInfo input error, timeout too len."); return ERR_INVALID_PARA; } auto object = DeviceSecurityLevelLoader::GetInstance().LoadDslmService(); auto proxy = iface_cast(object); if (proxy == nullptr) { - HiLog::Error(LABEL, "GetDeviceSecurityInfo iface_cast error."); + HILOG_ERROR(LOG_CORE, "GetDeviceSecurityInfo iface_cast error."); return ERR_IPC_REMOTE_OBJ_ERR; } auto &helper = DelayedRefSingleton::GetInstance(); @@ -59,13 +59,13 @@ static int32_t RequestDeviceSecurityInfoAsyncImpl(const DeviceIdentify *identify auto success = helper.Publish(*identify, callback, option->timeout, stub, cookie); if (!success || stub == nullptr || cookie == 0) { - HiLog::Error(LABEL, "GetDeviceSecurityInfo get stub error."); + HILOG_ERROR(LOG_CORE, "GetDeviceSecurityInfo get stub error."); return ERR_REG_CALLBACK; } auto result = proxy->RequestDeviceSecurityLevel(*identify, *option, stub->AsObject(), cookie); if (result != SUCCESS) { - HiLog::Error(LABEL, "GetDeviceSecurityInfo RequestDeviceSecurityLevel error."); + HILOG_ERROR(LOG_CORE, "GetDeviceSecurityInfo RequestDeviceSecurityLevel error."); helper.Withdraw(cookie); return result; } @@ -84,7 +84,7 @@ static int32_t RequestDeviceSecurityInfoImpl(const DeviceIdentify *identify, con }; auto result = RequestDeviceSecurityInfoAsyncImpl(identify, option, callback); if (result != SUCCESS) { - HiLog::Error(LABEL, "RequestDeviceSecurityInfoImpl RequestDeviceSecurityLevel error."); + HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityInfoImpl RequestDeviceSecurityLevel error."); return result; } *info = promise.get_future().get(); diff --git a/interfaces/inner_api/src/standard/device_security_level_callback_helper.cpp b/interfaces/inner_api/src/standard/device_security_level_callback_helper.cpp index 443f1105eed20af086ea89ce6910ea2c9ade3132..4b4538ebe404039fd2b1831880011f28754569c8 100644 --- a/interfaces/inner_api/src/standard/device_security_level_callback_helper.cpp +++ b/interfaces/inner_api/src/standard/device_security_level_callback_helper.cpp @@ -60,7 +60,7 @@ bool DeviceSecurityLevelCallbackHelper::Publish(const DeviceIdentify &identity, auto result = holder_.PushCallback(identity, callback, keep, cookie); if (!result) { - HiLog::Error(LABEL, "DeviceSecurityLevelCallbackHelper::PushCallback failed"); + HILOG_ERROR(LOG_CORE, "DeviceSecurityLevelCallbackHelper::PushCallback failed"); return false; } @@ -76,7 +76,7 @@ bool DeviceSecurityLevelCallbackHelper::Withdraw(uint32_t cookie) auto result = holder_.PopCallback(cookie); if (!result) { - HiLog::Error(LABEL, "DeviceSecurityLevelCallbackHelper::withdraw failed"); + HILOG_ERROR(LOG_CORE, "DeviceSecurityLevelCallbackHelper::withdraw failed"); return false; } return true; @@ -89,7 +89,7 @@ int32_t DeviceSecurityLevelCallbackHelper::OnRemoteRequest(uint32_t code, Messag auto cookie = data.ReadUint32(); auto result = data.ReadUint32(); auto level = data.ReadUint32(); - HiLog::Info(LABEL, "callback cookie %{public}u, result %{public}u, level %{public}u", cookie, result, level); + HILOG_INFO(LOG_CORE, "callback cookie %{public}u, result %{public}u, level %{public}u", cookie, result, level); holder_.PopCallback(cookie, result, level); } @@ -111,7 +111,7 @@ bool DeviceSecurityLevelCallbackHelper::CallbackInfoHolder::PushCallback(const D { std::lock_guard lock(mutex_); if (map_.size() > MAX_CALLBACKS_NUM) { - HiLog::Error(LABEL, "DeviceSecurityLevelCallbackHelper::PushCallback reached max"); + HILOG_ERROR(LOG_CORE, "DeviceSecurityLevelCallbackHelper::PushCallback reached max"); return false; } diff --git a/interfaces/inner_api/src/standard/device_security_level_callback_stub.cpp b/interfaces/inner_api/src/standard/device_security_level_callback_stub.cpp index b1d3b506d253ddb07c1a858a686791017811e2d7..d3b35af4efa9078139df017526c2c71daeb6b5b7 100644 --- a/interfaces/inner_api/src/standard/device_security_level_callback_stub.cpp +++ b/interfaces/inner_api/src/standard/device_security_level_callback_stub.cpp @@ -37,7 +37,7 @@ int32_t DeviceSecurityLevelCallbackStub::OnRemoteRequest(uint32_t code, MessageP MessageOption &option) { if (DeviceSecurityLevelCallbackStub::GetDescriptor() != data.ReadInterfaceToken()) { - HiLog::Error(LABEL, "descriptor not match"); + HILOG_ERROR(LOG_CORE, "descriptor not match"); return SUCCESS; } diff --git a/interfaces/inner_api/src/standard/device_security_level_loader.cpp b/interfaces/inner_api/src/standard/device_security_level_loader.cpp index 1cf59ddc2f2c6f5b66f8af96b3da3709c864b798..c2180fba1d7c8cc2dcebbdd23df647a8eee23a43 100644 --- a/interfaces/inner_api/src/standard/device_security_level_loader.cpp +++ b/interfaces/inner_api/src/standard/device_security_level_loader.cpp @@ -35,7 +35,7 @@ sptr DeviceSecurityLevelLoader::LoadDslmService() { auto registry = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (registry == nullptr) { - HiLog::Error(LABEL, "GetDeviceSecurityInfo get registry error."); + HILOG_ERROR(LOG_CORE, "GetDeviceSecurityInfo get registry error."); return {}; } auto object = registry->CheckSystemAbility(DEVICE_SECURITY_LEVEL_MANAGER_SA_ID); @@ -46,7 +46,7 @@ sptr DeviceSecurityLevelLoader::LoadDslmService() sptr callback = new (std::nothrow) LoadCallback(); int32_t result = registry->LoadSystemAbility(DEVICE_SECURITY_LEVEL_MANAGER_SA_ID, callback); if (result != ERR_OK) { - HiLog::Error(LABEL, "GetDeviceSecurityInfo LoadSystemAbility error."); + HILOG_ERROR(LOG_CORE, "GetDeviceSecurityInfo LoadSystemAbility error."); return {}; } return callback->Promise(); @@ -54,13 +54,13 @@ sptr DeviceSecurityLevelLoader::LoadDslmService() void DeviceSecurityLevelLoader::LoadCallback::OnLoadSystemAbilitySuccess(int32_t sid, const sptr &object) { - HiLog::Info(LABEL, "OnLoadSystemAbilitySuccess = %{public}d.", sid); + HILOG_INFO(LOG_CORE, "OnLoadSystemAbilitySuccess = %{public}d.", sid); promise_.set_value(object); } void DeviceSecurityLevelLoader::LoadCallback::OnLoadSystemAbilityFail(int32_t sid) { - HiLog::Error(LABEL, "OnLoadSystemAbilityFail = %{public}d.", sid); + HILOG_ERROR(LOG_CORE, "OnLoadSystemAbilityFail = %{public}d.", sid); } sptr DeviceSecurityLevelLoader::LoadCallback::Promise() diff --git a/interfaces/inner_api/src/standard/device_security_level_proxy.cpp b/interfaces/inner_api/src/standard/device_security_level_proxy.cpp index d4465399111679be30a039dbb70206b227a9cdf5..05610f20f6704c8bb0640805faa34dd3e8100043 100644 --- a/interfaces/inner_api/src/standard/device_security_level_proxy.cpp +++ b/interfaces/inner_api/src/standard/device_security_level_proxy.cpp @@ -49,12 +49,12 @@ int32_t DeviceSecurityLevelProxy::RequestDeviceSecurityLevel(const DeviceIdentif auto length = identify.length; if (length == 0 || length > DEVICE_ID_MAX_LEN) { - HiLog::Error(LABEL, "RequestDeviceSecurityLevel invalid para len."); + HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityLevel invalid para len."); return ERR_INVALID_LEN_PARA; } if (!data.WriteInterfaceToken(GetDescriptor())) { - HiLog::Error(LABEL, "RequestDeviceSecurityLevel write descriptor failed"); + HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityLevel write descriptor failed"); return ERR_INVALID_PARA; } @@ -74,18 +74,18 @@ int32_t DeviceSecurityLevelProxy::RequestDeviceSecurityLevel(const DeviceIdentif MessageOption ipcOption = {MessageOption::TF_SYNC}; auto result = Remote()->SendRequest(CMD_GET_DEVICE_SECURITY_LEVEL, data, reply, ipcOption); if (result != ERR_NONE) { - HiLog::Error(LABEL, "RequestDeviceSecurityLevelSendRequest send failed, ret is %{public}d", result); + HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityLevelSendRequest send failed, ret is %{public}d", result); return result; } if (reply.GetReadableBytes() < sizeof(uint32_t)) { - HiLog::Error(LABEL, "RequestDeviceSecurityLevelSendRequest result length error"); + HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityLevelSendRequest result length error"); return ERR_IPC_RET_PARCEL_ERR; } auto status = reply.ReadUint32(); if (status != cookie) { - HiLog::Error(LABEL, "RequestDeviceSecurityLevelSendRequest result value error, ret is %{public}u", status); + HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityLevelSendRequest result value error, ret is %{public}u", status); return ERR_IPC_REMOTE_OBJ_ERR; }