From 171c634f0c4ec5abdd69867f1eb597d3dbc9e974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 20 Mar 2024 14:45:08 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9hilog=E5=AE=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20Signed-off-by:=20=E9=82=B9=E5=8F=8B=E6=9D=BE=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- foundations/ability/log/include/update_log.h | 75 ++++++++++++------- foundations/ability/log/log.gni | 5 +- foundations/ability/log/src/update_log.cpp | 32 ++++---- .../inner_api/modulemgr/include/module_log.h | 15 ++-- interfaces/inner_api/modulemgr/modulemgr.gni | 6 +- .../firmware/utils/include/firmware_log.h | 17 +++-- 6 files changed, 90 insertions(+), 60 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index ebbc6ce0..43ebe40e 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -29,6 +29,25 @@ static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_LABEL = {LOG_CORE, 0xD002E00 static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_LABEL = {LOG_CORE, 0xD002E00, "UPDATE_KITS"}; #endif +struct LogLabel { + uint32_t domainId; + const char *tag; +}; + +static const LogLabel HiLogTagArr[] = { + {0xD002E00, "UPDATE_SA"}, + {0xD002E00, "UPDATE_KITS"}, + {0xD002E00, "UPDATE_FIRMWARE"}, + {0xD002E00, "UPDATER_MODULE_MGR"} +}; + +enum class HiLogTagIndex { + UPDATE_SA_TAG = 0, + UPDATE_KITS_TAG, + UPDATE_FIRMWARE_TAG, + UPDATER_MODULE_MGR_TAG +}; + enum class UpdateLogLevel { UPDATE_DEBUG = 0, UPDATE_INFO, @@ -62,11 +81,11 @@ public: static void SetLogLevel(const UpdateLogLevel &level); static const UpdateLogLevel &GetLogLevel(); static std::string GetBriefFileName(const std::string &file); - static void PrintLongLog(const UpdateLogContent &logContent); + static void PrintLongLog(const uint32_t index, const UpdateLogContent &logContent); private: - static void PrintLog(const UpdateLogContent &logContent); - static void PrintSingleLine(const UpdateLogContent &logContent); + static void PrintLog(const uint32_t index, const UpdateLogContent &logContent); + static void PrintSingleLine(const uint32_t index, const UpdateLogContent &logContent); static std::pair SplitLogByFmtLabel(const std::string &log, const std::string &fmtLabel); static std::string GetFmtLabel(const std::string &log); static int32_t FindSubStrCount(const std::string &str, const std::string &subStr); @@ -75,33 +94,39 @@ private: static UpdateLogLevel level_; }; +#define FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) +#define FORMAT_LOG(fmt) "%{public}s:%{public}d %{public}s" fmt, FILENAME, __LINE__, __FUNCTION__ +#define ENUM_UINT(enumClass) (static_cast(enumClass)) // 暂时记录两边日志 -#define BASE_PRINT_LOG(label, level, hilogMethod, fileName, line, fmt, ...) \ - if (UpdateLog::JudgeLevel((level))) \ - OHOS::HiviewDFX::HiLog::hilogMethod((label), ("[%{public}s(%{public}d)] " + \ - std::string(fmt)).c_str(), fileName, line, ##__VA_ARGS__) - -#define PRINT_LOG(label, level, hilogMethod, fmt, ...) BASE_PRINT_LOG(label, level, \ - hilogMethod, UpdateLog::GetBriefFileName(std::string(__FILE__)).c_str(), __LINE__, fmt, ##__VA_ARGS__) - -#define PRINT_LOGD(label, fmt, ...) PRINT_LOG(label, UpdateLogLevel::UPDATE_DEBUG, Debug, fmt, ##__VA_ARGS__) -#define PRINT_LOGI(label, fmt, ...) PRINT_LOG(label, UpdateLogLevel::UPDATE_INFO, Info, fmt, ##__VA_ARGS__) -#define PRINT_LOGE(label, fmt, ...) PRINT_LOG(label, UpdateLogLevel::UPDATE_ERROR, Error, fmt, ##__VA_ARGS__) - -#define ENGINE_LOGD(fmt, ...) PRINT_LOGD(UPDATE_LABEL, fmt, ##__VA_ARGS__) -#define ENGINE_LOGI(fmt, ...) PRINT_LOGI(UPDATE_LABEL, fmt, ##__VA_ARGS__) -#define ENGINE_LOGE(fmt, ...) PRINT_LOGE(UPDATE_LABEL, fmt, ##__VA_ARGS__) - -#define PRINT_LONG_LOGD(label, fmt, args) UpdateLog::PrintLongLog({label, \ +#define BASE_PRINT_LOG(index, label, level, hilogMethod, fmt, ...) \ + if (OHOS::UpdateEngine::UpdateLog::JudgeLevel((level))) \ + HILOG_IMPL(LOG_CORE, hilogMethod, OHOS::UpdateEngine::HiLogTagArr[index].domainId, \ + OHOS::UpdateEngine::HiLogTagArr[index].tag, fmt, ##__VA_ARGS__) + +#define PRINT_LOG(index, label, level, hilogMethod, fmt, ...) BASE_PRINT_LOG(index, label, level, \ + hilogMethod, FORMAT_LOG(fmt), ##__VA_ARGS__) + +#define PRINT_LOGD(index, label, fmt, ...) PRINT_LOG(index, label, OHOS::UpdateEngine::UpdateLogLevel::UPDATE_DEBUG, \ + LOG_DEBUG, fmt, ##__VA_ARGS__) +#define PRINT_LOGI(index, label, fmt, ...) PRINT_LOG(index, label, OHOS::UpdateEngine::UpdateLogLevel::UPDATE_INFO, \ + LOG_INFO, fmt, ##__VA_ARGS__) +#define PRINT_LOGE(index, label, fmt, ...) PRINT_LOG(index, label, OHOS::UpdateEngine::UpdateLogLevel::UPDATE_ERROR, \ + LOG_ERROR, fmt, ##__VA_ARGS__) + +#define ENGINE_LOGD(fmt, ...) PRINT_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), LOG_CORE, fmt, ##__VA_ARGS__) +#define ENGINE_LOGI(fmt, ...) PRINT_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), LOG_CORE, fmt, ##__VA_ARGS__) +#define ENGINE_LOGE(fmt, ...) PRINT_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), LOG_CORE, fmt, ##__VA_ARGS__) + +#define PRINT_LONG_LOGD(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ UpdateLogLevel::UPDATE_DEBUG, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define PRINT_LONG_LOGI(label, fmt, args) UpdateLog::PrintLongLog({label, \ +#define PRINT_LONG_LOGI(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ UpdateLogLevel::UPDATE_INFO, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define PRINT_LONG_LOGE(label, fmt, args) UpdateLog::PrintLongLog({label, \ +#define PRINT_LONG_LOGE(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ UpdateLogLevel::UPDATE_ERROR, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define ENGINE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(UPDATE_LABEL, fmt, args) -#define ENGINE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(UPDATE_LABEL, fmt, args) -#define ENGINE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(UPDATE_LABEL, fmt, args) +#define ENGINE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), UPDATE_LABEL, fmt, args) +#define ENGINE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), UPDATE_LABEL, fmt, args) +#define ENGINE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), UPDATE_LABEL, fmt, args) } // namespace UpdateEngine } // namespace OHOS #endif // UPDATE_LOG_H \ No newline at end of file diff --git a/foundations/ability/log/log.gni b/foundations/ability/log/log.gni index 51216d82..0ad851f8 100644 --- a/foundations/ability/log/log.gni +++ b/foundations/ability/log/log.gni @@ -19,5 +19,6 @@ update_log_external_deps = [ ] update_log_deps = [] update_log_include = - [ "$updateengine_root_path/foundations/ability/log/include" ] -update_log_src = [ "$updateengine_root_path/foundations/ability/log/src/update_log.cpp" ] + [ "$updateengine_root_path/foundations/ability/log/include" ] +update_log_src = + [ "$updateengine_root_path/foundations/ability/log/src/update_log.cpp" ] diff --git a/foundations/ability/log/src/update_log.cpp b/foundations/ability/log/src/update_log.cpp index c104ed6d..ac0ebce5 100644 --- a/foundations/ability/log/src/update_log.cpp +++ b/foundations/ability/log/src/update_log.cpp @@ -57,45 +57,45 @@ std::string UpdateLog::GetBriefFileName(const std::string &file) return file; } -void UpdateLog::PrintLongLog(const UpdateLogContent &logContent) +void UpdateLog::PrintLongLog(const uint32_t index, const UpdateLogContent &logContent) { std::string fmtLabel = GetFmtLabel(logContent.log); std::pair splitLogPair = SplitLogByFmtLabel(logContent.log, fmtLabel); - PrintLog(logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.first)); // log前缀不做打印控制 - PrintLog(logContent.BuildWithFmtAndArgs(fmtLabel, logContent.args)); // args采用fmt进行控制 - PrintLog(logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.second)); // log后缀不做打印控制 + PrintLog(index, logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.first)); // log前缀不做打印控制 + PrintLog(index, logContent.BuildWithFmtAndArgs(fmtLabel, logContent.args)); // args采用fmt进行控制 + PrintLog(index, logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.second)); // log后缀不做打印控制 } -void UpdateLog::PrintLog(const UpdateLogContent &logContent) +void UpdateLog::PrintLog(const uint32_t index, const UpdateLogContent &logContent) { int32_t printPos = 0; int32_t len = static_cast(logContent.args.length()); while (printPos < len) { int32_t printLen = std::min(len - printPos, LONG_LOG_LEN); - PrintSingleLine(logContent.BuildWithArgs(logContent.args.substr(printPos, printLen))); + PrintSingleLine(index, logContent.BuildWithArgs(logContent.args.substr(printPos, printLen))); printPos += printLen; } } -void UpdateLog::PrintSingleLine(const UpdateLogContent &logContent) +void UpdateLog::PrintSingleLine(const uint32_t index, const UpdateLogContent &logContent) { // BASE_PRINT_LOG的第三个参数是hilog方法名,即hilogMethod switch (logContent.level) { case UpdateLogLevel::UPDATE_DEBUG: - BASE_PRINT_LOG(logContent.label, logContent.level, Debug, - UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, - logContent.log.c_str(), logContent.args.c_str()); + //BASE_PRINT_LOG(index, logContent.label, logContent.level, LOG_DEBUG, + // UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, + // logContent.log.c_str(), logContent.args.c_str()); break; case UpdateLogLevel::UPDATE_INFO: - BASE_PRINT_LOG(logContent.label, logContent.level, Info, - UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, - logContent.log.c_str(), logContent.args.c_str()); + //BASE_PRINT_LOG(index, logContent.label, logContent.level, LOG_INFO, + // UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, + // logContent.log.c_str(), logContent.args.c_str()); break; case UpdateLogLevel::UPDATE_ERROR: - BASE_PRINT_LOG(logContent.label, logContent.level, Error, - UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, - logContent.log.c_str(), logContent.args.c_str()); + //BASE_PRINT_LOG(index, logContent.label, logContent.level, LOG_ERROR, + // UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, + // logContent.log.c_str(), logContent.args.c_str()); break; default: break; diff --git a/interfaces/inner_api/modulemgr/include/module_log.h b/interfaces/inner_api/modulemgr/include/module_log.h index b7363adf..2ac9eb90 100644 --- a/interfaces/inner_api/modulemgr/include/module_log.h +++ b/interfaces/inner_api/modulemgr/include/module_log.h @@ -17,14 +17,13 @@ #ifndef UPDATE_SERVICE__MODULE_LOG_H #define UPDATE_SERVICE__MODULE_LOG_H -#include "hilog/log.h" +#include "update_log.h" -constexpr OHOS::HiviewDFX::HiLogLabel MODULE_MGR_LABEL = {LOG_CORE, 0xD002E00, "UPDATER_MODULE_MGR"}; - -#define UTILS_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(MODULE_MGR_LABEL, __VA_ARGS__) -#define UTILS_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(MODULE_MGR_LABEL, __VA_ARGS__) -#define UTILS_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(MODULE_MGR_LABEL, __VA_ARGS__) -#define UTILS_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(MODULE_MGR_LABEL, __VA_ARGS__) -#define UTILS_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(MODULE_MGR_LABEL, __VA_ARGS__) +#define UTILS_LOGD(fmt, ...) PRINT_LOGD(ENUM_UINT(OHOS::UpdateEngine::HiLogTagIndex::UPDATER_MODULE_MGR_TAG), \ + LOG_CORE, fmt, ##__VA_ARGS__) +#define UTILS_LOGI(fmt, ...) PRINT_LOGI(ENUM_UINT(OHOS::UpdateEngine::HiLogTagIndex::UPDATER_MODULE_MGR_TAG), \ + LOG_CORE, fmt, ##__VA_ARGS__) +#define UTILS_LOGE(fmt, ...) PRINT_LOGE(ENUM_UINT(OHOS::UpdateEngine::HiLogTagIndex::UPDATER_MODULE_MGR_TAG), \ + LOG_CORE, fmt, ##__VA_ARGS__) #endif // UPDATE_SERVICE__MODULE_LOG_H diff --git a/interfaces/inner_api/modulemgr/modulemgr.gni b/interfaces/inner_api/modulemgr/modulemgr.gni index 40ffdf00..c83cef7a 100644 --- a/interfaces/inner_api/modulemgr/modulemgr.gni +++ b/interfaces/inner_api/modulemgr/modulemgr.gni @@ -28,11 +28,15 @@ modulemgr_deps = [] modulemgr_public_deps = [] -modulemgr_include = [ "$modulemgr_root_path/include" ] +modulemgr_include = [ + "$modulemgr_root_path/include", + "$updateengine_root_path/foundations/ability/log/include", +] modulemgr_src = [ "$modulemgr_root_path/src/update_service_module.cpp", "$modulemgr_root_path/src/module_manager.cpp", + "$updateengine_root_path/foundations/ability/log/src/update_log.cpp", ] modulemgr_cflags = [ diff --git a/services/firmware/utils/include/firmware_log.h b/services/firmware/utils/include/firmware_log.h index b78454e9..47821242 100644 --- a/services/firmware/utils/include/firmware_log.h +++ b/services/firmware/utils/include/firmware_log.h @@ -16,21 +16,22 @@ #ifndef FIRMWARE_LOG_H #define FIRMWARE_LOG_H -#include "hilog/log.h" - #include "update_log.h" namespace OHOS { namespace UpdateEngine { static constexpr OHOS::HiviewDFX::HiLogLabel FIRMWARE_UPDATE_LABEL = {LOG_CORE, 0xD002E00, "UPDATE_FIRMWARE"}; -#define FIRMWARE_LOGD(fmt, ...) PRINT_LOGD(FIRMWARE_UPDATE_LABEL, fmt, ##__VA_ARGS__) -#define FIRMWARE_LOGI(fmt, ...) PRINT_LOGI(FIRMWARE_UPDATE_LABEL, fmt, ##__VA_ARGS__) -#define FIRMWARE_LOGE(fmt, ...) PRINT_LOGE(FIRMWARE_UPDATE_LABEL, fmt, ##__VA_ARGS__) +#define FIRMWARE_LOGD(fmt, ...) PRINT_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), LOG_CORE, fmt, ##__VA_ARGS__) +#define FIRMWARE_LOGI(fmt, ...) PRINT_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), LOG_CORE, fmt, ##__VA_ARGS__) +#define FIRMWARE_LOGE(fmt, ...) PRINT_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), LOG_CORE, fmt, ##__VA_ARGS__) -#define FIRMWARE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(FIRMWARE_UPDATE_LABEL, fmt, args) -#define FIRMWARE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(FIRMWARE_UPDATE_LABEL, fmt, args) -#define FIRMWARE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(FIRMWARE_UPDATE_LABEL, fmt, args) +#define FIRMWARE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), \ + FIRMWARE_UPDATE_LABEL, fmt, args) +#define FIRMWARE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), \ + FIRMWARE_UPDATE_LABEL, fmt, args) +#define FIRMWARE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), \ + FIRMWARE_UPDATE_LABEL, fmt, args) } // namespace UpdateEngine } // namespace OHOS #endif // FIRMWARE_LOG_H \ No newline at end of file -- Gitee From 0d5b68da9a05de6917e79c750874db985c4d128d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 20 Mar 2024 19:36:01 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9hilog=E5=AE=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20Signed-off-by:=20=E9=82=B9=E5=8F=8B=E6=9D=BE=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- foundations/ability/log/include/update_log.h | 71 ++++++++----------- foundations/ability/log/log.gni | 2 +- .../inner_api/modulemgr/include/module_log.h | 9 +-- .../ability/alarm/src/alarm_timer_utils.cpp | 14 ++-- .../src/firmware_download_executor.cpp | 2 +- .../firmware/utils/include/firmware_log.h | 15 ++-- .../src/firmware_check_analyze_utils.cpp | 6 +- 7 files changed, 52 insertions(+), 67 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index 43ebe40e..55da6d6b 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -29,23 +29,20 @@ static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_LABEL = {LOG_CORE, 0xD002E00 static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_LABEL = {LOG_CORE, 0xD002E00, "UPDATE_KITS"}; #endif -struct LogLabel { - uint32_t domainId; - const char *tag; -}; - -static const LogLabel HiLogTagArr[] = { - {0xD002E00, "UPDATE_SA"}, - {0xD002E00, "UPDATE_KITS"}, - {0xD002E00, "UPDATE_FIRMWARE"}, - {0xD002E00, "UPDATER_MODULE_MGR"} -}; - -enum class HiLogTagIndex { - UPDATE_SA_TAG = 0, +static constexpr uint32_t UPDATER_SA_DOMAIN_ID = 0xD002E00; +enum UpdaterSaSubModule { + UPDATE_ENGINE_TAG = 0, UPDATE_KITS_TAG, UPDATE_FIRMWARE_TAG, - UPDATER_MODULE_MGR_TAG + UPDATE_MODULEMGR_TAG, + UPDATE_MODULE_MAX +}; + +static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_MODULE_LABEL[UPDATE_MODULE_MAX] = { + { LOG_CORE, UPDATER_SA_DOMAIN_ID, "UPDATE_SA" }, + { LOG_CORE, UPDATER_SA_DOMAIN_ID, "UPDATE_KITS" }, + { LOG_CORE, UPDATER_SA_DOMAIN_ID, "UPDATE_FIRMWARE" }, + { LOG_CORE, UPDATER_SA_DOMAIN_ID, "UPDATER_MODULE_MGR" } }; enum class UpdateLogLevel { @@ -94,28 +91,22 @@ private: static UpdateLogLevel level_; }; -#define FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) -#define FORMAT_LOG(fmt) "%{public}s:%{public}d %{public}s" fmt, FILENAME, __LINE__, __FUNCTION__ -#define ENUM_UINT(enumClass) (static_cast(enumClass)) -// 暂时记录两边日志 -#define BASE_PRINT_LOG(index, label, level, hilogMethod, fmt, ...) \ - if (OHOS::UpdateEngine::UpdateLog::JudgeLevel((level))) \ - HILOG_IMPL(LOG_CORE, hilogMethod, OHOS::UpdateEngine::HiLogTagArr[index].domainId, \ - OHOS::UpdateEngine::HiLogTagArr[index].tag, fmt, ##__VA_ARGS__) - -#define PRINT_LOG(index, label, level, hilogMethod, fmt, ...) BASE_PRINT_LOG(index, label, level, \ - hilogMethod, FORMAT_LOG(fmt), ##__VA_ARGS__) - -#define PRINT_LOGD(index, label, fmt, ...) PRINT_LOG(index, label, OHOS::UpdateEngine::UpdateLogLevel::UPDATE_DEBUG, \ - LOG_DEBUG, fmt, ##__VA_ARGS__) -#define PRINT_LOGI(index, label, fmt, ...) PRINT_LOG(index, label, OHOS::UpdateEngine::UpdateLogLevel::UPDATE_INFO, \ - LOG_INFO, fmt, ##__VA_ARGS__) -#define PRINT_LOGE(index, label, fmt, ...) PRINT_LOG(index, label, OHOS::UpdateEngine::UpdateLogLevel::UPDATE_ERROR, \ - LOG_ERROR, fmt, ##__VA_ARGS__) - -#define ENGINE_LOGD(fmt, ...) PRINT_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), LOG_CORE, fmt, ##__VA_ARGS__) -#define ENGINE_LOGI(fmt, ...) PRINT_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), LOG_CORE, fmt, ##__VA_ARGS__) -#define ENGINE_LOGE(fmt, ...) PRINT_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), LOG_CORE, fmt, ##__VA_ARGS__) +#define R_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) +#define R_FORMATED(fmt, ...) "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__ + +#define PRINT_HILOGE(module, fmt, ...) (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, \ + OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].domain, OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].tag, \ + "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__) +#define PRINT_HILOGI(module, fmt, ...) (void)HILOG_IMPL(LOG_CORE, LOG_INFO, \ + OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].domain, OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].tag, \ + "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__) +#define PRINT_HILOGD(module, fmt, ...) (void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, \ + OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].domain, OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].tag, \ + "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__) + +#define ENGINE_LOGE(fmt, ...) PRINT_HILOGE(UPDATE_ENGINE_TAG, fmt, ##__VA_ARGS__) +#define ENGINE_LOGI(fmt, ...) PRINT_HILOGI(UPDATE_ENGINE_TAG, fmt, ##__VA_ARGS__) +#define ENGINE_LOGD(fmt, ...) PRINT_HILOGD(UPDATE_ENGINE_TAG, fmt, ##__VA_ARGS__) #define PRINT_LONG_LOGD(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ UpdateLogLevel::UPDATE_DEBUG, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) @@ -124,9 +115,9 @@ private: #define PRINT_LONG_LOGE(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ UpdateLogLevel::UPDATE_ERROR, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define ENGINE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), UPDATE_LABEL, fmt, args) -#define ENGINE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), UPDATE_LABEL, fmt, args) -#define ENGINE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_SA_TAG), UPDATE_LABEL, fmt, args) +#define ENGINE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(UPDATE_ENGINE_TAG, UPDATE_LABEL, fmt, args) +#define ENGINE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(UPDATE_ENGINE_TAG, UPDATE_LABEL, fmt, args) +#define ENGINE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(UPDATE_ENGINE_TAG, UPDATE_LABEL, fmt, args) } // namespace UpdateEngine } // namespace OHOS #endif // UPDATE_LOG_H \ No newline at end of file diff --git a/foundations/ability/log/log.gni b/foundations/ability/log/log.gni index 0ad851f8..787485b6 100644 --- a/foundations/ability/log/log.gni +++ b/foundations/ability/log/log.gni @@ -13,7 +13,7 @@ import("//base/update/updateservice/updateengine.gni") -update_log_external_deps = [ +update_log_external_deps = [ "hilog:libhilog", "updater:libupdaterlog_shared", ] diff --git a/interfaces/inner_api/modulemgr/include/module_log.h b/interfaces/inner_api/modulemgr/include/module_log.h index 2ac9eb90..2a39a000 100644 --- a/interfaces/inner_api/modulemgr/include/module_log.h +++ b/interfaces/inner_api/modulemgr/include/module_log.h @@ -19,11 +19,8 @@ #include "update_log.h" -#define UTILS_LOGD(fmt, ...) PRINT_LOGD(ENUM_UINT(OHOS::UpdateEngine::HiLogTagIndex::UPDATER_MODULE_MGR_TAG), \ - LOG_CORE, fmt, ##__VA_ARGS__) -#define UTILS_LOGI(fmt, ...) PRINT_LOGI(ENUM_UINT(OHOS::UpdateEngine::HiLogTagIndex::UPDATER_MODULE_MGR_TAG), \ - LOG_CORE, fmt, ##__VA_ARGS__) -#define UTILS_LOGE(fmt, ...) PRINT_LOGE(ENUM_UINT(OHOS::UpdateEngine::HiLogTagIndex::UPDATER_MODULE_MGR_TAG), \ - LOG_CORE, fmt, ##__VA_ARGS__) +#define UTILS_LOGE(fmt, ...) PRINT_HILOGE(OHOS::UpdateEngine::UPDATE_MODULEMGR_TAG, fmt, ##__VA_ARGS__) +#define UTILS_LOGI(fmt, ...) PRINT_HILOGI(OHOS::UpdateEngine::UPDATE_MODULEMGR_TAG, fmt, ##__VA_ARGS__) +#define UTILS_LOGD(fmt, ...) PRINT_HILOGD(OHOS::UpdateEngine::UPDATE_MODULEMGR_TAG, fmt, ##__VA_ARGS__) #endif // UPDATE_SERVICE__MODULE_LOG_H diff --git a/services/core/ability/alarm/src/alarm_timer_utils.cpp b/services/core/ability/alarm/src/alarm_timer_utils.cpp index 23644278..34cd39a6 100644 --- a/services/core/ability/alarm/src/alarm_timer_utils.cpp +++ b/services/core/ability/alarm/src/alarm_timer_utils.cpp @@ -67,7 +67,7 @@ uint64_t AlarmTimerUtils::RegisterAlarm(int64_t time, const AlarmTimerCallback & int64_t currentTime = TimeUtils::GetTimestamp(); if (currentTime >= time) { - ENGINE_LOGE("register time is outdated, register time %{public}lld", time); + ENGINE_LOGE("register time is outdated"); return 0; } int64_t tiggerTimeMs = time * Constant::MILLESECONDS; @@ -77,7 +77,7 @@ uint64_t AlarmTimerUtils::RegisterAlarm(int64_t time, const AlarmTimerCallback & uint64_t AlarmTimerUtils::RegisterRepeatAlarm(int64_t time, int64_t repeatTime, const AlarmTimerCallback &callback) { - ENGINE_LOGI("register repeat timer, start time %{public}d, repeat %{public}d", time, repeatTime); + ENGINE_LOGI("RegisterRepeatAlarm"); auto timerInfo = std::make_shared(); uint8_t timerType = static_cast(timerInfo->TIMER_TYPE_REALTIME); timerInfo->SetType(static_cast(timerType)); @@ -94,21 +94,21 @@ uint64_t AlarmTimerUtils::RegisterTimer(int64_t time, const std::shared_ptr systemTimer = MiscServices::TimeServiceClient::GetInstance(); uint64_t timerId = systemTimer->CreateTimer(timerInfo); if (timerId == 0) { - ENGINE_LOGE("CreateTimer failed, register tim %{public}lld", time); + ENGINE_LOGE("CreateTimer failed"); return 0; } // 将秒时间戳改为毫秒时间戳, alarm定时器不支持秒为单位的时间戳 if (!systemTimer->StartTimer(timerId, static_cast(time))) { - ENGINE_LOGE("StartTimer failed, register time %{public}lld", time); + ENGINE_LOGE("StartTimer failed"); return 0; } - ENGINE_LOGI("register timer success, register time %{public}lld, timerId %{public}d", time, timerId); + ENGINE_LOGI("register timer success"); return timerId; } void AlarmTimerUtils::UnregisterAlarm(uint64_t timerId) { - ENGINE_LOGI("UnregisterAlarm, timerId %{public}d", timerId); + ENGINE_LOGI("UnregisterAlarm"); sptr systemTimer = MiscServices::TimeServiceClient::GetInstance(); if (systemTimer != nullptr) { systemTimer->DestroyTimer(timerId); @@ -124,7 +124,7 @@ uint64_t AlarmTimerUtils::GetSystemBootTime() return 0; } uint64_t bootTime = static_cast(currentBootTime); - ENGINE_LOGI("GetSystemBootTime bootTime : %{public}lld", bootTime); + ENGINE_LOGI("GetSystemBootTime success"); return bootTime; } } // namespace UpdateEngine diff --git a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp index 9519a1e5..291ff5be 100644 --- a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp @@ -88,7 +88,7 @@ void FirmwareDownloadExecutor::PerformDownload() std::string downloadFileName = downloadInfo.path; int64_t localFileLength = static_cast(DownloadThread::GetLocalFileLength(downloadFileName)); - ENGINE_LOGI("Download %zu %s", localFileLength, downloadFileName.c_str()); + ENGINE_LOGI("Download %{public}" PRId64 ", %{public}s", localFileLength, downloadFileName.c_str()); if (localFileLength == downloadInfo.packageSize && downloadInfo.packageSize != 0) { progress0.percent = DOWNLOAD_FINISH_PERCENT; progress0.status = UpgradeStatus::DOWNLOAD_SUCCESS; diff --git a/services/firmware/utils/include/firmware_log.h b/services/firmware/utils/include/firmware_log.h index 47821242..fcf5857f 100644 --- a/services/firmware/utils/include/firmware_log.h +++ b/services/firmware/utils/include/firmware_log.h @@ -22,16 +22,13 @@ namespace OHOS { namespace UpdateEngine { static constexpr OHOS::HiviewDFX::HiLogLabel FIRMWARE_UPDATE_LABEL = {LOG_CORE, 0xD002E00, "UPDATE_FIRMWARE"}; -#define FIRMWARE_LOGD(fmt, ...) PRINT_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), LOG_CORE, fmt, ##__VA_ARGS__) -#define FIRMWARE_LOGI(fmt, ...) PRINT_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), LOG_CORE, fmt, ##__VA_ARGS__) -#define FIRMWARE_LOGE(fmt, ...) PRINT_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), LOG_CORE, fmt, ##__VA_ARGS__) +#define FIRMWARE_LOGD(fmt, ...) PRINT_HILOGD(UPDATE_FIRMWARE_TAG, fmt, ##__VA_ARGS__) +#define FIRMWARE_LOGI(fmt, ...) PRINT_HILOGI(UPDATE_FIRMWARE_TAG, fmt, ##__VA_ARGS__) +#define FIRMWARE_LOGE(fmt, ...) PRINT_HILOGE(UPDATE_FIRMWARE_TAG, fmt, ##__VA_ARGS__) -#define FIRMWARE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), \ - FIRMWARE_UPDATE_LABEL, fmt, args) -#define FIRMWARE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), \ - FIRMWARE_UPDATE_LABEL, fmt, args) -#define FIRMWARE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(ENUM_UINT(HiLogTagIndex::UPDATE_FIRMWARE_TAG), \ - FIRMWARE_UPDATE_LABEL, fmt, args) +#define FIRMWARE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(UPDATE_FIRMWARE_TAG, FIRMWARE_UPDATE_LABEL, fmt, args) +#define FIRMWARE_LONG_LOGI(fmt, args) PRINT_LONG_LOGI(UPDATE_FIRMWARE_TAG, FIRMWARE_UPDATE_LABEL, fmt, args) +#define FIRMWARE_LONG_LOGE(fmt, args) PRINT_LONG_LOGE(UPDATE_FIRMWARE_TAG, FIRMWARE_UPDATE_LABEL, fmt, args) } // namespace UpdateEngine } // namespace OHOS #endif // FIRMWARE_LOG_H \ No newline at end of file diff --git a/services/firmware/utils/src/firmware_check_analyze_utils.cpp b/services/firmware/utils/src/firmware_check_analyze_utils.cpp index a5de85c0..29e26edc 100644 --- a/services/firmware/utils/src/firmware_check_analyze_utils.cpp +++ b/services/firmware/utils/src/firmware_check_analyze_utils.cpp @@ -68,7 +68,7 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeBlVersionCheckResults(nlohmann::json & FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeBlVersionCheckResults no key checkResults"); return CAST_INT(JsonParseError::MISSING_PROP); } - FIRMWARE_LOGI("checkResults size is %{public}lu ", root["checkResults"].size()); + FIRMWARE_LOGI("checkResults size is %{public}d ", root["checkResults"].size()); int32_t ret = CAST_INT(JsonParseError::ERR_OK); for (auto &result : root["checkResults"]) { int32_t status = CAST_INT(CheckResultStatus::STATUS_SYSTEM_ERROR); @@ -108,7 +108,7 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeComponents(nlohmann::json &root) FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeComponents no key checkResults"); return CAST_INT(JsonParseError::MISSING_PROP); } - FIRMWARE_LOGI("checkResults size is %{public}lu ", root["checkResults"].size()); + FIRMWARE_LOGI("checkResults size is %{public}d ", root["checkResults"].size()); int32_t ret = CAST_INT(JsonParseError::ERR_OK); std::string componentId; for (auto &result : root["checkResults"]) { @@ -129,7 +129,7 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeComponents(nlohmann::json &root) componentId = component.descriptPackageId; components_.push_back(component); } - + if (root.find("descriptInfo") == root.end()) { FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeComponents no key descriptInfo"); return CAST_INT(JsonParseError::MISSING_PROP); -- Gitee From 8b7471dbf54c4ff6f05336a2a01fafdaaa918ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 20 Mar 2024 12:35:33 +0000 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9hilog=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- .../ability/alarm/src/alarm_timer_utils.cpp | 17 +++++++++-------- services/core/ability/utils/src/file_utils.cpp | 3 ++- .../utils/src/firmware_check_analyze_utils.cpp | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/services/core/ability/alarm/src/alarm_timer_utils.cpp b/services/core/ability/alarm/src/alarm_timer_utils.cpp index 34cd39a6..a582166e 100644 --- a/services/core/ability/alarm/src/alarm_timer_utils.cpp +++ b/services/core/ability/alarm/src/alarm_timer_utils.cpp @@ -15,9 +15,10 @@ #include "alarm_timer_utils.h" -#include "time_service_client.h" +#include #include "constant.h" +#include "time_service_client.h" #include "time_utils.h" #include "update_log.h" @@ -67,7 +68,7 @@ uint64_t AlarmTimerUtils::RegisterAlarm(int64_t time, const AlarmTimerCallback & int64_t currentTime = TimeUtils::GetTimestamp(); if (currentTime >= time) { - ENGINE_LOGE("register time is outdated"); + ENGINE_LOGE("register time is outdated, register time %{public}" PRIu64 "", time); return 0; } int64_t tiggerTimeMs = time * Constant::MILLESECONDS; @@ -77,7 +78,7 @@ uint64_t AlarmTimerUtils::RegisterAlarm(int64_t time, const AlarmTimerCallback & uint64_t AlarmTimerUtils::RegisterRepeatAlarm(int64_t time, int64_t repeatTime, const AlarmTimerCallback &callback) { - ENGINE_LOGI("RegisterRepeatAlarm"); + ENGINE_LOGI("register repeat timer, start time %{public}" PRId64 ", repeat %{public}" PRId64 "", time, repeatTime); auto timerInfo = std::make_shared(); uint8_t timerType = static_cast(timerInfo->TIMER_TYPE_REALTIME); timerInfo->SetType(static_cast(timerType)); @@ -94,21 +95,21 @@ uint64_t AlarmTimerUtils::RegisterTimer(int64_t time, const std::shared_ptr systemTimer = MiscServices::TimeServiceClient::GetInstance(); uint64_t timerId = systemTimer->CreateTimer(timerInfo); if (timerId == 0) { - ENGINE_LOGE("CreateTimer failed"); + ENGINE_LOGE("CreateTimer failed, register tim %{public}" PRId64 "", time); return 0; } // 将秒时间戳改为毫秒时间戳, alarm定时器不支持秒为单位的时间戳 if (!systemTimer->StartTimer(timerId, static_cast(time))) { - ENGINE_LOGE("StartTimer failed"); + ENGINE_LOGE("StartTimer failed, register time %{public}" PRId64"", time); return 0; } - ENGINE_LOGI("register timer success"); + ENGINE_LOGI("register timer success, register time %{public}" PRId64 ", timerId %{public}" PRIu64 "", time, timerId); return timerId; } void AlarmTimerUtils::UnregisterAlarm(uint64_t timerId) { - ENGINE_LOGI("UnregisterAlarm"); + ENGINE_LOGI("UnregisterAlarm, timerId %{public}" PRIu64 "", timerId); sptr systemTimer = MiscServices::TimeServiceClient::GetInstance(); if (systemTimer != nullptr) { systemTimer->DestroyTimer(timerId); @@ -124,7 +125,7 @@ uint64_t AlarmTimerUtils::GetSystemBootTime() return 0; } uint64_t bootTime = static_cast(currentBootTime); - ENGINE_LOGI("GetSystemBootTime success"); + ENGINE_LOGI("GetSystemBootTime bootTime : %{public}" PRIu64 "", bootTime); return bootTime; } } // namespace UpdateEngine diff --git a/services/core/ability/utils/src/file_utils.cpp b/services/core/ability/utils/src/file_utils.cpp index 76d94322..05ada0b9 100644 --- a/services/core/ability/utils/src/file_utils.cpp +++ b/services/core/ability/utils/src/file_utils.cpp @@ -16,6 +16,7 @@ #include "file_utils.h" #include +#include #include #include #include @@ -59,7 +60,7 @@ bool FileUtils::IsSpaceEnough(const std::string &filePath, const int64_t require } else { ENGINE_LOGE("statfs fail, error code = %{public}d", ret); } - ENGINE_LOGI("free space=%{public}llu, required space=%{public}llu", freeSpace, + ENGINE_LOGI("free space=%{public}" PRIu64 ", required space=%{public}" PRIu64 "", freeSpace, static_cast(requiredSpace)); return freeSpace >= static_cast(requiredSpace); } diff --git a/services/firmware/utils/src/firmware_check_analyze_utils.cpp b/services/firmware/utils/src/firmware_check_analyze_utils.cpp index 29e26edc..ddf3c7ac 100644 --- a/services/firmware/utils/src/firmware_check_analyze_utils.cpp +++ b/services/firmware/utils/src/firmware_check_analyze_utils.cpp @@ -68,7 +68,7 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeBlVersionCheckResults(nlohmann::json & FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeBlVersionCheckResults no key checkResults"); return CAST_INT(JsonParseError::MISSING_PROP); } - FIRMWARE_LOGI("checkResults size is %{public}d ", root["checkResults"].size()); + FIRMWARE_LOGI("checkResults size is %{public}" PRIu64 "", root["checkResults"].size()); int32_t ret = CAST_INT(JsonParseError::ERR_OK); for (auto &result : root["checkResults"]) { int32_t status = CAST_INT(CheckResultStatus::STATUS_SYSTEM_ERROR); @@ -108,7 +108,7 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeComponents(nlohmann::json &root) FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeComponents no key checkResults"); return CAST_INT(JsonParseError::MISSING_PROP); } - FIRMWARE_LOGI("checkResults size is %{public}d ", root["checkResults"].size()); + FIRMWARE_LOGI("checkResults size is %{public}" PRIu64 "", root["checkResults"].size()); int32_t ret = CAST_INT(JsonParseError::ERR_OK); std::string componentId; for (auto &result : root["checkResults"]) { -- Gitee From f4cbf36d8dca676bc60a3c12b23ddccf906cb3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 20 Mar 2024 12:48:46 +0000 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- services/firmware/utils/src/firmware_check_analyze_utils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/firmware/utils/src/firmware_check_analyze_utils.cpp b/services/firmware/utils/src/firmware_check_analyze_utils.cpp index ddf3c7ac..43e30e3f 100644 --- a/services/firmware/utils/src/firmware_check_analyze_utils.cpp +++ b/services/firmware/utils/src/firmware_check_analyze_utils.cpp @@ -15,6 +15,7 @@ #include "firmware_check_analyze_utils.h" +#include #include #include #include @@ -68,7 +69,7 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeBlVersionCheckResults(nlohmann::json & FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeBlVersionCheckResults no key checkResults"); return CAST_INT(JsonParseError::MISSING_PROP); } - FIRMWARE_LOGI("checkResults size is %{public}" PRIu64 "", root["checkResults"].size()); + FIRMWARE_LOGI("checkResults size is %{public}" PRIu64 "", static_cast(root["checkResults"].size())); int32_t ret = CAST_INT(JsonParseError::ERR_OK); for (auto &result : root["checkResults"]) { int32_t status = CAST_INT(CheckResultStatus::STATUS_SYSTEM_ERROR); @@ -108,7 +109,7 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeComponents(nlohmann::json &root) FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeComponents no key checkResults"); return CAST_INT(JsonParseError::MISSING_PROP); } - FIRMWARE_LOGI("checkResults size is %{public}" PRIu64 "", root["checkResults"].size()); + FIRMWARE_LOGI("checkResults size is %{public}" PRIu64 "", static_cast(root["checkResults"].size())); int32_t ret = CAST_INT(JsonParseError::ERR_OK); std::string componentId; for (auto &result : root["checkResults"]) { -- Gitee From 4bc9f5164d3deb668d3247f1e5698ae0aff07b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 21 Mar 2024 18:04:06 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9hilog=E5=AE=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20Signed-off-by:=20=E9=82=B9=E5=8F=8B=E6=9D=BE=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- foundations/ability/log/include/update_log.h | 53 +++++++++++++++++--- foundations/ability/log/src/update_log.cpp | 31 ++++-------- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index 55da6d6b..ca9e73de 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -29,6 +29,11 @@ static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_LABEL = {LOG_CORE, 0xD002E00 static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_LABEL = {LOG_CORE, 0xD002E00, "UPDATE_KITS"}; #endif +const std::string DEFAULT_LABEL = "%"; +const std::string DEFAULT_FMT_LABEL = "%s"; +const std::string PRIVATE_FMT_LABEL = "%{private}s"; +const std::string PUBLIC_FMT_LABEL = "%{public}s"; + static constexpr uint32_t UPDATER_SA_DOMAIN_ID = 0xD002E00; enum UpdaterSaSubModule { UPDATE_ENGINE_TAG = 0, @@ -78,11 +83,11 @@ public: static void SetLogLevel(const UpdateLogLevel &level); static const UpdateLogLevel &GetLogLevel(); static std::string GetBriefFileName(const std::string &file); - static void PrintLongLog(const uint32_t index, const UpdateLogContent &logContent); + static void PrintLongLog(const uint32_t module, const UpdateLogContent &logContent); private: - static void PrintLog(const uint32_t index, const UpdateLogContent &logContent); - static void PrintSingleLine(const uint32_t index, const UpdateLogContent &logContent); + static void PrintLog(const uint32_t module, const UpdateLogContent &logContent); + static void PrintSingleLine(const uint32_t module, const UpdateLogContent &logContent); static std::pair SplitLogByFmtLabel(const std::string &log, const std::string &fmtLabel); static std::string GetFmtLabel(const std::string &log); static int32_t FindSubStrCount(const std::string &str, const std::string &subStr); @@ -94,6 +99,42 @@ private: #define R_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) #define R_FORMATED(fmt, ...) "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__ +#define EXEC_PRINT_HILOG(module, fmtlabel, level, fmt) \ + if (level == UpdateLogLevel::UPDATE_ERROR) { \ + EXEC_PRINT_HILOE(module, fmtlabel, fmt); \ + } else if (level == UpdateLogLevel::UPDATE_DEBUG) { \ + EXEC_PRINT_HILOD(module, fmtlabel, fmt); \ + } else { \ + EXEC_PRINT_HILOI(module, fmtlabel, fmt); \ + } + +#define EXEC_PRINT_HILOGE(module, fmtlabel, fmt, ...) \ + if (fmtlabel == PUBLIC_FMT_LABEL) { \ + PRINT_HILOGE(module, "%{public}s", fmt); \ + } else if (level == PRIVATE_FMT_LABEL) { \ + PRINT_HILOGE(module, "%{private}s", fmt); \ + } else { \ + PRINT_HILOGE(module, "%s", fmt); \ + } + +#define EXEC_PRINT_HILOGD(module, fmtlabel, fmt, ...) \ + if (fmtlabel == PUBLIC_FMT_LABEL) { \ + PRINT_HILOGD(module, "%{public}s", fmt); \ + } else if (level == PRIVATE_FMT_LABEL) { \ + PRINT_HILOGD(module, "%{private}s", fmt); \ + } else { \ + PRINT_HILOGD(module, "%s", fmt); \ + } + +#define EXEC_PRINT_HILOGI(module, fmtlabel, fmt, ...) \ + if (fmtlabel == PUBLIC_FMT_LABEL) { \ + PRINT_HILOGI(module, "%{public}s", fmt); \ + } else if (level == PRIVATE_FMT_LABEL) { \ + PRINT_HILOGI(module, "%{private}s", fmt); \ + } else { \ + PRINT_HILOGI(module, "%s", fmt); \ + } + #define PRINT_HILOGE(module, fmt, ...) (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, \ OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].domain, OHOS::UpdateEngine::UPDATE_MODULE_LABEL[module].tag, \ "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__) @@ -108,11 +149,11 @@ private: #define ENGINE_LOGI(fmt, ...) PRINT_HILOGI(UPDATE_ENGINE_TAG, fmt, ##__VA_ARGS__) #define ENGINE_LOGD(fmt, ...) PRINT_HILOGD(UPDATE_ENGINE_TAG, fmt, ##__VA_ARGS__) -#define PRINT_LONG_LOGD(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ +#define PRINT_LONG_LOGD(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ UpdateLogLevel::UPDATE_DEBUG, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define PRINT_LONG_LOGI(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ +#define PRINT_LONG_LOGI(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ UpdateLogLevel::UPDATE_INFO, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define PRINT_LONG_LOGE(index, label, fmt, args) UpdateLog::PrintLongLog(index, {label, \ +#define PRINT_LONG_LOGE(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ UpdateLogLevel::UPDATE_ERROR, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) #define ENGINE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(UPDATE_ENGINE_TAG, UPDATE_LABEL, fmt, args) diff --git a/foundations/ability/log/src/update_log.cpp b/foundations/ability/log/src/update_log.cpp index ac0ebce5..3651a3b4 100644 --- a/foundations/ability/log/src/update_log.cpp +++ b/foundations/ability/log/src/update_log.cpp @@ -20,10 +20,6 @@ namespace UpdateEngine { UpdateLogLevel UpdateLog::level_ = UpdateLogLevel::UPDATE_INFO; constexpr int32_t COUNT_ONE = 1; constexpr int32_t LONG_LOG_LEN = 900; -const std::string DEFAULT_LABEL = "%"; -const std::string DEFAULT_FMT_LABEL = "%s"; -const std::string PRIVATE_FMT_LABEL = "%{private}s"; -const std::string PUBLIC_FMT_LABEL = "%{public}s"; bool UpdateLog::JudgeLevel(const UpdateLogLevel &level) { @@ -57,45 +53,36 @@ std::string UpdateLog::GetBriefFileName(const std::string &file) return file; } -void UpdateLog::PrintLongLog(const uint32_t index, const UpdateLogContent &logContent) +void UpdateLog::PrintLongLog(const uint32_t module, const UpdateLogContent &logContent) { std::string fmtLabel = GetFmtLabel(logContent.log); std::pair splitLogPair = SplitLogByFmtLabel(logContent.log, fmtLabel); - PrintLog(index, logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.first)); // log前缀不做打印控制 - PrintLog(index, logContent.BuildWithFmtAndArgs(fmtLabel, logContent.args)); // args采用fmt进行控制 - PrintLog(index, logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.second)); // log后缀不做打印控制 + PrintLog(module, logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.first)); // log前缀不做打印控制 + PrintLog(module, logContent.BuildWithFmtAndArgs(fmtLabel, logContent.args)); // args采用fmt进行控制 + PrintLog(module, logContent.BuildWithFmtAndArgs(PUBLIC_FMT_LABEL, splitLogPair.second)); // log后缀不做打印控制 } -void UpdateLog::PrintLog(const uint32_t index, const UpdateLogContent &logContent) +void UpdateLog::PrintLog(const uint32_t module, const UpdateLogContent &logContent) { int32_t printPos = 0; int32_t len = static_cast(logContent.args.length()); while (printPos < len) { int32_t printLen = std::min(len - printPos, LONG_LOG_LEN); - PrintSingleLine(index, logContent.BuildWithArgs(logContent.args.substr(printPos, printLen))); + PrintSingleLine(module, logContent.BuildWithArgs(logContent.args.substr(printPos, printLen))); printPos += printLen; } } -void UpdateLog::PrintSingleLine(const uint32_t index, const UpdateLogContent &logContent) +void UpdateLog::PrintSingleLine(const uint32_t module, const UpdateLogContent &logContent) { // BASE_PRINT_LOG的第三个参数是hilog方法名,即hilogMethod + std::string fmtLabel = GetFmtLabel(logContent.log); switch (logContent.level) { case UpdateLogLevel::UPDATE_DEBUG: - //BASE_PRINT_LOG(index, logContent.label, logContent.level, LOG_DEBUG, - // UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, - // logContent.log.c_str(), logContent.args.c_str()); - break; case UpdateLogLevel::UPDATE_INFO: - //BASE_PRINT_LOG(index, logContent.label, logContent.level, LOG_INFO, - // UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, - // logContent.log.c_str(), logContent.args.c_str()); - break; case UpdateLogLevel::UPDATE_ERROR: - //BASE_PRINT_LOG(index, logContent.label, logContent.level, LOG_ERROR, - // UpdateLog::GetBriefFileName(logContent.fileName).c_str(), logContent.line, - // logContent.log.c_str(), logContent.args.c_str()); + EXEC_PRINT_HILOG(module, fmtLabel, logContent.level, logContent.args.c_str()); break; default: break; -- Gitee From 966e215e63673fd5a3b515f6319d0c9e06615c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 21 Mar 2024 10:14:06 +0000 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- foundations/ability/log/include/update_log.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index ca9e73de..d1978727 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -101,11 +101,11 @@ private: #define EXEC_PRINT_HILOG(module, fmtlabel, level, fmt) \ if (level == UpdateLogLevel::UPDATE_ERROR) { \ - EXEC_PRINT_HILOE(module, fmtlabel, fmt); \ + EXEC_PRINT_HILOGE(module, fmtlabel, fmt); \ } else if (level == UpdateLogLevel::UPDATE_DEBUG) { \ - EXEC_PRINT_HILOD(module, fmtlabel, fmt); \ + EXEC_PRINT_HILOGD(module, fmtlabel, fmt); \ } else { \ - EXEC_PRINT_HILOI(module, fmtlabel, fmt); \ + EXEC_PRINT_HILOGI(module, fmtlabel, fmt); \ } #define EXEC_PRINT_HILOGE(module, fmtlabel, fmt, ...) \ -- Gitee From 74448fa612144945e49cd22f58faa9d0af0078aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 21 Mar 2024 10:20:03 +0000 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9hilog=20=E5=AE=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- foundations/ability/log/include/update_log.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index d1978727..00e26b86 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -111,7 +111,7 @@ private: #define EXEC_PRINT_HILOGE(module, fmtlabel, fmt, ...) \ if (fmtlabel == PUBLIC_FMT_LABEL) { \ PRINT_HILOGE(module, "%{public}s", fmt); \ - } else if (level == PRIVATE_FMT_LABEL) { \ + } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ PRINT_HILOGE(module, "%{private}s", fmt); \ } else { \ PRINT_HILOGE(module, "%s", fmt); \ @@ -120,7 +120,7 @@ private: #define EXEC_PRINT_HILOGD(module, fmtlabel, fmt, ...) \ if (fmtlabel == PUBLIC_FMT_LABEL) { \ PRINT_HILOGD(module, "%{public}s", fmt); \ - } else if (level == PRIVATE_FMT_LABEL) { \ + } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ PRINT_HILOGD(module, "%{private}s", fmt); \ } else { \ PRINT_HILOGD(module, "%s", fmt); \ @@ -129,7 +129,7 @@ private: #define EXEC_PRINT_HILOGI(module, fmtlabel, fmt, ...) \ if (fmtlabel == PUBLIC_FMT_LABEL) { \ PRINT_HILOGI(module, "%{public}s", fmt); \ - } else if (level == PRIVATE_FMT_LABEL) { \ + } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ PRINT_HILOGI(module, "%{private}s", fmt); \ } else { \ PRINT_HILOGI(module, "%s", fmt); \ -- Gitee From c71a4d459ac736d8f9a3ddf362b201d7ac6ac6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 21 Mar 2024 10:36:46 +0000 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A9=BA=E6=A0=BC?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- foundations/ability/log/include/update_log.h | 48 +++++++++---------- .../ability/alarm/src/alarm_timer_utils.cpp | 5 +- .../core/ability/utils/src/file_utils.cpp | 2 +- .../src/firmware_check_analyze_utils.cpp | 2 +- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index 00e26b86..40e21bc7 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -108,31 +108,31 @@ private: EXEC_PRINT_HILOGI(module, fmtlabel, fmt); \ } -#define EXEC_PRINT_HILOGE(module, fmtlabel, fmt, ...) \ - if (fmtlabel == PUBLIC_FMT_LABEL) { \ - PRINT_HILOGE(module, "%{public}s", fmt); \ - } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ - PRINT_HILOGE(module, "%{private}s", fmt); \ - } else { \ - PRINT_HILOGE(module, "%s", fmt); \ +#define EXEC_PRINT_HILOGE(module, fmtlabel, fmt, ...) \ + if (fmtlabel == PUBLIC_FMT_LABEL) { \ + PRINT_HILOGE(module, "%{public}s", fmt); \ + } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ + PRINT_HILOGE(module, "%{private}s", fmt); \ + } else { \ + PRINT_HILOGE(module, "%s", fmt); \ } -#define EXEC_PRINT_HILOGD(module, fmtlabel, fmt, ...) \ - if (fmtlabel == PUBLIC_FMT_LABEL) { \ - PRINT_HILOGD(module, "%{public}s", fmt); \ - } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ - PRINT_HILOGD(module, "%{private}s", fmt); \ - } else { \ - PRINT_HILOGD(module, "%s", fmt); \ +#define EXEC_PRINT_HILOGD(module, fmtlabel, fmt, ...) \ + if (fmtlabel == PUBLIC_FMT_LABEL) { \ + PRINT_HILOGD(module, "%{public}s", fmt); \ + } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ + PRINT_HILOGD(module, "%{private}s", fmt); \ + } else { \ + PRINT_HILOGD(module, "%s", fmt); \ } -#define EXEC_PRINT_HILOGI(module, fmtlabel, fmt, ...) \ - if (fmtlabel == PUBLIC_FMT_LABEL) { \ - PRINT_HILOGI(module, "%{public}s", fmt); \ - } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ - PRINT_HILOGI(module, "%{private}s", fmt); \ - } else { \ - PRINT_HILOGI(module, "%s", fmt); \ +#define EXEC_PRINT_HILOGI(module, fmtlabel, fmt, ...) \ + if (fmtlabel == PUBLIC_FMT_LABEL) { \ + PRINT_HILOGI(module, "%{public}s", fmt); \ + } else if (fmtlabel == PRIVATE_FMT_LABEL) { \ + PRINT_HILOGI(module, "%{private}s", fmt); \ + } else { \ + PRINT_HILOGI(module, "%s", fmt); \ } #define PRINT_HILOGE(module, fmt, ...) (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, \ @@ -149,11 +149,11 @@ private: #define ENGINE_LOGI(fmt, ...) PRINT_HILOGI(UPDATE_ENGINE_TAG, fmt, ##__VA_ARGS__) #define ENGINE_LOGD(fmt, ...) PRINT_HILOGD(UPDATE_ENGINE_TAG, fmt, ##__VA_ARGS__) -#define PRINT_LONG_LOGD(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ +#define PRINT_LONG_LOGD(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ UpdateLogLevel::UPDATE_DEBUG, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define PRINT_LONG_LOGI(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ +#define PRINT_LONG_LOGI(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ UpdateLogLevel::UPDATE_INFO, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) -#define PRINT_LONG_LOGE(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ +#define PRINT_LONG_LOGE(module, label, fmt, args) UpdateLog::PrintLongLog(module, {label, \ UpdateLogLevel::UPDATE_ERROR, std::string(fmt), std::string(args), std::string(__FILE__), __LINE__}) #define ENGINE_LONG_LOGD(fmt, args) PRINT_LONG_LOGD(UPDATE_ENGINE_TAG, UPDATE_LABEL, fmt, args) diff --git a/services/core/ability/alarm/src/alarm_timer_utils.cpp b/services/core/ability/alarm/src/alarm_timer_utils.cpp index a582166e..8bfc16fb 100644 --- a/services/core/ability/alarm/src/alarm_timer_utils.cpp +++ b/services/core/ability/alarm/src/alarm_timer_utils.cpp @@ -15,7 +15,7 @@ #include "alarm_timer_utils.h" -#include +#include #include "constant.h" #include "time_service_client.h" @@ -103,7 +103,8 @@ uint64_t AlarmTimerUtils::RegisterTimer(int64_t time, const std::shared_ptr #include -#include #include #include #include diff --git a/services/firmware/utils/src/firmware_check_analyze_utils.cpp b/services/firmware/utils/src/firmware_check_analyze_utils.cpp index 43e30e3f..0250232c 100644 --- a/services/firmware/utils/src/firmware_check_analyze_utils.cpp +++ b/services/firmware/utils/src/firmware_check_analyze_utils.cpp @@ -15,7 +15,7 @@ #include "firmware_check_analyze_utils.h" -#include +#include #include #include #include -- Gitee From bdd472c82f1f4986997dc7f202e227b41aeef95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 21 Mar 2024 10:49:19 +0000 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9codex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- foundations/ability/log/include/update_log.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index 40e21bc7..c02e035e 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -100,9 +100,9 @@ private: #define R_FORMATED(fmt, ...) "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__ #define EXEC_PRINT_HILOG(module, fmtlabel, level, fmt) \ - if (level == UpdateLogLevel::UPDATE_ERROR) { \ + if ((level) == UpdateLogLevel::UPDATE_ERROR) { \ EXEC_PRINT_HILOGE(module, fmtlabel, fmt); \ - } else if (level == UpdateLogLevel::UPDATE_DEBUG) { \ + } else if ((level) == UpdateLogLevel::UPDATE_DEBUG) { \ EXEC_PRINT_HILOGD(module, fmtlabel, fmt); \ } else { \ EXEC_PRINT_HILOGI(module, fmtlabel, fmt); \ -- Gitee From c4f0b94907dfaaeebac1eb08297d0e8c2e43a3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 21 Mar 2024 11:00:40 +0000 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- foundations/ability/log/include/update_log.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index c02e035e..30490c28 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -100,12 +100,12 @@ private: #define R_FORMATED(fmt, ...) "[%{public}s] %{public}s#]" fmt, R_FILENAME, __FUNCTION__, ##__VA_ARGS__ #define EXEC_PRINT_HILOG(module, fmtlabel, level, fmt) \ - if ((level) == UpdateLogLevel::UPDATE_ERROR) { \ - EXEC_PRINT_HILOGE(module, fmtlabel, fmt); \ - } else if ((level) == UpdateLogLevel::UPDATE_DEBUG) { \ - EXEC_PRINT_HILOGD(module, fmtlabel, fmt); \ - } else { \ - EXEC_PRINT_HILOGI(module, fmtlabel, fmt); \ + if ((level) == UpdateLogLevel::UPDATE_ERROR) { \ + EXEC_PRINT_HILOGE(module, fmtlabel, fmt); \ + } else if ((level) == UpdateLogLevel::UPDATE_DEBUG) { \ + EXEC_PRINT_HILOGD(module, fmtlabel, fmt); \ + } else { \ + EXEC_PRINT_HILOGI(module, fmtlabel, fmt); \ } #define EXEC_PRINT_HILOGE(module, fmtlabel, fmt, ...) \ -- Gitee