diff --git a/foundations/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h index ebbc6ce0ecde831544a8461416cd8881e7c884f4..30490c2878fd3c4fc633ac6d06b818e7a16677ae 100644 --- a/foundations/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -29,6 +29,27 @@ 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, + UPDATE_KITS_TAG, + UPDATE_FIRMWARE_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 { UPDATE_DEBUG = 0, UPDATE_INFO, @@ -62,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 UpdateLogContent &logContent); + static void PrintLongLog(const uint32_t module, const UpdateLogContent &logContent); private: - static void PrintLog(const UpdateLogContent &logContent); - static void PrintSingleLine(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); @@ -75,33 +96,69 @@ private: static UpdateLogLevel level_; }; -// 暂时记录两边日志 -#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 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_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, ...) \ + 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_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, \ + 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(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(label, fmt, args) UpdateLog::PrintLongLog({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(label, fmt, args) UpdateLog::PrintLongLog({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_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(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 51216d82437ad1b0dbfc5a6433b121451a0d1520..787485b66519b37c5c53f5e1d2e8dbbd53a4a3d1 100644 --- a/foundations/ability/log/log.gni +++ b/foundations/ability/log/log.gni @@ -13,11 +13,12 @@ import("//base/update/updateservice/updateengine.gni") -update_log_external_deps = [ +update_log_external_deps = [ "hilog:libhilog", "updater:libupdaterlog_shared", ] 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 c104ed6d9fa11b3d7cb333a53c48bfd11aef396b..3651a3b4b2fa701f20a93e983eacfa11d9923932 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 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(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(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 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(logContent.BuildWithArgs(logContent.args.substr(printPos, printLen))); + PrintSingleLine(module, logContent.BuildWithArgs(logContent.args.substr(printPos, printLen))); printPos += printLen; } } -void UpdateLog::PrintSingleLine(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(logContent.label, logContent.level, 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()); - 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()); + EXEC_PRINT_HILOG(module, fmtLabel, logContent.level, 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 b7363adfc00250a91a4188fdc12176e8c78d3f2b..2a39a000573450d78066f72c92ae48da831bf7b8 100644 --- a/interfaces/inner_api/modulemgr/include/module_log.h +++ b/interfaces/inner_api/modulemgr/include/module_log.h @@ -17,14 +17,10 @@ #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_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/interfaces/inner_api/modulemgr/modulemgr.gni b/interfaces/inner_api/modulemgr/modulemgr.gni index 40ffdf00ceedf0a0d5e88473a6defacfda4c4189..c83cef7aa8692a983ebca1fb5a2ab8bfa07f9ff6 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/core/ability/alarm/src/alarm_timer_utils.cpp b/services/core/ability/alarm/src/alarm_timer_utils.cpp index 2364427849e12181a9f6108d93fde404ca160f51..8bfc16fbe58d830d641f148e5c5c629914374daf 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, register time %{public}lld", time); + 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("register repeat timer, start time %{public}d, repeat %{public}d", time, repeatTime); + 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,22 @@ 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, register tim %{public}" PRId64 "", time); return 0; } // 将秒时间戳改为毫秒时间戳, alarm定时器不支持秒为单位的时间戳 if (!systemTimer->StartTimer(timerId, static_cast(time))) { - ENGINE_LOGE("StartTimer failed, register time %{public}lld", time); + ENGINE_LOGE("StartTimer failed, register time %{public}" PRId64"", time); return 0; } - ENGINE_LOGI("register timer success, register time %{public}lld, timerId %{public}d", time, timerId); + 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, timerId %{public}d", timerId); + ENGINE_LOGI("UnregisterAlarm, timerId %{public}" PRIu64 "", timerId); sptr systemTimer = MiscServices::TimeServiceClient::GetInstance(); if (systemTimer != nullptr) { systemTimer->DestroyTimer(timerId); @@ -124,7 +126,7 @@ uint64_t AlarmTimerUtils::GetSystemBootTime() return 0; } uint64_t bootTime = static_cast(currentBootTime); - ENGINE_LOGI("GetSystemBootTime bootTime : %{public}lld", bootTime); + 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 76d94322de1ecd400d11b9af9368477c4c1be511..33dc3b84593a3dc98b7cea760ede12528bdd30b8 100644 --- a/services/core/ability/utils/src/file_utils.cpp +++ b/services/core/ability/utils/src/file_utils.cpp @@ -15,6 +15,7 @@ #include "file_utils.h" +#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/upgrade/executor/src/firmware_download_executor.cpp b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp index 9519a1e5b70a1fd2eb4e064c557be30dc0ab6464..291ff5bea69f0ab1bb06b59397ad2e1bbbbd9b7f 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 b78454e99c214baa0246bdea9423aa2b1dd3b132..fcf5857f140ec49f9a306754fdfe1e7df3f9d63e 100644 --- a/services/firmware/utils/include/firmware_log.h +++ b/services/firmware/utils/include/firmware_log.h @@ -16,21 +16,19 @@ #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_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(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(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 a5de85c0a04ea0a52fc95c19bdf6e30691505a95..0250232c93c0f852c6603403c6ae4a6a66587f83 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}lu ", 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}lu ", 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"]) { @@ -129,7 +130,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);