From 000fd59a10a4fc36cd78cf925d16ceb67a7e97d3 Mon Sep 17 00:00:00 2001 From: worldants Date: Wed, 23 Mar 2022 14:22:39 +0800 Subject: [PATCH 1/2] Signed-off-by: worldants --- client/update_client.h | 2 -- engine/src/progress_thread.cpp | 4 ++-- engine/src/update_helper.cpp | 23 -------------------- interfaces/innerkits/include/update_helper.h | 3 --- 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/client/update_client.h b/client/update_client.h index 8c7b2939..05ec74a8 100644 --- a/client/update_client.h +++ b/client/update_client.h @@ -33,12 +33,10 @@ static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_CLIENT = {LOG_CORE, 0, "UPDATE_CLIENT"}; #define CLIENT_LOGE(format, ...) \ - OHOS::update_engine::UpdateHelper::Logger(__FILE__, (__LINE__), format, ##__VA_ARGS__); \ OHOS::HiviewDFX::HiLog::Error(UPDATE_CLIENT, "[%{public}s(%{public}d)] " format, \ OHOS::update_engine::UpdateHelper::GetBriefFileName(std::string(__FILE__)).c_str(), __LINE__, ##__VA_ARGS__) #define CLIENT_LOGI(format, ...) \ - OHOS::update_engine::UpdateHelper::Logger(__FILE__, (__LINE__), format, ##__VA_ARGS__); \ OHOS::HiviewDFX::HiLog::Info(UPDATE_CLIENT, "[%{public}s(%{public}d)] " format, \ OHOS::update_engine::UpdateHelper::GetBriefFileName(std::string(__FILE__)).c_str(), __LINE__, ##__VA_ARGS__) diff --git a/engine/src/progress_thread.cpp b/engine/src/progress_thread.cpp index d8a69ac4..a2a81316 100755 --- a/engine/src/progress_thread.cpp +++ b/engine/src/progress_thread.cpp @@ -127,13 +127,13 @@ bool DownloadThread::ProcessThreadExecute() CURLcode res = curl_easy_perform(downloadHandle_); if (res != CURLE_OK) { ProcessThreadExit(); - ENGINE_LOGI("Failed to download %s res %s", serverUrl_.c_str(), curl_easy_strerror(res)); + ENGINE_LOGI("Failed to download res %s", curl_easy_strerror(res)); if (res != CURLE_ABORTED_BY_CALLBACK) { // cancel by user, do not callback DownloadCallback(0, UPDATE_STATE_DOWNLOAD_FAIL, curl_easy_strerror(res)); } } else { ProcessThreadExit(); - ENGINE_LOGI("Success to download %s", serverUrl_.c_str()); + ENGINE_LOGI("Success to download"); DownloadCallback(DOWNLOAD_FINISH_PERCENT, UPDATE_STATE_DOWNLOAD_SUCCESS, ""); } // clear up diff --git a/engine/src/update_helper.cpp b/engine/src/update_helper.cpp index bbf47471..8d68a7fc 100755 --- a/engine/src/update_helper.cpp +++ b/engine/src/update_helper.cpp @@ -194,29 +194,6 @@ int32_t UpdateHelper::CopyUpdatePolicy(const UpdatePolicy &srcInfo, UpdatePolicy return 0; } -void UpdateHelper::Logger(const std::string &fileName, int32_t line, const char *format, ...) -{ - std::string name = UpdateHelper::GetBriefFileName(fileName); - std::ofstream logStream(LOG_NAME, std::ios::app | std::ios::out); - static std::vector buff(VECTOR_MAX_BUF_SIZE); - va_list list; - va_start(list, format); - int size = vsnprintf_s(reinterpret_cast(buff.data()), buff.capacity(), buff.capacity() - 1, format, list); - ENGINE_CHECK(size != -1, return, ""); - va_end(list); - std::string str(buff.data(), size); - char realTime[MAX_TIME_SIZE] = {0}; - auto sysTime = std::chrono::system_clock::now(); - auto currentTime = std::chrono::system_clock::to_time_t(sysTime); - struct tm *localTime = std::localtime(¤tTime); - if (localTime != nullptr) { - std::strftime(realTime, sizeof(realTime), "%Y-%m-%d %H:%M:%S", localTime); - } - logStream << realTime << "[" << LOG_LABEL << "]" << name << " " << line << " : " << str << std::endl; - std::cout << realTime << "[" << LOG_LABEL << "]" << name << " " << line << " : " << str << std::endl; - logStream.close(); -} - bool UpdateHelper::JudgeLevel(const UpdateLogLevel& level) { const UpdateLogLevel& curLevel = UpdateHelper::GetLogLevel(); diff --git a/interfaces/innerkits/include/update_helper.h b/interfaces/innerkits/include/update_helper.h index e125e6ab..83e4ccb2 100755 --- a/interfaces/innerkits/include/update_helper.h +++ b/interfaces/innerkits/include/update_helper.h @@ -178,8 +178,6 @@ public: static int32_t CompareVersion(const std::string &version1, const std::string &version2); static std::vector SplitString(const std::string &str, const std::string &delimiter); - static void Logger(const std::string &fileName, int32_t line, const char *format, ...); - static bool JudgeLevel(const UpdateLogLevel& level); static void SetLogLevel(const UpdateLogLevel& level) @@ -200,7 +198,6 @@ private: // 暂时记录两边日志 #define PRINT_LOG(LEVEL, Level, fmt, ...) \ - UpdateHelper::Logger(__FILE__, (__LINE__), fmt, ##__VA_ARGS__); \ if (UpdateHelper::JudgeLevel(UpdateLogLevel::LEVEL)) \ OHOS::HiviewDFX::HiLog::Level(UPDATE_LABEL, "[%{public}s(%{public}d)] " fmt, \ UpdateHelper::GetBriefFileName(std::string(__FILE__)).c_str(), __LINE__, ##__VA_ARGS__) -- Gitee From 3e9938277d57efd1a56dc82bc77d56f727fdba5d Mon Sep 17 00:00:00 2001 From: worldants Date: Wed, 23 Mar 2022 14:47:19 +0800 Subject: [PATCH 2/2] Signed-off-by: worldants --- engine/src/update_helper.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/engine/src/update_helper.cpp b/engine/src/update_helper.cpp index 8d68a7fc..cda0e8ea 100755 --- a/engine/src/update_helper.cpp +++ b/engine/src/update_helper.cpp @@ -34,8 +34,6 @@ const std::string LOG_NAME = "/data/update_service_log.txt"; const std::string LOG_LABEL = "update_engine"; const std::string LOG_NAME = "/data/update_client.log.txt"; #endif -constexpr int VECTOR_MAX_BUF_SIZE = 1024; -constexpr int MAX_TIME_SIZE = 20; constexpr int HEX_DIGEST_NUM = 2; constexpr int HEX_DIGEST_BASE = 16; -- Gitee