diff --git a/client/update_client.h b/client/update_client.h index 8c7b29392ee3ac2b3b486917c211d7e27eaee764..05ec74a8a8f8669ebfe710e92210f3d33844bb1f 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 d8a69ac463036b3112cd873ddbf4feedfd87f242..a2a81316687916eb252c4f02396d9002f6294b39 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 bbf474712ba4d47c27d80f49534d7ec4207f99d8..cda0e8eab0dd29aaea7bc7b0c005ee4b35ca817a 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; @@ -194,29 +192,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 e125e6ab807c5e76b731d3165ee99fe1752d767b..83e4ccb2b13e4b6243835e53c78888b613a0831e 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__)