From 41724da4a278db871d97e41d669c377d961088d6 Mon Sep 17 00:00:00 2001 From: wangzhaohao Date: Tue, 12 Aug 2025 11:44:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzhaohao --- common/BUILD.gn | 1 - .../distributed_device_profile_constants.h | 2 -- .../utils/distributed_device_profile_log.h | 16 +++------- common/include/utils/log_utils.h | 29 ----------------- common/src/utils/log_utils.cpp | 31 ------------------- .../core/test/unittest/profile_utils_test.cpp | 18 ----------- 6 files changed, 5 insertions(+), 92 deletions(-) delete mode 100644 common/include/utils/log_utils.h delete mode 100644 common/src/utils/log_utils.cpp diff --git a/common/BUILD.gn b/common/BUILD.gn index 89295ccf..03c9c474 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -131,7 +131,6 @@ ohos_shared_library("distributed_device_profile_common") { "src/interfaces/trusted_device_info.cpp", "src/utils/content_sensor_manager_utils.cpp", "src/utils/ipc_utils.cpp", - "src/utils/log_utils.cpp", "src/utils/profile_utils.cpp", ] diff --git a/common/include/constants/distributed_device_profile_constants.h b/common/include/constants/distributed_device_profile_constants.h index c435bab7..8d067f8c 100644 --- a/common/include/constants/distributed_device_profile_constants.h +++ b/common/include/constants/distributed_device_profile_constants.h @@ -246,8 +246,6 @@ constexpr int32_t MIN_USER_ID = 0; constexpr int32_t MAX_USER_ID = 100000; constexpr uint32_t MAX_TRUSTED_DEVICE_SIZE = 1000; constexpr int32_t MAX_SESSIONKEY_SIZE = 8*1024; -constexpr int32_t COUNTER_INIT = 0; -constexpr int32_t COUNTER_MAX = 999999; constexpr int32_t US_100000 = 100000; constexpr int32_t US_200000 = 200000; constexpr int32_t US_300000 = 300000; diff --git a/common/include/utils/distributed_device_profile_log.h b/common/include/utils/distributed_device_profile_log.h index d84e6786..7a6a63ec 100644 --- a/common/include/utils/distributed_device_profile_log.h +++ b/common/include/utils/distributed_device_profile_log.h @@ -22,7 +22,6 @@ #define LOG_DOMAIN 0xD004400 #endif #include "hilog/log.h" -#include "log_utils.h" namespace OHOS { namespace DistributedDeviceProfile { @@ -43,16 +42,11 @@ namespace DistributedDeviceProfile { #undef HILOGD #endif -#define HILOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}d] %{public}s::%{public}s " fmt, LogUtils::LogCounter(), \ - TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) -#define HILOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}d] %{public}s::%{public}s " fmt, LogUtils::LogCounter(), \ - TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) -#define HILOGW(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}d] %{public}s::%{public}s " fmt, LogUtils::LogCounter(), \ - TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) -#define HILOGI(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}d] %{public}s::%{public}s " fmt, LogUtils::LogCounter(), \ - TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) -#define HILOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}d] %{public}s::%{public}s " fmt, LogUtils::LogCounter(), \ - TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) +#define HILOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) +#define HILOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) +#define HILOGW(fmt, ...) HILOG_WARN(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) +#define HILOGI(fmt, ...) HILOG_INFO(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) +#define HILOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "%{public}s::%{public}s " fmt, TAG.c_str(), __FUNCTION__, ##__VA_ARGS__) } // namespace DistributedDeviceProfile } // namespace OHOS #endif // OHOS_DP_DEVICE_PROFILE_LOG_H diff --git a/common/include/utils/log_utils.h b/common/include/utils/log_utils.h deleted file mode 100644 index 634fbbcf..00000000 --- a/common/include/utils/log_utils.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_DP_LOG_UTILS_H -#define OHOS_DP_LOG_UTILS_H - -#include - -namespace OHOS { -namespace DistributedDeviceProfile { -class LogUtils { -public: - static int32_t LogCounter(); -}; -} // namespace DistributedDeviceProfile -} // namespace OHOS -#endif // OHOS_DP_LOG_UTILS_H diff --git a/common/src/utils/log_utils.cpp b/common/src/utils/log_utils.cpp deleted file mode 100644 index 011dc60f..00000000 --- a/common/src/utils/log_utils.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "distributed_device_profile_constants.h" -#include "log_utils.h" - -namespace OHOS { -namespace DistributedDeviceProfile { - -int32_t LogUtils::LogCounter() -{ - static int32_t counter = COUNTER_INIT; - int32_t result = counter; - counter = (counter + 1) % (COUNTER_MAX + 1); - return result; -} - -} // namespace DistributedDeviceProfile -} // namespace OHOS diff --git a/services/core/test/unittest/profile_utils_test.cpp b/services/core/test/unittest/profile_utils_test.cpp index 182fd79d..9f7a9d08 100644 --- a/services/core/test/unittest/profile_utils_test.cpp +++ b/services/core/test/unittest/profile_utils_test.cpp @@ -20,7 +20,6 @@ #include "gtest/gtest.h" #include "refbase.h" #include "rdb_errno.h" -#include "log_utils.h" #include "profile_utils.h" #include "distributed_device_profile_constants.h" #include "distributed_device_profile_errors.h" @@ -1639,22 +1638,5 @@ HWTEST_F(ProfileUtilsTest, IsNumStr001, TestSize.Level1) bool isNumStr = ProfileUtils::IsNumStr(""); EXPECT_EQ(isNumStr, false); } - -/** - * @tc.name: LogCounter001 - * @tc.desc: - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(ProfileUtilsTest, LogCounter001, TestSize.Level1) -{ - int32_t counter = LogUtils::LogCounter(); - EXPECT_GE(counter, COUNTER_INIT); - for (int32_t i = 0; i < COUNTER_MAX; i++) { - LogUtils::LogCounter(); - } - counter = LogUtils::LogCounter(); - EXPECT_LE(counter, COUNTER_MAX); -} } // namespace DistributedDeviceProfile } // namespace OHOS -- Gitee