diff --git a/OAT.xml b/OAT.xml index 9705a1cbe38d1ac277d21d688189b738b49a37d6..ab7cca4997aea30fae92309c2dc1ce361d6dbc9e 100644 --- a/OAT.xml +++ b/OAT.xml @@ -103,6 +103,11 @@ Note:If the text contains special characters, please escape them according to th + + + + + @@ -145,6 +150,7 @@ Note:If the text contains special characters, please escape them according to th + @@ -281,6 +287,11 @@ Note:If the text contains special characters, please escape them according to th + + + + + @@ -372,6 +383,10 @@ Note:If the text contains special characters, please escape them according to th + + + + @@ -416,6 +431,13 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + @@ -475,9 +497,41 @@ Note:If the text contains special characters, please escape them according to th - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -951,6 +1005,9 @@ Note:If the text contains special characters, please escape them according to th + + + @@ -1062,6 +1119,10 @@ Note:If the text contains special characters, please escape them according to th + + + + @@ -1195,6 +1256,7 @@ Note:If the text contains special characters, please escape them according to th + @@ -1262,6 +1324,31 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1273,6 +1360,30 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + @@ -1325,25 +1436,13 @@ Note:If the text contains special characters, please escape them according to th - - - - + - - - - - - - - - - + @@ -1394,7 +1493,7 @@ Note:If the text contains special characters, please escape them according to th - + ` @@ -1472,6 +1571,273 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1517,6 +1883,19 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + @@ -1571,6 +1950,19 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/.gitignore b/code/DocsSample/PerformanceAnalysisKit/Hilog/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/app.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..bf1020b33496325f02644731457f67dea8e0a7af --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.samples.hilog", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ffde311434c2bd7a86d8e057d860177635dd44cc --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "HiLog" + } + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/resources/base/media/app_icon.png b/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/Hilog/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/README_zh.md b/code/DocsSample/PerformanceAnalysisKit/Hilog/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..22786e954c6b586a8484d75087f9ab5159f7d367 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/README_zh.md @@ -0,0 +1,88 @@ +# 使用HiLog打印日志 + +### 介绍 + +本示例主要展示了使用HiLog打印日志相关的功能,在应用开发过程中,可在关键代码处输出日志信息。在运行应用后,通过查看日志信息来分析应用执行情况(如应用是否正常运行、代码运行时序、运行逻辑分支是否正常等)。 + +HiLog日志系统,提供给系统框架、服务、以及应用,用于打印日志,记录用户操作、系统运行状态等。 + +该工程中的展示的代码详细描述可查如下链接: + +- [使用HiLog打印日志(ArkTS)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/dfx/hilog-guidelines-arkts.md) + +- [使用HiLog打印日志(C/C++)](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/dfx/hilog-guidelines-ndk.md) + +### 效果预览 + +| 主页 | +| :----------------------------------------------------------: | +| z | + +#### 使用说明 + +##### 1.Hilog(ArkTS)使用说明 + +1.在应用侧主界面,点击"HiLog ArkTS"按钮; + +2.在DevEco界面切换到"Log"窗口,日志过滤选择"No filters",搜索内容设置为"testTag"。此时窗口仅显示符合条件的日志,打印日志结果为: + +``` +01-16 14:46:54.316 2997-2997 A0ff00/testTag com.sampl...logarkts I hilog_info_test +01-16 14:46:54.316 2997-2997 A0ff00/testTag com.sampl...logarkts D hilog_debug_test +01-16 14:46:54.316 2997-2997 A0ff00/testTag com.sampl...logarkts W hilog_warn_test +01-16 14:46:54.316 2997-2997 A0ff00/testTag com.sampl...logarkts F hilog_fatal_test +01-16 14:46:54.316 2997-2997 A0ff00/testTag com.sampl...logarkts E hilog_error_test +01-16 14:46:54.316 2997-2997 A0ff00/testTag com.sampl...logarkts I A log with a domainID of 0xFF00 and a label of testTag can print logs at the Info level or higher. +``` + +##### 2.HiLog(C++)使用说明 + +1.在主界面,点击"HiLog C++"按钮(会引发程序崩溃); + +2.切换到"Log"窗口,日志过滤选择"No filters",搜索内容设置为"Failed to test"。此时窗口显示报错的日志,打印日志结果为"Failed to test"。 + +### 工程目录 + +``` +entry/src/main +├─cpp +│ ├─CMakeLists.txt //导入so链接 +│ └─napi_init.cpp //功能函数 +│ +└─ets + └─pages + └─Index.ets //主页 + +``` + +### 具体实现 + +1.ArkTS实现时只需在按钮的点击事件中添加各种类型日志的打印函数 + +2.C++实现时在napi_init.cpp添加具有打印功能的函数,在主页按钮中增加一个单击事件,并调用功能函数打印一条日志。 + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568; +2. 本示例已适配API14版本SDK,版本号:5.0.2.58,镜像版本号:OpenHarmony5.0.2.58; +3. 本示例需要使用DevEco Studio(5.0.3.910)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/PerformanceAnalysisKit/Hilog/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d06f497c28415a48a6000c73bda832fcacdd4d7a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/build-profile.json5 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": 14, + "compileSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/.gitignore b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/build-profile.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cf04697149e08706d1ff6952e21801b4bde1d860 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/build-profile.json5 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "x86_64", + "arm64-v8a", + "armeabi-v7a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e042e3f963ab27941d3b34f1f027da9933b81df1 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/obfuscation-rules.txt b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..fdbb5b9852d7dd5f39bddaeb21ab5ee1f3346749 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/obfuscation-rules.txt @@ -0,0 +1,22 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d55b3e8de9d84c6b79c43869a2b2f0948633f7ec --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..08fade9bb8b366cb86b74a738ee2463526255dac --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,16 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(CPP) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so) +target_link_libraries(entry PUBLIC libhilog_ndk.z.so) \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86d71d8dcd24006e9fe44954f748ddb287b1fdd0 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" +#include "hilog/log.h" +#undef LOG_DOMAIN +#undef LOG_TAG +#define LOG_DOMAIN 0x3200 // 全局domain宏,标识业务领域 +#define LOG_TAG "MY_TAG" // 全局tag宏,标识模块日志tag + +void MyHiLog(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *msg) +{ + // user-defined to handle your log, such as redirect/filter + // 注意: 回调函数里面不允许再调用hilog接口打印日志,不然会死循环 +} + +static napi_value HiLogTest(napi_env env, napi_callback_info info) +{ + OH_LOG_SetCallback(MyHiLog); + OH_LOG_ERROR(LOG_APP, "Failed to test"); +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "HiLogTest", nullptr, HiLogTest, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..38cfeee0f849bc795cd14ae2292d0096d4c03b13 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const HiLogTest: () => void; \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..88838fa0b2042f057b1d730054d5698b61c7fb58 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e490e3a4f8d3d18d7e4671881aab868c7c5dde9 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/pages/Index.ets b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddee5b974f552da8ee8977454090a5c5e9823614 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + // 添加按钮,以响应用户点击 + Button($r('app.string.HiLogArkTS_Button')) + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // 按钮绑定onClick事件,点击时打印日志,注意realse hap包默认无法打印debug级别日志 + .onClick(() => { + hilog.info(0xFF00, 'testTag', 'hilog_info_test'); + hilog.debug(0xFF00, 'testTag', 'hilog_debug_test'); + hilog.warn(0xFF00, 'testTag', 'hilog_warn_test'); + hilog.fatal(0xFF00, 'testTag', 'hilog_fatal_test'); + hilog.error(0xFF00, 'testTag', 'hilog_error_test'); + //isLoggable是用来判断,domainID和tag是否满足目前的日志级别打印,建议对返回值进行判断 + let ret = hilog.isLoggable(0xFF00, 'testTag', hilog.LogLevel.INFO); + if (ret) { + hilog.info(0xFF00, 'testTag', + 'A log with a domainID of 0xFF00 and a label of testTag can print logs at the Info level or higher.'); + } + }) + Button($r('app.string.HiLogCPP_Button')) + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + .onClick(() => { + testNapi.HiLogTest(); + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/module.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9f7f873fbc51484895e18fcfd60b2498521aecb0 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/element/color.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/element/string.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5250737a934da4c67468eddbc0f5450e0a216882 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Hilog" + }, + { + "name": "HiLogArkTS_Button", + "value": "HiLog ArkTS" + }, + { + "name": "HiLogCPP_Button", + "value": "HiLog C++" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/background.png b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5250737a934da4c67468eddbc0f5450e0a216882 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Hilog" + }, + { + "name": "HiLogArkTS_Button", + "value": "HiLog ArkTS" + }, + { + "name": "HiLogCPP_Button", + "value": "HiLog C++" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2b53d3178a02d340eff90ab5d9f271af1107ecd1 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Hilog" + }, + { + "name": "HiLogArkTS_Button", + "value": "HiLog ArkTS" + }, + { + "name": "HiLogCPP_Button", + "value": "HiLog C++" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/mock/Libentry.mock.ets b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..37c4693badee0bced9f50f020403147ada0e8d44 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const nativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default nativeMock; \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/mock/mock-config.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..25f4db9dcf89e656abe1a6776fe21cd00fc94dac --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/entry/src/mock/mock-config.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/hvigor/hvigor-config.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a2c44fdf8f9ac103168672568ff000ac395a2edc --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/hvigorfile.ts b/code/DocsSample/PerformanceAnalysisKit/Hilog/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..79d8761856e2996edc0649eca63b96b2c883b28a --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/oh-package.json5 b/code/DocsSample/PerformanceAnalysisKit/Hilog/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b7f346f7ddb2fc98ac428c55207a63ff89ea1c70 --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.18", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/ohosTest.md b/code/DocsSample/PerformanceAnalysisKit/Hilog/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..dbd9ae1104aa54f79cce9bba6e0c1f3b9678448d --- /dev/null +++ b/code/DocsSample/PerformanceAnalysisKit/Hilog/ohosTest.md @@ -0,0 +1,8 @@ +# Hilog测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------ | ------------ | ------------------------------ | ------------ | -------- | -------- | +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 否 | Pass | +| 主页按钮点击 | 位于主页 | 按readme的使用说明依次点击按钮 | 输出预期日志 | 否 | Pass | \ No newline at end of file diff --git a/code/DocsSample/PerformanceAnalysisKit/Hilog/screenshots/Screenshot_20250219094412587.jpeg b/code/DocsSample/PerformanceAnalysisKit/Hilog/screenshots/Screenshot_20250219094412587.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..3b59a0831253071c972e85d7844e6a5a7b0dd534 Binary files /dev/null and b/code/DocsSample/PerformanceAnalysisKit/Hilog/screenshots/Screenshot_20250219094412587.jpeg differ