From 814868c4c5a5cb5176f9f2a61c77509aeb63fb10 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 3 Jun 2025 10:34:45 +0800 Subject: [PATCH] modify log Signed-off-by: zhangzezhong --- .../src/ani_common_ability_result.cpp | 14 +- .../ets/ani/enum_convert/ani_enum_convert.h | 16 +- .../context_native_constructor.cpp | 16 +- .../src/sts_ui_extension.cpp | 14 +- .../ability_runtime/sts_ability_context.cpp | 6 +- .../native/sts_free_install_observer.cpp | 2 +- .../runner_runtime/sts_test_runner.cpp | 4 +- .../runtime/ohos_sts_environment_impl.cpp | 42 ++--- frameworks/native/runtime/sts_runtime.cpp | 146 +++++++++--------- services/common/include/hilog_tag_wrapper.h | 6 +- .../sts_environment/src/sts_environment.cpp | 74 ++++----- 11 files changed, 171 insertions(+), 169 deletions(-) diff --git a/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp b/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp index ad2ecfb3de3..948dcea29d0 100644 --- a/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp +++ b/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp @@ -31,39 +31,39 @@ ani_object WrapAbilityResult(ani_env *env, int32_t resultCode, const AAFwk::Want static const char *className = "Lability/abilityResult/AbilityResultInner;"; if ((status = env->FindClass(className, &cls)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); return nullptr; } if ((status = env->Class_FindMethod(cls, "", nullptr, &ctor)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); return nullptr; } if ((status = env->Object_New(cls, ctor, &result_obj)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); return nullptr; } ani_method resultCodeSetter = nullptr; if ((status = env->Class_FindMethod(cls, "resultCode", nullptr, &resultCodeSetter)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); } ani_double dResultCode {resultCode}; if ((status = env->Object_CallMethod_Void(result_obj, resultCodeSetter, dResultCode)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); return nullptr; } ani_method wantSetter = nullptr; if ((status = env->Class_FindMethod(cls, "want", nullptr, &wantSetter)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); } ani_object wantObj = AppExecFwk::WrapWant(env, want); if ((status = env->Object_CallMethod_Void(result_obj, wantSetter, wantObj)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); return nullptr; } diff --git a/frameworks/ets/ani/enum_convert/ani_enum_convert.h b/frameworks/ets/ani/enum_convert/ani_enum_convert.h index f97d870c4a3..fcdc029d54e 100644 --- a/frameworks/ets/ani/enum_convert/ani_enum_convert.h +++ b/frameworks/ets/ani/enum_convert/ani_enum_convert.h @@ -27,12 +27,12 @@ namespace AniEnumConvertUtil { ani_size sz {}; ani_status status = ANI_ERROR; if ((status = env->String_GetUTF8Size(str, &sz)) != ANI_OK) { - TAG_LOGE(AAFwkTag::JSNAPI, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); return false; } res.resize(sz + 1); if ((status = env->String_GetUTF8SubString(str, 0, sz, res.data(), res.size(), &sz)) != ANI_OK) { - TAG_LOGE(AAFwkTag::JSNAPI, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "status : %{public}d", status); return false; } res.resize(sz); @@ -47,7 +47,7 @@ static bool EnumConvert_StsToNative(ani_env *env, ani_enum_item enumItem, T &res ani_int intValue{}; status = env->EnumItem_GetValue_Int(enumItem, &intValue); if (ANI_OK != status) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "EnumConvert_StsToNative failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "EnumConvert_StsToNative failed, status : %{public}d", status); return false; } result = static_cast(intValue); @@ -56,12 +56,12 @@ static bool EnumConvert_StsToNative(ani_env *env, ani_enum_item enumItem, T &res ani_string strValue{}; status = env->EnumItem_GetValue_String(enumItem, &strValue); if (ANI_OK != status) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "EnumItem_GetValue_String failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ANI, "EnumItem_GetValue_String failed, status : %{public}d", status); return false; } return GetStdString(env, strValue, result); } else { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Enum convert failed: type not supported"); + TAG_LOGE(AAFwkTag::ANI, "Enum convert failed: type not supported"); return false; } } @@ -78,7 +78,7 @@ static bool EnumConvert_NativeToSts(ani_env *env, const char *enumName, const T ani_enum aniEnum{}; ani_status status = env->FindEnum(enumName, &aniEnum); if (ANI_OK != status) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Enum convert FindEnum failed: %{public}s status: %{public}d", enumName, status); + TAG_LOGE(AAFwkTag::ANI, "Enum convert FindEnum failed: %{public}s status: %{public}d", enumName, status); return false; } constexpr int32_t loopMaxNum = 1000; @@ -86,7 +86,7 @@ static bool EnumConvert_NativeToSts(ani_env *env, const char *enumName, const T ani_enum_item enumItem{}; status = env->Enum_GetEnumItemByIndex(aniEnum, index, &enumItem); if (ANI_OK != status) { - TAG_LOGE(AAFwkTag::STSRUNTIME, + TAG_LOGE(AAFwkTag::ANI, "Enum convert Enum_GetEnumItemByIndex failed: enumName:%{public}s index:%{public}d status:%{public}d", enumName, index, status); return false; @@ -98,7 +98,7 @@ static bool EnumConvert_NativeToSts(ani_env *env, const char *enumName, const T return true; } } - TAG_LOGE(AAFwkTag::STSRUNTIME, "EnumConvert_NativeToSts failed enumName: %{public}s", enumName); + TAG_LOGE(AAFwkTag::ANI, "EnumConvert_NativeToSts failed enumName: %{public}s", enumName); return false; } } diff --git a/frameworks/ets/ani/native_constructor/context_native_constructor.cpp b/frameworks/ets/ani/native_constructor/context_native_constructor.cpp index d9475b46268..a462058a30a 100644 --- a/frameworks/ets/ani/native_constructor/context_native_constructor.cpp +++ b/frameworks/ets/ani/native_constructor/context_native_constructor.cpp @@ -35,18 +35,18 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) { ani_env *env; if (vm == nullptr || result == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Illegal VM or result"); + TAG_LOGE(AAFwkTag::CONTEXT, "Illegal VM or result"); return ANI_ERROR; } if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Unsupported ANI_VERSION_1"); + TAG_LOGE(AAFwkTag::CONTEXT, "Unsupported ANI_VERSION_1"); return ANI_ERROR; } // class Context ani_class contextClass; static const char *contextClassName = "Lapplication/Context/Context;"; if (ANI_OK != env->FindClass(contextClassName, &contextClass)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Not found class %{public}s.", contextClassName); + TAG_LOGE(AAFwkTag::CONTEXT, "Not found class %{public}s.", contextClassName); return ANI_NOT_FOUND; } std::array classMethods_context = { @@ -54,14 +54,14 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) }; if (ANI_OK != env->Class_BindNativeMethods(contextClass, classMethods_context.data(), classMethods_context.size())) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Cannot bind native ctor to class %{public}s.", contextClassName); + TAG_LOGE(AAFwkTag::CONTEXT, "Cannot bind native ctor to class %{public}s.", contextClassName); return ANI_ERROR; }; // class ExtensionContext ani_class extensionContextClass; static const char *extensionContextClassName = "Lapplication/ExtensionContext/ExtensionContext;"; if (ANI_OK != env->FindClass(extensionContextClassName, &extensionContextClass)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Not found class %{public}s.", extensionContextClassName); + TAG_LOGE(AAFwkTag::CONTEXT, "Not found class %{public}s.", extensionContextClassName); return ANI_NOT_FOUND; } std::array classMethods_extensionContext = { @@ -69,14 +69,14 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) }; if (ANI_OK != env->Class_BindNativeMethods(extensionContextClass, classMethods_extensionContext.data(), classMethods_extensionContext.size())) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Cannot bind native ctor to class %{public}s.", extensionContextClassName); + TAG_LOGE(AAFwkTag::CONTEXT, "Cannot bind native ctor to class %{public}s.", extensionContextClassName); return ANI_ERROR; }; // class UIAbilityContext ani_class uiAbilityClass; static const char *uiAbilityClassName = "Lapplication/UIAbilityContext/UIAbilityContext;"; if (ANI_OK != env->FindClass(uiAbilityClassName, &uiAbilityClass)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Not found class %{public}s.", uiAbilityClassName); + TAG_LOGE(AAFwkTag::CONTEXT, "Not found class %{public}s.", uiAbilityClassName); return ANI_NOT_FOUND; } std::array classMethods_uiAbility = { @@ -84,7 +84,7 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) }; if (ANI_OK != env->Class_BindNativeMethods(uiAbilityClass, classMethods_uiAbility.data(), classMethods_uiAbility.size())) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Cannot bind native ctor to class %{public}s.", uiAbilityClassName); + TAG_LOGE(AAFwkTag::CONTEXT, "Cannot bind native ctor to class %{public}s.", uiAbilityClassName); return ANI_ERROR; }; diff --git a/frameworks/ets/ani/ui_extension_ability/src/sts_ui_extension.cpp b/frameworks/ets/ani/ui_extension_ability/src/sts_ui_extension.cpp index cc70e0c62ce..0c73505c2f9 100644 --- a/frameworks/ets/ani/ui_extension_ability/src/sts_ui_extension.cpp +++ b/frameworks/ets/ani/ui_extension_ability/src/sts_ui_extension.cpp @@ -150,22 +150,22 @@ std::shared_ptr StsUIExtension::LoadModule(ani_env *env) ani_class cls = nullptr; ani_status status = ANI_ERROR; if ((status = env->FindClass(UIEXTENSION_CLASS_NAME, &cls)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status: %{public}d", status); + TAG_LOGE(AAFwkTag::UI_EXT, "status: %{public}d", status); } ani_method entryMethod = nullptr; if ((status = env->Class_FindMethod(cls, "", ":V", &entryMethod)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status: %{public}d", status); + TAG_LOGE(AAFwkTag::UI_EXT, "status: %{public}d", status); } ani_object entryObject = nullptr; if ((status = env->Object_New(cls, entryMethod, &entryObject)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status: %{public}d", status); + TAG_LOGE(AAFwkTag::UI_EXT, "status: %{public}d", status); } ani_ref entryObjectRef = nullptr; if ((status = env->GlobalReference_Create(entryObject, &entryObjectRef)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status: %{public}d", status); + TAG_LOGE(AAFwkTag::UI_EXT, "status: %{public}d", status); } stsNativeReference->aniCls = cls; stsNativeReference->aniObj = entryObject; @@ -204,19 +204,19 @@ void StsUIExtension::BindContext(ani_env*env, std::shared_ptr want, ani_field contextField; auto status = env->Class_FindField(stsObj_->aniCls, "context", &contextField); if (status != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status: %{public}d", status); + TAG_LOGE(AAFwkTag::UI_EXT, "status: %{public}d", status); ResetEnv(env); return; } ani_ref contextRef = nullptr; if ((status = env->GlobalReference_Create(contextObj, &contextRef)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status: %{public}d", status); + TAG_LOGE(AAFwkTag::UI_EXT, "status: %{public}d", status); return; } if ((status = env->Object_SetField_Ref(stsObj_->aniObj, contextField, contextRef)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status: %{public}d", status); + TAG_LOGE(AAFwkTag::UI_EXT, "status: %{public}d", status); ResetEnv(env); } } diff --git a/frameworks/native/ability/native/ability_runtime/sts_ability_context.cpp b/frameworks/native/ability/native/ability_runtime/sts_ability_context.cpp index 480c7af5bd3..18f8df37eb0 100644 --- a/frameworks/native/ability/native/ability_runtime/sts_ability_context.cpp +++ b/frameworks/native/ability/native/ability_runtime/sts_ability_context.cpp @@ -257,7 +257,7 @@ void StsAbilityContext::AddFreeInstallObserver( ani_vm *etsVm = nullptr; ani_status status = ANI_ERROR; if ((status = env->GetVM(&etsVm)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::CONTEXT, "status : %{public}d", status); } freeInstallObserver_ = new StsFreeInstallObserver(etsVm); ret = context->AddFreeInstallObserver(freeInstallObserver_); @@ -365,7 +365,7 @@ void StsAbilityContext::StartAbilityForResultInner(ani_env *env, ani_object aniO ani_vm *etsVm = nullptr; ani_status status = ANI_ERROR; if ((status = env->GetVM(&etsVm)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::CONTEXT, "status : %{public}d", status); return; } RuntimeTask task = [etsVm, callbackRef, element = want.GetElement(), flags = want.GetFlags(), startTime] @@ -374,7 +374,7 @@ void StsAbilityContext::StartAbilityForResultInner(ani_env *env, ani_object aniO ani_status status = ANI_ERROR; ani_env *env = nullptr; if ((status = etsVm->GetEnv(ANI_VERSION_1, &env)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::CONTEXT, "status : %{public}d", status); return; } std::string bundleName = element.GetBundleName(); diff --git a/frameworks/native/ability/native/sts_free_install_observer.cpp b/frameworks/native/ability/native/sts_free_install_observer.cpp index ab8c65e1f9b..67202081709 100644 --- a/frameworks/native/ability/native/sts_free_install_observer.cpp +++ b/frameworks/native/ability/native/sts_free_install_observer.cpp @@ -75,7 +75,7 @@ void StsFreeInstallObserver::CallCallback(ani_object callback, int32_t resultCod ani_option interopEnabled { "--interop=disable", nullptr }; ani_options aniArgs { 1, &interopEnabled }; if ((etsVm_->AttachCurrentThread(&aniArgs, ANI_VERSION_1, &env)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "status : %{public}d", status); + TAG_LOGE(AAFwkTag::FREE_INSTALL, "status : %{public}d", status); } AsyncCallback(env, callback, WrapBusinessError(env, resultCode), nullptr); } diff --git a/frameworks/native/appkit/ability_delegator/runner_runtime/sts_test_runner.cpp b/frameworks/native/appkit/ability_delegator/runner_runtime/sts_test_runner.cpp index a3124f34e15..60a75550ce7 100644 --- a/frameworks/native/appkit/ability_delegator/runner_runtime/sts_test_runner.cpp +++ b/frameworks/native/appkit/ability_delegator/runner_runtime/sts_test_runner.cpp @@ -124,7 +124,7 @@ void STSTestRunner::Prepare() TAG_LOGI(AAFwkTag::DELEGATOR, "use stsTestRunnerObj_"); auto env = stsRuntime_.GetAniEnv(); if (env->ResetError() != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "ResetError failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "ResetError failed"); } ani_method method; ani_status status = ANI_ERROR; @@ -152,7 +152,7 @@ void STSTestRunner::Run() TAG_LOGI(AAFwkTag::DELEGATOR, "use stsTestRunnerObj_"); auto env = stsRuntime_.GetAniEnv(); if (env->ResetError() != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "ResetError failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "ResetError failed"); } ani_method method; ani_status status = ANI_ERROR; diff --git a/frameworks/native/runtime/ohos_sts_environment_impl.cpp b/frameworks/native/runtime/ohos_sts_environment_impl.cpp index 7967a7c2aaf..8b060c3720b 100644 --- a/frameworks/native/runtime/ohos_sts_environment_impl.cpp +++ b/frameworks/native/runtime/ohos_sts_environment_impl.cpp @@ -25,16 +25,16 @@ namespace { void OHOSStsEnvironmentImpl::PostTaskToHandler(const char* taskName, uv_io_cb func, void* work, int status, int priority) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (!func || !work) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Invalid parameters"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Invalid parameters"); return; } auto task = [func, work, status]() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "Do uv work"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "Do uv work"); func(work, status); - TAG_LOGD(AAFwkTag::STSRUNTIME, "Do uv work end"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "Do uv work end"); }; AppExecFwk::EventQueue::Priority prio = AppExecFwk::EventQueue::Priority::IMMEDIATE; @@ -54,21 +54,21 @@ void OHOSStsEnvironmentImpl::PostTaskToHandler(const char* taskName, uv_io_cb fu } if (g_eventHandler == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Invalid parameters"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Invalid parameters"); return; } g_eventHandler->PostTask(task, "uv_io_cb", 0, prio); } OHOSStsEnvironmentImpl::OHOSStsEnvironmentImpl() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); } OHOSStsEnvironmentImpl::OHOSStsEnvironmentImpl(const std::shared_ptr& eventRunner) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (eventRunner != nullptr) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "Create event handler"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "Create event handler"); eventHandler_ = std::make_shared(eventRunner); if (eventRunner.get() == AppExecFwk::EventRunner::GetMainEventRunner().get()) { g_eventHandler = std::make_shared(eventRunner); @@ -78,12 +78,12 @@ OHOSStsEnvironmentImpl::OHOSStsEnvironmentImpl(const std::shared_ptr& task, const std::string& name, int64_t delayTime) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (eventHandler_ != nullptr) { eventHandler_->PostTask(task, name, delayTime); } @@ -91,7 +91,7 @@ void OHOSStsEnvironmentImpl::PostTask(const std::function& task, const s void OHOSStsEnvironmentImpl::PostSyncTask(const std::function& task, const std::string& name) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (eventHandler_ != nullptr) { eventHandler_->PostSyncTask(task, name); } @@ -99,7 +99,7 @@ void OHOSStsEnvironmentImpl::PostSyncTask(const std::function& task, con void OHOSStsEnvironmentImpl::RemoveTask(const std::string& name) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (eventHandler_ != nullptr) { eventHandler_->RemoveTask(name); } @@ -107,21 +107,21 @@ void OHOSStsEnvironmentImpl::RemoveTask(const std::string& name) bool OHOSStsEnvironmentImpl::InitLoop(bool isStage) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); loop_ = new (std::nothrow)uv_loop_t; if (loop_ == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "failed to create uv_loop, async task interface would not work"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "failed to create uv_loop, async task interface would not work"); return false; } if (uv_loop_init(loop_) != ERR_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "failed to init uv_loop, async task interface would not work"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "failed to init uv_loop, async task interface would not work"); delete loop_; loop_ = nullptr; return false; } auto fd = loop_ != nullptr ? uv_backend_fd(loop_) : -1; if (fd < 0) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "get fd failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "get fd failed"); return false; } uv_run(loop_, UV_RUN_NOWAIT); @@ -129,7 +129,7 @@ bool OHOSStsEnvironmentImpl::InitLoop(bool isStage) if (eventHandler_ != nullptr) { uint32_t events = AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT | AppExecFwk::FILE_DESCRIPTOR_OUTPUT_EVENT; eventHandler_->AddFileDescriptorListener(fd, events, std::make_shared(loop_), "uvLoopTask"); - TAG_LOGD(AAFwkTag::STSRUNTIME, "uv_register_task_to_event, isStage: %{public}d", isStage); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "uv_register_task_to_event, isStage: %{public}d", isStage); if (isStage && (eventHandler_->GetEventRunner()).get() == AppExecFwk::EventRunner::GetMainEventRunner().get()) { uv_register_task_to_event(loop_, PostTaskToHandler, nullptr); } @@ -140,7 +140,7 @@ bool OHOSStsEnvironmentImpl::InitLoop(bool isStage) void OHOSStsEnvironmentImpl::DeInitLoop() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); auto fd = loop_ != nullptr ? uv_backend_fd(loop_) : -1; if (fd >= 0 && eventHandler_ != nullptr) { eventHandler_->RemoveFileDescriptorListener(fd); @@ -151,7 +151,7 @@ void OHOSStsEnvironmentImpl::DeInitLoop() bool OHOSStsEnvironmentImpl::ReInitUVLoop() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (loop_ != nullptr) { delete loop_; loop_ = nullptr; @@ -159,11 +159,11 @@ bool OHOSStsEnvironmentImpl::ReInitUVLoop() loop_ = new (std::nothrow)uv_loop_t; if (loop_ == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "failed to create uv_loop, async task interface would not work"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "failed to create uv_loop, async task interface would not work"); return false; } if (uv_loop_init(loop_) != ERR_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "failed to init uv_loop, async task interface would not work"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "failed to init uv_loop, async task interface would not work"); delete loop_; loop_ = nullptr; return false; diff --git a/frameworks/native/runtime/sts_runtime.cpp b/frameworks/native/runtime/sts_runtime.cpp index bb1b3b11d9d..6e3f9510ccb 100644 --- a/frameworks/native/runtime/sts_runtime.cpp +++ b/frameworks/native/runtime/sts_runtime.cpp @@ -98,41 +98,41 @@ public: std::ifstream inFile; inFile.open(ENTRY_PATH_MAP_FILE, std::ios::in); if (!inFile.is_open()) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "no entrypath file"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "no entrypath file"); return false; } nlohmann::json filePathsJson; inFile >> filePathsJson; if (filePathsJson.is_discarded()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "json discarded error"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "json discarded error"); inFile.close(); return false; } if (filePathsJson.is_null() || filePathsJson.empty()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "invalid json"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "invalid json"); inFile.close(); return false; } if (!filePathsJson.contains(ENTRY_PATH_MAP_KEY)) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "no entrypath key"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "no entrypath key"); return false; } const auto &entryPathMap = filePathsJson[ENTRY_PATH_MAP_KEY]; if (!entryPathMap.is_object()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "entrypath is not object"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "entrypath is not object"); return false; } for (const auto &entryPath: entryPathMap.items()) { std::string key = entryPath.key(); if (!entryPath.value().is_string()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "val is not string, key: %{public}s", key.c_str()); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "val is not string, key: %{public}s", key.c_str()); continue; } std::string val = entryPath.value(); - TAG_LOGD(AAFwkTag::STSRUNTIME, "key: %{public}s, value: %{public}s", key.c_str(), val.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "key: %{public}s, value: %{public}s", key.c_str(), val.c_str()); entryPathMap_.emplace(key, val); } inFile.close(); @@ -144,13 +144,13 @@ public: auto const &iter = entryPathMap_.find(srcEntry); if (iter == entryPathMap_.end()) { if (StartsWithDotSlash(srcEntry)) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "not found srcEntry: %{public}s", srcEntry.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "not found srcEntry: %{public}s", srcEntry.c_str()); return DEFAULT_ENTRY_ABILITY_CLASS; } - TAG_LOGD(AAFwkTag::STSRUNTIME, "srcEntry as class: %{public}s", srcEntry.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "srcEntry as class: %{public}s", srcEntry.c_str()); return HandleOhmUrlSrcEntry(srcEntry); } - TAG_LOGD(AAFwkTag::STSRUNTIME, "found srcEntry: %{public}s, output: %{public}s", + TAG_LOGD(AAFwkTag::ETSRUNTIME, "found srcEntry: %{public}s, output: %{public}s", srcEntry.c_str(), iter->second.c_str()); return iter->second; } @@ -206,7 +206,7 @@ AbilityRuntime::JsRuntime* STSRuntime::jsRuntime_ = nullptr; std::unique_ptr STSRuntime::Create(const Options& options, Runtime* jsRuntime) { STSRuntime::jsRuntime_ = static_cast(jsRuntime); - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); std::unique_ptr instance; // JsRuntimeLite::InitJsRuntimeLite(options); if (!options.preload && options.isStageModel) { @@ -236,11 +236,11 @@ std::unique_ptr STSRuntime::Create(const Options& options, Runtime* void STSRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); std::string appPath = ""; for (const auto& kv : appLibPaths) { for (const auto& libPath : kv.second) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "SetSTSAppLibPath: %{public}s.", libPath.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "SetSTSAppLibPath: %{public}s.", libPath.c_str()); STSRuntime::appLibPaths_.emplace_back(libPath); appPath += appPath.empty() ? libPath : ":" + libPath; } @@ -254,9 +254,9 @@ void STSRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths) bool STSRuntime::Initialize(const Options& options) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (options.lang != GetLanguage()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "language mismatch"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "language mismatch"); return false; } @@ -268,22 +268,22 @@ bool STSRuntime::Initialize(const Options& options) if (!preloaded_) { if (!CreateStsEnv(options)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Create stsEnv failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Create stsEnv failed"); return false; } } apiTargetVersion_ = options.apiTargetVersion; - TAG_LOGD(AAFwkTag::STSRUNTIME, "Initialize: %{public}d", apiTargetVersion_); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "Initialize: %{public}d", apiTargetVersion_); if (options.isStageModel || options.isTestFramework) { if (preloaded_) { PostPreload(options); } if (!preloaded_) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "PreloadAce start"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "PreloadAce start"); PreloadAce(options); - TAG_LOGD(AAFwkTag::STSRUNTIME, "PreloadAce end"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "PreloadAce end"); } if (!options.preload) { @@ -303,14 +303,14 @@ bool STSRuntime::Initialize(const Options& options) if (!options.preload) { if (options.isUnique) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "Not supported TimerModule when form render"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "Not supported TimerModule when form render"); } else { InitTimerModule(); } SetModuleLoadChecker(options.moduleCheckerDelegate); if (!stsEnv_->InitLoop(options.isStageModel)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Init loop failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Init loop failed"); return false; } } @@ -320,7 +320,7 @@ bool STSRuntime::Initialize(const Options& options) bool STSRuntime::LoadSTSAppLibrary(const AppLibPathVec& appLibPaths) { if (stsEnv_ == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "null stsEnv_"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "null stsEnv_"); return false; } @@ -335,7 +335,7 @@ void STSRuntime::StartDebugMode(const DebugOption dOption) bool STSRuntime::StartDebugger() { if (stsEnv_ == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "null stsEnv_"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "null stsEnv_"); return false; } return stsEnv_->StartDebugger(); @@ -343,18 +343,18 @@ bool STSRuntime::StartDebugger() void STSRuntime::UnLoadSTSAppLibrary() { - TAG_LOGI(AAFwkTag::STSRUNTIME, "UnLoadSTSAppLibrary not support yet"); + TAG_LOGI(AAFwkTag::ETSRUNTIME, "UnLoadSTSAppLibrary not support yet"); } void STSRuntime::RegisterUncaughtExceptionHandler(void* uncaughtExceptionInfo) { if (stsEnv_ == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "null stsEnv_"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "null stsEnv_"); return; } if (uncaughtExceptionInfo == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "null uncaughtExceptionInfo"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "null uncaughtExceptionInfo"); return; } @@ -366,13 +366,13 @@ void STSRuntime::RegisterUncaughtExceptionHandler(void* uncaughtExceptionInfo) STSRuntime::~STSRuntime() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); Deinitialize(); } void STSRuntime::PostTask(const std::function& task, const std::string& name, int64_t delayTime) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (stsEnv_ != nullptr) { stsEnv_->PostTask(task, name, delayTime); } @@ -380,7 +380,7 @@ void STSRuntime::PostTask(const std::function& task, const std::string& void STSRuntime::PostSyncTask(const std::function& task, const std::string& name) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (stsEnv_ != nullptr) { stsEnv_->PostSyncTask(task, name); } @@ -388,7 +388,7 @@ void STSRuntime::PostSyncTask(const std::function& task, const std::stri void STSRuntime::RemoveTask(const std::string& name) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (stsEnv_ != nullptr) { stsEnv_->RemoveTask(name); } @@ -396,7 +396,7 @@ void STSRuntime::RemoveTask(const std::string& name) void STSRuntime::Deinitialize() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); for (auto it = modules_.begin(); it != modules_.end(); it = modules_.erase(it)) { delete it->second; it->second = nullptr; @@ -409,7 +409,7 @@ void STSRuntime::Deinitialize() bool STSRuntime::CreateStsEnv(const Options& options) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); stsEnv_ = std::make_shared(std::make_unique(options.eventRunner)); std::vector aniOptions; @@ -418,12 +418,12 @@ bool STSRuntime::CreateStsEnv(const Options& options) std::string aotFilePath = SANDBOX_ARK_CACHE_PATH + options.arkNativeFilePath + options.moduleName + ".an"; aotFileString = "--ext:--aot-file=" + aotFilePath; aniOptions.push_back(ani_option{aotFileString.c_str(), nullptr}); - TAG_LOGI(AAFwkTag::STSRUNTIME, "aotFileString: %{public}s", aotFileString.c_str()); + TAG_LOGI(AAFwkTag::ETSRUNTIME, "aotFileString: %{public}s", aotFileString.c_str()); aniOptions.push_back(ani_option{"--ext:--enable-an", nullptr}); } if (stsEnv_ == nullptr || !stsEnv_->StartRuntime(STSRuntime::jsRuntime_->GetNapiEnv(), aniOptions)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Init StsEnv failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Init StsEnv failed"); return false; } @@ -432,12 +432,12 @@ bool STSRuntime::CreateStsEnv(const Options& options) void STSRuntime::PreloadAce(const Options& options) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); } void STSRuntime::ReInitStsEnvImpl(const Options& options) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (stsEnv_ == nullptr) { return; } @@ -446,7 +446,7 @@ void STSRuntime::ReInitStsEnvImpl(const Options& options) void STSRuntime::LoadAotFile(const Options& options) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (options.hapPath.empty()) { return; } @@ -460,18 +460,18 @@ void STSRuntime::LoadAotFile(const Options& options) void STSRuntime::InitConsoleModule() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); // need vm support Console } void STSRuntime::InitTimerModule() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); } void STSRuntime::ReInitUVLoop() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (stsEnv_ == nullptr) { return; } @@ -480,7 +480,7 @@ void STSRuntime::ReInitUVLoop() void STSRuntime::PostPreload(const Options& options) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); // need vm support Preload ReInitUVLoop(); } @@ -488,7 +488,7 @@ void STSRuntime::PostPreload(const Options& options) ani_env* STSRuntime::GetAniEnv() { if (stsEnv_ == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "null stsEnv_"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "null stsEnv_"); return nullptr; } return stsEnv_->GetAniEnv(); @@ -497,50 +497,50 @@ ani_env* STSRuntime::GetAniEnv() void STSRuntime::PreloadModule(const std::string& moduleName, const std::string& hapPath, bool isEsMode, bool useCommonTrunk) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "moduleName: %{public}s", moduleName.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "moduleName: %{public}s", moduleName.c_str()); ani_env* aniEnv = GetAniEnv(); if (aniEnv == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "GetAniEnv failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "GetAniEnv failed"); return; } ani_class stringCls = nullptr; if (aniEnv->FindClass("Lstd/core/String;", &stringCls) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "FindClass Lstd/core/String Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "FindClass Lstd/core/String Failed"); return; } std::string modulePath = BUNDLE_INSTALL_PATH + moduleName + MERGE_ABC_PATH; ani_string ani_str; if (aniEnv->String_NewUTF8(modulePath.c_str(), modulePath.size(), &ani_str) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "String_NewUTF8 modulePath Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "String_NewUTF8 modulePath Failed"); return; } ani_ref undefined_ref; if (aniEnv->GetUndefined(&undefined_ref) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "GetUndefined failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "GetUndefined failed"); return; } ani_array_ref refArray; if (aniEnv->Array_New_Ref(stringCls, 1, undefined_ref, &refArray) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Array_New_Ref Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Array_New_Ref Failed"); return; } if (aniEnv->Array_Set_Ref(refArray, 0, ani_str) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Array_Set_Ref Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Array_Set_Ref Failed"); return; } ani_class cls = nullptr; if (aniEnv->FindClass("Lstd/core/AbcRuntimeLinker;", &cls) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "FindClass AbcRuntimeLinker failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "FindClass AbcRuntimeLinker failed"); return; } ani_method method = nullptr; if (aniEnv->Class_FindMethod(cls, "", "Lstd/core/RuntimeLinker;[Lstd/core/String;:V", &method) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Class_FindMethod ctor failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Class_FindMethod ctor failed"); return; } ani_object object = nullptr; if (aniEnv->Object_New(cls, method, &object, undefined_ref, refArray) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Object_New AbcRuntimeLinker failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Object_New AbcRuntimeLinker failed"); } } @@ -548,7 +548,7 @@ std::unique_ptr STSRuntime::LoadModule(const std::string& mo const std::string& modulePath, const std::string& hapPath, bool esmodule, bool useCommonChunk, const std::string& srcEntrance) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "Load module(%{public}s, %{public}s, %{public}s, %{public}s)", + TAG_LOGD(AAFwkTag::ETSRUNTIME, "Load module(%{public}s, %{public}s, %{public}s, %{public}s)", moduleName.c_str(), modulePath.c_str(), hapPath.c_str(), esmodule ? "true" : "false"); std::string path = moduleName; @@ -557,7 +557,7 @@ std::unique_ptr STSRuntime::LoadModule(const std::string& mo path.erase(pos, path.size() - pos); moduleName_ = path; } - TAG_LOGD(AAFwkTag::STSRUNTIME, "moduleName_(%{public}s, path %{public}s", + TAG_LOGD(AAFwkTag::ETSRUNTIME, "moduleName_(%{public}s, path %{public}s", moduleName_.c_str(), path.c_str()); std::string fileName; @@ -567,7 +567,7 @@ std::unique_ptr STSRuntime::LoadModule(const std::string& mo fileName = std::regex_replace(fileName, pattern, ""); } else { if (!MakeFilePath(codePath_, modulePath, fileName)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "make module file path: %{public}s failed", modulePath.c_str()); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "make module file path: %{public}s failed", modulePath.c_str()); return nullptr; } } @@ -579,63 +579,63 @@ std::unique_ptr STSRuntime::LoadStsModule(const std::string const std::string &path, const std::string &hapPath, const std::string &srcEntrance) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "Load sts module(%{public}s, %{public}s, %{public}s, %{public}s)", + TAG_LOGD(AAFwkTag::ETSRUNTIME, "Load sts module(%{public}s, %{public}s, %{public}s, %{public}s)", moduleName.c_str(), path.c_str(), hapPath.c_str(), srcEntrance.c_str()); auto stsNativeReference = std::make_unique(); ani_env* aniEnv = GetAniEnv(); if (aniEnv == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "GetAniEnv failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "GetAniEnv failed"); return std::make_unique(); } ani_class stringCls = nullptr; if (aniEnv->FindClass("Lstd/core/String;", &stringCls) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "FindClass Lstd/core/String Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "FindClass Lstd/core/String Failed"); return std::make_unique(); } std::string modulePath = BUNDLE_INSTALL_PATH + moduleName_ + MERGE_ABC_PATH; ani_string ani_str; if (aniEnv->String_NewUTF8(modulePath.c_str(), modulePath.size(), &ani_str) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "String_NewUTF8 modulePath Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "String_NewUTF8 modulePath Failed"); return std::make_unique(); } ani_ref undefined_ref; if (aniEnv->GetUndefined(&undefined_ref) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "GetUndefined failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "GetUndefined failed"); return std::make_unique(); } ani_array_ref refArray; if (aniEnv->Array_New_Ref(stringCls, 1, undefined_ref, &refArray) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Array_New_Ref Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Array_New_Ref Failed"); return std::make_unique(); } if (aniEnv->Array_Set_Ref(refArray, 0, ani_str) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Array_Set_Ref Failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Array_Set_Ref Failed"); return std::make_unique(); } ani_class cls = nullptr; if (aniEnv->FindClass("Lstd/core/AbcRuntimeLinker;", &cls) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "FindClass AbcRuntimeLinker failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "FindClass AbcRuntimeLinker failed"); return std::make_unique(); } ani_method method = nullptr; if (aniEnv->Class_FindMethod(cls, "", "Lstd/core/RuntimeLinker;[Lstd/core/String;:V", &method) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Class_FindMethod ctor failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Class_FindMethod ctor failed"); return std::make_unique(); } ani_object object = nullptr; aniEnv->ResetError(); if (aniEnv->Object_New(cls, method, &object, undefined_ref, refArray) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Object_New AbcRuntimeLinker failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Object_New AbcRuntimeLinker failed"); HandleUncaughtError(); return std::make_unique(); } ani_method loadClassMethod = nullptr; if (aniEnv->Class_FindMethod(cls, "loadClass", nullptr, &loadClassMethod) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Class_FindMethod loadClass failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Class_FindMethod loadClass failed"); return std::make_unique(); } std::string entryPath = EntryPathManager::GetInstance().GetEntryPath(srcEntrance); @@ -644,9 +644,9 @@ std::unique_ptr STSRuntime::LoadStsModule(const std::string ani_class entryClass = nullptr; ani_ref entryClassRef = nullptr; ani_boolean isInit = false; - TAG_LOGI(AAFwkTag::STSRUNTIME, "load class: %{public}s", entryPath.c_str()); + TAG_LOGI(AAFwkTag::ETSRUNTIME, "load class: %{public}s", entryPath.c_str()); if (aniEnv->Object_CallMethod_Ref(object, loadClassMethod, &entryClassRef, entryClassStr, isInit) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Object_CallMethod_Ref loadClassMethod failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Object_CallMethod_Ref loadClassMethod failed"); return std::make_unique(); } else { entryClass = static_cast(entryClassRef); @@ -654,19 +654,19 @@ std::unique_ptr STSRuntime::LoadStsModule(const std::string ani_method entryMethod = nullptr; if (aniEnv->Class_FindMethod(entryClass, "", ":V", &entryMethod) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Class_FindMethod ctor failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Class_FindMethod ctor failed"); return std::make_unique(); } ani_object entryObject = nullptr; if (aniEnv->Object_New(entryClass, entryMethod, &entryObject) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Object_New AbcRuntimeLinker failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Object_New AbcRuntimeLinker failed"); return std::make_unique(); } ani_ref entryObjectRef = nullptr; if (aniEnv->GlobalReference_Create(entryObject, &entryObjectRef) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "GlobalReference_Create failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "GlobalReference_Create failed"); return std::make_unique(); } stsNativeReference->aniCls = entryClass; @@ -682,14 +682,14 @@ bool STSRuntime::RunScript(ani_env *aniEnv, const std::string &moduleName, { bool newCreate = false; std::string loadPath = ExtractorUtil::GetLoadFilePath(hapPath); - TAG_LOGE(AAFwkTag::STSRUNTIME, "hapPath[%{public}s], loadPath:%{public}s", hapPath.c_str(), loadPath.c_str()); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "hapPath[%{public}s], loadPath:%{public}s", hapPath.c_str(), loadPath.c_str()); // need vm support Aot. return true; } void STSRuntime::HandleUncaughtError() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); if (stsEnv_ == nullptr) { return; } diff --git a/services/common/include/hilog_tag_wrapper.h b/services/common/include/hilog_tag_wrapper.h index 7cfcc081750..3ed7c5c889a 100644 --- a/services/common/include/hilog_tag_wrapper.h +++ b/services/common/include/hilog_tag_wrapper.h @@ -58,7 +58,8 @@ enum class AAFwkLogTag : uint32_t { INTENT, JSNAPI, CJRUNTIME, - STSRUNTIME, + ETSRUNTIME, + ANI, DELEGATOR = DEFAULT + 0x30, // 0xD001330 CONTEXT, @@ -128,7 +129,8 @@ inline const char* GetDomainName1(AAFwkLogTag tag) inline const char* GetDomainName2(AAFwkLogTag tag) { - const char* tagNames[] = { "JsEnv", "JsRuntime", "FA", "Intent", "JsNapi" }; + const char* tagNames[] = { "JsEnv", "JsRuntime", "FA", "Intent", "JsNapi", "CjRuntime", "EtsRuntime", + "Ani" }; uint32_t offset = GetOffset(tag, AAFwkLogTag::JSENV); if (offset >= sizeof(tagNames) / sizeof(const char*)) { return "UN"; diff --git a/sts_environment/frameworks/sts_environment/src/sts_environment.cpp b/sts_environment/frameworks/sts_environment/src/sts_environment.cpp index b1f8b073ca2..39c6075da48 100644 --- a/sts_environment/frameworks/sts_environment/src/sts_environment.cpp +++ b/sts_environment/frameworks/sts_environment/src/sts_environment.cpp @@ -64,18 +64,18 @@ bool STSEnvironment::LoadBootPathFile(std::string& bootfiles) std::ifstream inFile; inFile.open(BOOT_PATH, std::ios::in); if (!inFile.is_open()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "read json error"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "read json error"); return false; } nlohmann::json jsonObject = nlohmann::json::parse(inFile); if (jsonObject.is_discarded()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "json discarded error"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "json discarded error"); inFile.close(); return false; } if (jsonObject.is_null() || jsonObject.empty()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "invalid json"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "invalid json"); inFile.close(); return false; } @@ -84,7 +84,7 @@ bool STSEnvironment::LoadBootPathFile(std::string& bootfiles) if (!value.is_null() && value.is_string()) { std::string jsonValue = value.get(); if (jsonValue.empty()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "json value of %{public}s is empty", key.c_str()); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "json value of %{public}s is empty", key.c_str()); continue; } if (!bootfiles.empty()) { @@ -108,7 +108,7 @@ bool STSEnvironment::LoadRuntimeApis() dlns_get(STSEnvironment::stsSDKNSName, &ns); auto dso = DynamicLoadLibrary(&ns, STS_LIB_PATH, 1); if (!dso) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "load library failed: %{public}s", STS_LIB_PATH); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "load library failed: %{public}s", STS_LIB_PATH); return false; } @@ -116,7 +116,7 @@ bool STSEnvironment::LoadRuntimeApis() !LoadSymbolGetCreatedVMs(dso, lazyApis_) || !LoadSymbolCreateVM(dso, lazyApis_) || !LoadSymbolANIGetCreatedVMs(dso, lazyApis_)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "load symbol failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "load symbol failed"); return false; } @@ -149,7 +149,7 @@ std::string STSEnvironment::GetBuildId(std::string stack) void STSEnvironment::RegisterUncaughtExceptionHandler(const STSUncaughtExceptionInfo& handle) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); uncaughtExceptionInfo_ = handle; } @@ -162,7 +162,7 @@ bool STSEnvironment::LoadSymbolGetDefaultVMInitArgs(void* handle, STSRuntimeAPI& { auto symbol = dlsym(handle, STS_GET_DEFAULT_VM_INIT_ARGS); if (symbol == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "runtime api not found: %{public}s", STS_GET_DEFAULT_VM_INIT_ARGS); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "runtime api not found: %{public}s", STS_GET_DEFAULT_VM_INIT_ARGS); return false; } apis.ETS_GetDefaultVMInitArgs = reinterpret_cast(symbol); @@ -174,7 +174,7 @@ bool STSEnvironment::LoadSymbolGetCreatedVMs(void* handle, STSRuntimeAPI& apis) { auto symbol = dlsym(handle, STS_GET_CREATED_VMS); if (symbol == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "runtime api not found: %{public}s", STS_GET_CREATED_VMS); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "runtime api not found: %{public}s", STS_GET_CREATED_VMS); return false; } apis.ETS_GetCreatedVMs = reinterpret_cast(symbol); @@ -186,7 +186,7 @@ bool STSEnvironment::LoadSymbolCreateVM(void* handle, STSRuntimeAPI& apis) { auto symbol = dlsym(handle, STS_CREATE_VM); if (symbol == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "runtime api not found: %{public}s", STS_CREATE_VM); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "runtime api not found: %{public}s", STS_CREATE_VM); return false; } apis.ANI_CreateVM = reinterpret_cast(symbol); @@ -198,7 +198,7 @@ bool STSEnvironment::LoadSymbolANIGetCreatedVMs(void* handle, STSRuntimeAPI& api { auto symbol = dlsym(handle, STS_ANI_GET_CREATEDVMS); if (symbol == nullptr) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "runtime api not found: %{public}s", STS_ANI_GET_CREATEDVMS); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "runtime api not found: %{public}s", STS_ANI_GET_CREATEDVMS); return false; } apis.ANI_GetCreatedVMs = reinterpret_cast(symbol); @@ -208,7 +208,7 @@ bool STSEnvironment::LoadSymbolANIGetCreatedVMs(void* handle, STSRuntimeAPI& api void STSEnvironment::InitSTSChipSDKNS(const ::std::string& path) { - LOGI("InitSTSChipSDKNS: %{public}s", path.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "InitSTSChipSDKNS: %{public}s", path.c_str()); Dl_namespace chip_ndk; DynamicInitNamespace(&chip_ndk, nullptr, path.c_str(), STSEnvironment::stsChipSDKNSName); @@ -222,7 +222,7 @@ void STSEnvironment::InitSTSChipSDKNS(const ::std::string& path) void STSEnvironment::InitSTSAppNS(const std::string& path) { - LOGI("InitSTSAppNS: %{public}s", path.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "InitSTSAppNS: %{public}s", path.c_str()); Dl_namespace ndk; Dl_namespace ns; DynamicInitNamespace(&ns, nullptr, path.c_str(), STSEnvironment::stsAppNSName); @@ -236,7 +236,7 @@ void STSEnvironment::InitSTSAppNS(const std::string& path) void STSEnvironment::InitSTSSDKNS(const std::string& path) { - LOGI("InitSTSSDKNS: %{public}s", path.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "InitSTSSDKNS: %{public}s", path.c_str()); Dl_namespace sts_app; Dl_namespace ns; dlns_get(STSEnvironment::stsAppNSName, &sts_app); @@ -245,7 +245,7 @@ void STSEnvironment::InitSTSSDKNS(const std::string& path) void STSEnvironment::InitSTSSysNS(const std::string& path) { - LOGI("InitSTSSysNS: %{public}s", path.c_str()); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "InitSTSSysNS: %{public}s", path.c_str()); Dl_namespace sts_sdk; Dl_namespace ndk; Dl_namespace ns; @@ -257,24 +257,24 @@ void STSEnvironment::InitSTSSysNS(const std::string& path) bool STSEnvironment::StartRuntime(napi_env napiEnv, std::vector& options) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "StartRuntime call"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "StartRuntime call"); if (isRuntimeStarted_) { return true; } if (!LoadRuntimeApis()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "LoadRuntimeApis failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "LoadRuntimeApis failed"); return false; } std::string bootfiles; if (!LoadBootPathFile(bootfiles)) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "LoadBootPathFile failed"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "LoadBootPathFile failed"); return false; } const std::string optionPrefix = "--ext:"; // Create boot-panda-files options std::string bootString = optionPrefix + "--boot-panda-files=" + bootfiles; - TAG_LOGI(AAFwkTag::STSRUNTIME, "bootString %{public}s", bootString.c_str()); + TAG_LOGI(AAFwkTag::ETSRUNTIME, "bootString %{public}s", bootString.c_str()); options.push_back(ani_option{bootString.c_str(), nullptr}); std::string schedulingExternal = optionPrefix + "--coroutine-enable-external-scheduling=true"; ani_option schedulingExternalOption = {schedulingExternal.data(), nullptr}; @@ -301,7 +301,7 @@ bool STSEnvironment::StartRuntime(napi_env napiEnv, std::vector& opt ani_options optionsPtr = {options.size(), options.data()}; auto status = lazyApis_.ANI_CreateVM(&optionsPtr, ANI_VERSION_1, &vmEntry_.ani_vm); if (status != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "ANI_CreateVM failed %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "ANI_CreateVM failed %{public}d", status); return false; } ani_size nrVMs; @@ -392,7 +392,7 @@ void STSEnvironment::DeInitLoop() bool STSEnvironment::ReInitUVLoop() { - LOGI("ReInitUVLoop"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "ReInitUVLoop called"); if (impl_ != nullptr) { return impl_->ReInitUVLoop(); } @@ -401,7 +401,7 @@ bool STSEnvironment::ReInitUVLoop() void STSEnvironment::ReInitStsEnvImpl(std::unique_ptr impl) { - LOGI("ReInit stsenv impl"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "ReInitStsEnvImpl called"); impl_ = std::move(impl); } @@ -412,14 +412,14 @@ ani_env* STSEnvironment::GetAniEnv() void STSEnvironment::HandleUncaughtError() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); const StsEnv::STSErrorObject errorObj = GetSTSErrorObject(); std::string errorStack = errorObj.stack; if (errorStack.empty()) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "errorStack is empty"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "errorStack is empty"); return; } - TAG_LOGE(AAFwkTag::STSRUNTIME, "errorObj.name:%{public}s, errorObj.message:%{public}s,errorObj.stack:%{public}s", + TAG_LOGE(AAFwkTag::ETSRUNTIME, "errorObj.name:%{public}s, errorObj.message:%{public}s,errorObj.stack:%{public}s", errorObj.name.c_str(), errorObj.message.c_str(), errorObj.stack.c_str()); std::string summary = "Error name:" + errorObj.name + "\n"; summary += "Error message:" + errorObj.message + "\n"; @@ -435,32 +435,32 @@ void STSEnvironment::HandleUncaughtError() } #endif // SUPPORT_GRAPHICS if (uncaughtExceptionInfo_.uncaughtTask) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "uncaughtTask called"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "uncaughtTask called"); uncaughtExceptionInfo_.uncaughtTask(summary, errorObj); } } StsEnv::STSErrorObject STSEnvironment::GetSTSErrorObject() { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); ani_boolean errorExists = ANI_FALSE; ani_status status = ANI_ERROR; auto aniEnv = GetAniEnv(); if ((status = aniEnv->ExistUnhandledError(&errorExists)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "ExistUnhandledError failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "ExistUnhandledError failed, status : %{public}d", status); return StsEnv::STSErrorObject(); } if (errorExists == ANI_FALSE) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "not exist error"); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "not exist error"); return StsEnv::STSErrorObject(); } ani_error aniError = nullptr; if ((status = aniEnv->GetUnhandledError(&aniError)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "GetUnhandledError failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "GetUnhandledError failed, status : %{public}d", status); return StsEnv::STSErrorObject(); } if ((status = aniEnv->ResetError()) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "ResetError failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "ResetError failed, status : %{public}d", status); return StsEnv::STSErrorObject(); } std::string errorMsg = GetErrorProperty(aniError, "message"); @@ -476,35 +476,35 @@ StsEnv::STSErrorObject STSEnvironment::GetSTSErrorObject() std::string STSEnvironment::GetErrorProperty(ani_error aniError, const char* property) { - TAG_LOGD(AAFwkTag::STSRUNTIME, "called"); + TAG_LOGD(AAFwkTag::ETSRUNTIME, "called"); auto aniEnv = GetAniEnv(); std::string propertyValue; ani_status status = ANI_ERROR; ani_type errorType = nullptr; if ((status = aniEnv->Object_GetType(aniError, &errorType)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Object_GetType failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Object_GetType failed, status : %{public}d", status); return propertyValue; } ani_method getterMethod = nullptr; if ((status = aniEnv->Class_FindGetter(static_cast(errorType), property, &getterMethod)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Class_FindGetter failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Class_FindGetter failed, status : %{public}d", status); return propertyValue; } ani_ref aniRef = nullptr; if ((status = aniEnv->Object_CallMethod_Ref(aniError, getterMethod, &aniRef)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "Object_CallMethod_Ref failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Object_CallMethod_Ref failed, status : %{public}d", status); return propertyValue; } ani_string aniString = reinterpret_cast(aniRef); ani_size sz {}; if ((status = aniEnv->String_GetUTF8Size(aniString, &sz)) != ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "String_GetUTF8Size failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "String_GetUTF8Size failed, status : %{public}d", status); return propertyValue; } propertyValue.resize(sz + 1); if ((status = aniEnv->String_GetUTF8SubString( aniString, 0, sz, propertyValue.data(), propertyValue.size(), &sz))!= ANI_OK) { - TAG_LOGE(AAFwkTag::STSRUNTIME, "String_GetUTF8SubString failed, status : %{public}d", status); + TAG_LOGE(AAFwkTag::ETSRUNTIME, "String_GetUTF8SubString failed, status : %{public}d", status); return propertyValue; } propertyValue.resize(sz); -- Gitee