已合并
恢复截图日志 #82862
zouqianshun创建于 3月28日
恢复截图日志 #82862
已合并
zouqianshun创建于 3月28日
已删除 :0328log合入到openharmony/arkui_ace_enginemaster
1 个文件变更+17-8
@@ -596,11 +596,13 @@ static napi_value JSSnapshotGetSync(napi_env env, napi_callback_info info)
596 napi_valuetype valueType = napi_null;596 napi_valuetype valueType = napi_null;
597 GetNapiString(env, helper.GetArgv(0), componentId, valueType);597 GetNapiString(env, helper.GetArgv(0), componentId, valueType);
598 598 
599+ auto reason = ContainerScope::CurrentIdWithReason().second;
600+ auto instanceId = Container::CurrentIdSafely();
599 auto delegate = EngineHelper::GetCurrentDelegateSafely();601 auto delegate = EngineHelper::GetCurrentDelegateSafely();
600 if (!delegate) {602 if (!delegate) {
601- auto currentIdAndReason = ContainerScope::CurrentIdWithReason();603+ TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT, "Can't get delegate of ace_engine. ");
602 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(604 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(
603- currentIdAndReason.second, Container::CurrentIdSafely());605+ reason, instanceId);
604 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);606 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);
605 napi_close_escapable_handle_scope(env, scope);607 napi_close_escapable_handle_scope(env, scope);
606 return result;608 return result;
@@ -679,11 +681,14 @@ static napi_value JSSnapshotGetSyncWithUniqueId(napi_env env, napi_callback_info
679 int32_t uniqueId;681 int32_t uniqueId;
680 napi_get_value_int32(env, helper.GetArgv(0), &uniqueId);682 napi_get_value_int32(env, helper.GetArgv(0), &uniqueId);
681 683 
684+ auto reason = ContainerScope::CurrentIdWithReason().second;
685+ auto instanceId = Container::CurrentIdSafely();
682 auto delegate = EngineHelper::GetCurrentDelegateSafely();686 auto delegate = EngineHelper::GetCurrentDelegateSafely();
683 if (!delegate) {687 if (!delegate) {
684- auto currentIdAndReason = ContainerScope::CurrentIdWithReason();688+ TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT,
689+ "Can't get delegate of ace_engine. param: %{public}d", uniqueId);
685 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(690 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(
686- currentIdAndReason.second, Container::CurrentIdSafely());691+ reason, instanceId);
687 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);692 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);
688 napi_close_escapable_handle_scope(env, scope);693 napi_close_escapable_handle_scope(env, scope);
689 return result;694 return result;
@@ -712,11 +717,13 @@ static napi_value JSSnapshotFromComponent(napi_env env, napi_callback_info info)
712 }717 }
713 718 
714 napi_value result = nullptr;719 napi_value result = nullptr;
720+ auto reason = ContainerScope::CurrentIdWithReason().second;
721+ auto instanceId = Container::CurrentIdSafely();
715 auto delegate = EngineHelper::GetCurrentDelegateSafely();722 auto delegate = EngineHelper::GetCurrentDelegateSafely();
716 if (!delegate) {723 if (!delegate) {
717- auto currentIdAndReason = ContainerScope::CurrentIdWithReason();724+ TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT, "Can't get delegate of ace_engine. ");
718 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(725 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(
arkui-feature-manager

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟢 日志记录中缺少关键参数信息

位置: L725 | 严重程度: Low

❓ 问题描述

JSSnapshotFromComponentJSSnapshotGetWithRange 函数的错误日志中,仅打印了固定的错误字符串,未包含输入参数(如 componentId)。相比之下,JSSnapshotGetSyncJSSnapshotGetSyncWithUniqueId 在日志中包含了参数信息。为了便于问题排查,建议统一在日志中打印关键参数。

💡 修复建议

修改建议:在日志字符串中添加 componentId 参数的打印,保持与其他函数日志风格一致。

725: TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT, "Can't get delegate of ace_engine. componentId: %{public}s", componentId.c_str());


likedislike
719- currentIdAndReason.second, Container::CurrentIdSafely());726+ reason, instanceId);
720 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);727 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);
721 napi_close_escapable_handle_scope(env, scope);728 napi_close_escapable_handle_scope(env, scope);
722 return nullptr;729 return nullptr;
@@ -853,11 +860,13 @@ static napi_value JSSnapshotGetWithRange(napi_env env, napi_callback_info info)
853 auto endID = GetNodeIdentity(env, info, 1);860 auto endID = GetNodeIdentity(env, info, 1);
854 bool isStartRect = JudgeRectValue(env, info);861 bool isStartRect = JudgeRectValue(env, info);
855 862 
863+ auto reason = ContainerScope::CurrentIdWithReason().second;
864+ auto instanceId = Container::CurrentIdSafely();
856 auto delegate = EngineHelper::GetCurrentDelegateSafely();865 auto delegate = EngineHelper::GetCurrentDelegateSafely();
857 if (!delegate) {866 if (!delegate) {
858- auto currentIdAndReason = ContainerScope::CurrentIdWithReason();867+ TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT, "Can't get delegate of ace_engine. ");
859 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(868 std::string message = AceEngine::GetEnhancedContextBNotFoundMessage(
860- currentIdAndReason.second, Container::CurrentIdSafely());869+ reason, instanceId);
861 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);870 NapiThrow(env, "Delegate is null. " + message, ERROR_CODE_INTERNAL_ERROR);
862 napi_close_escapable_handle_scope(env, scope);871 napi_close_escapable_handle_scope(env, scope);
863 return result;872 return result;