日志整改

Signed-off-by: torrizo <lishenhao2@huawei.com>
This commit is contained in:
torrizo 2024-08-12 08:14:09 +00:00
parent f1f3809438
commit 3d47f11f63
5 changed files with 41 additions and 32 deletions

View File

@ -46,17 +46,19 @@ std::string ProfileUtils::GetDbKeyAnonyString(const std::string& dbKey)
splitKeys.size() <= DEVICE_ID_INDEX) { splitKeys.size() <= DEVICE_ID_INDEX) {
return GetAnonyString(dbKey); return GetAnonyString(dbKey);
} }
splitKeys[DEVICE_ID_INDEX] = GetAnonyString(splitKeys[DEVICE_ID_INDEX]); for (size_t i = DEVICE_ID_INDEX; i < splitKeys.size(); i++) {
splitKeys[i] = GetAnonyString(splitKeys[i]);
}
return JoinString(splitKeys, SEPARATOR); return JoinString(splitKeys, SEPARATOR);
} }
std::string ProfileUtils::GetAnonyString(const std::string& value) std::string ProfileUtils::GetAnonyString(const std::string& value)
{ {
constexpr size_t INT32_SHORT_ID_LENGTH = 20; constexpr size_t INT32_SHORT_ID_LENGTH = 10;
constexpr size_t INT32_PLAINTEXT_LENGTH = 4; constexpr size_t INT32_PLAINTEXT_LENGTH = 4;
constexpr size_t INT32_MIN_ID_LENGTH = 3; constexpr size_t INT32_MIN_ID_LENGTH = 3;
std::string res; std::string res;
std::string tmpStr("******"); std::string tmpStr("***");
size_t strLen = value.length(); size_t strLen = value.length();
if (strLen < INT32_MIN_ID_LENGTH) { if (strLen < INT32_MIN_ID_LENGTH) {
return tmpStr; return tmpStr;

View File

@ -453,7 +453,7 @@ void DistributedDeviceProfileClient::StartThreadSendSubscribeInfos()
void DistributedDeviceProfileClient::ReSubscribeDeviceProfileInited() void DistributedDeviceProfileClient::ReSubscribeDeviceProfileInited()
{ {
if (dpInitedCallback_ == nullptr) { if (dpInitedCallback_ == nullptr) {
HILOGD("not use Retry subscribe dp inited"); HILOGE("not use Retry subscribe dp inited");
return; return;
} }
auto autoTask = [this] () { auto autoTask = [this] () {
@ -508,7 +508,7 @@ int32_t DistributedDeviceProfileClient::UnSubscribeDeviceProfileInited(int32_t s
{ {
HILOGI("enter"); HILOGI("enter");
if (dpInitedCallback_ == nullptr) { if (dpInitedCallback_ == nullptr) {
HILOGD("not subscribe dp inited, no need unsubscribe dp inited"); HILOGE("not subscribe dp inited, no need unsubscribe dp inited");
return DP_SUCCESS; return DP_SUCCESS;
} }
SubscribeDeviceProfileSA(); SubscribeDeviceProfileSA();

View File

@ -59,7 +59,7 @@ void DpRadarHelper::ReportCheckDpSa(int32_t stageRes)
"ERROR_CODE", DP_LOAD_SERVICE_ERR); "ERROR_CODE", DP_LOAD_SERVICE_ERR);
} }
if (res != ERR_OK) { if (res != ERR_OK) {
HILOGE("ReportCheckDpSa fail"); HILOGE("failed");
} }
return; return;
} }
@ -93,7 +93,7 @@ void DpRadarHelper::ReportLoadDpSa(int32_t stageRes)
"ERROR_CODE", DP_LOAD_SERVICE_ERR); "ERROR_CODE", DP_LOAD_SERVICE_ERR);
} }
if (res != ERR_OK) { if (res != ERR_OK) {
HILOGE("ReportLoadDpSa failed"); HILOGE("failed");
} }
return; return;
} }
@ -127,7 +127,7 @@ void DpRadarHelper::ReportLoadDpSaCb(int32_t stageRes)
"ERROR_CODE", DP_LOAD_SERVICE_ERR); "ERROR_CODE", DP_LOAD_SERVICE_ERR);
} }
if (res != ERR_OK) { if (res != ERR_OK) {
HILOGE("ReportLoadDpSaCb failed"); HILOGE("failed");
} }
return; return;
} }
@ -160,7 +160,7 @@ void DpRadarHelper::ReportSaCheckAuth(int32_t stageRes)
"ERROR_CODE", ERR_PERMISSION_DENIED); "ERROR_CODE", ERR_PERMISSION_DENIED);
} }
if (res != ERR_OK) { if (res != ERR_OK) {
HILOGE("ReportSaCheckAuth failed"); HILOGE("failed");
} }
return; return;
} }
@ -203,7 +203,7 @@ void DpRadarHelper::ReportPutAclProfile(int32_t errCode, const AccessControlProf
"EXTRA_INFO", accessControlProfile.dump()); "EXTRA_INFO", accessControlProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportPutAclProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -246,7 +246,7 @@ void DpRadarHelper::ReportUpdateAclProfile(int32_t errCode, const AccessControlP
"EXTRA_INFO", accessControlProfile.dump()); "EXTRA_INFO", accessControlProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportUpdateAclProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -290,7 +290,7 @@ void DpRadarHelper::ReportGetTrustProfile(int32_t errCode, const std::string& de
"EXTRA_INFO", trustDeviceProfile.dump()); "EXTRA_INFO", trustDeviceProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportGetTrustProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -341,7 +341,7 @@ void DpRadarHelper::ReportGetAllTrustProfile(int32_t errCode, std::vector<TrustD
"EXTRA_INFO", extraInfo); "EXTRA_INFO", extraInfo);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportGetAllTrustProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -392,7 +392,7 @@ void DpRadarHelper::ReportGetAclProfile(int32_t errCode, std::vector<AccessContr
"EXTRA_INFO", extraInfo); "EXTRA_INFO", extraInfo);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportGetAclProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -443,7 +443,7 @@ void DpRadarHelper::ReportGetAllAclProfile(int32_t errCode, std::vector<AccessCo
"EXTRA_INFO", extraInfo); "EXTRA_INFO", extraInfo);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportGetAllAclProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -482,7 +482,7 @@ void DpRadarHelper::ReportDeleteAclProfile(int32_t errCode)
"ERROR_CODE", errCode); "ERROR_CODE", errCode);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportDeleteAclProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -525,7 +525,7 @@ void DpRadarHelper::ReportPutServiceProfile(int32_t errCode, const ServiceProfil
"EXTRA_INFO", serviceProfile.dump()); "EXTRA_INFO", serviceProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportPutServiceProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -576,7 +576,7 @@ void DpRadarHelper::ReportPutServiceProfileBatch(int32_t errCode, const std::vec
"EXTRA_INFO", extraInfo); "EXTRA_INFO", extraInfo);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportPutServiceProfileBatch failed"); HILOGE("failed");
} }
return; return;
} }
@ -619,7 +619,7 @@ void DpRadarHelper::ReportPutCharProfile(int32_t errCode, const CharacteristicPr
"EXTRA_INFO", characteristicProfile.dump()); "EXTRA_INFO", characteristicProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportPutCharProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -671,7 +671,7 @@ void DpRadarHelper::ReportPutCharProfileBatch(int32_t errCode,
"EXTRA_INFO", extraInfo); "EXTRA_INFO", extraInfo);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportPutCharProfileBatch failed"); HILOGE("failed");
} }
return; return;
} }
@ -714,7 +714,7 @@ void DpRadarHelper::ReportGetDeviceProfile(int32_t errCode, const std::string& d
"EXTRA_INFO", deviceProfile.dump()); "EXTRA_INFO", deviceProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportGetDeviceProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -758,7 +758,7 @@ void DpRadarHelper::ReportGetServiceProfile(int32_t errCode,
"EXTRA_INFO", serviceProfile.dump()); "EXTRA_INFO", serviceProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportGetServiceProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -802,7 +802,7 @@ void DpRadarHelper::ReportGetCharProfile(int32_t errCode,
"EXTRA_INFO", characteristicProfile.dump()); "EXTRA_INFO", characteristicProfile.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportGetCharProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -843,7 +843,7 @@ void DpRadarHelper::ReportDeleteServiceProfile(int32_t errCode, const std::strin
"ERROR_CODE", errCode); "ERROR_CODE", errCode);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportDeleteServiceProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -884,7 +884,7 @@ void DpRadarHelper::ReportDeleteCharProfile(int32_t errCode, const std::string&
"ERROR_CODE", errCode); "ERROR_CODE", errCode);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportDeleteCharProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -925,7 +925,7 @@ void DpRadarHelper::ReportSubscribeDeviceProfile(int32_t errCode, const Subscrib
"EXTRA_INFO", subscribeInfo.dump()); "EXTRA_INFO", subscribeInfo.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportSubscribeDeviceProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -966,7 +966,7 @@ void DpRadarHelper::ReportUnSubscribeDeviceProfile(int32_t errCode, const Subscr
"EXTRA_INFO", subscribeInfo.dump()); "EXTRA_INFO", subscribeInfo.dump());
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportUnSubscribeDeviceProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -1007,7 +1007,7 @@ void DpRadarHelper::ReportSyncDeviceProfile(int32_t errCode)
"ERROR_CODE", errCode); "ERROR_CODE", errCode);
} }
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportSyncDeviceProfile failed"); HILOGE("failed");
} }
return; return;
} }
@ -1058,7 +1058,7 @@ void DpRadarHelper::ReportNotifyProfileChange(int32_t code)
"LOCAL_UDID", GetLocalUdid(), "LOCAL_UDID", GetLocalUdid(),
"TO_CALL_PKG", RDB_NAME); "TO_CALL_PKG", RDB_NAME);
if (res != DP_SUCCESS) { if (res != DP_SUCCESS) {
HILOGE("ReportNotifyProfileChange failed"); HILOGE("failed");
} }
return; return;
} }

View File

@ -35,6 +35,7 @@ namespace OHOS {
namespace DistributedDeviceProfile { namespace DistributedDeviceProfile {
namespace { namespace {
const std::string TAG = "KvDataChangeListener"; const std::string TAG = "KvDataChangeListener";
const std::string STATIC_STORE_ID = "dp_kv_static_store";
} }
KvDataChangeListener::KvDataChangeListener(const std::string& storeId) KvDataChangeListener::KvDataChangeListener(const std::string& storeId)
@ -50,7 +51,10 @@ KvDataChangeListener::~KvDataChangeListener()
void KvDataChangeListener::OnChange(const DistributedKv::ChangeNotification& changeNotification) void KvDataChangeListener::OnChange(const DistributedKv::ChangeNotification& changeNotification)
{ {
HILOGI("DB data OnChange"); HILOGI("storeId=%{public}s", storeId_.c_str());
if (storeId_ == STATIC_STORE_ID) {
return;
}
if (!changeNotification.GetInsertEntries().empty() && if (!changeNotification.GetInsertEntries().empty() &&
changeNotification.GetInsertEntries().size() <= MAX_DB_RECORD_SIZE) { changeNotification.GetInsertEntries().size() <= MAX_DB_RECORD_SIZE) {
HandleAddChange(changeNotification.GetInsertEntries()); HandleAddChange(changeNotification.GetInsertEntries());
@ -67,7 +71,10 @@ void KvDataChangeListener::OnChange(const DistributedKv::ChangeNotification& cha
void KvDataChangeListener::OnChange(const DistributedKv::DataOrigin& origin, Keys&& keys) void KvDataChangeListener::OnChange(const DistributedKv::DataOrigin& origin, Keys&& keys)
{ {
HILOGD("DB data OnChange"); HILOGI("Cloud data Change. store=%{public}s", origin.store.c_str());
if (origin.store == STATIC_STORE_ID) {
return;
}
std::vector<DistributedKv::Entry> insertRecords = DeviceProfileManager::GetInstance() std::vector<DistributedKv::Entry> insertRecords = DeviceProfileManager::GetInstance()
.GetEntriesByKeys(keys[ChangeOp::OP_INSERT]); .GetEntriesByKeys(keys[ChangeOp::OP_INSERT]);
if (!insertRecords.empty() && insertRecords.size() <= MAX_DB_RECORD_SIZE) { if (!insertRecords.empty() && insertRecords.size() <= MAX_DB_RECORD_SIZE) {

View File

@ -451,7 +451,7 @@ std::unordered_set<SubscribeInfo, SubscribeHash, SubscribeCompare> SubscribeProf
{ {
std::lock_guard<std::mutex> lock(subscribeMutex_); std::lock_guard<std::mutex> lock(subscribeMutex_);
if (subscribeInfoMap_.find(dbKey) == subscribeInfoMap_.end()) { if (subscribeInfoMap_.find(dbKey) == subscribeInfoMap_.end()) {
HILOGE("This dbKey is not subscribed, dbKey: %{public}s", ProfileUtils::GetDbKeyAnonyString(dbKey).c_str()); HILOGD("This dbKey is not subscribed, dbKey: %{public}s", ProfileUtils::GetDbKeyAnonyString(dbKey).c_str());
return {}; return {};
} }
return subscribeInfoMap_[dbKey]; return subscribeInfoMap_[dbKey];