From e89437ce442784c3660c7673de2eacd654e96fbe Mon Sep 17 00:00:00 2001 From: liuyifei Date: Tue, 24 Jun 2025 07:09:35 +0000 Subject: [PATCH] =?UTF-8?q?hilog=E8=B5=84=E6=96=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuyifei --- zh-cn/application-dev/dfx/hilog-guidelines-arkts.md | 2 ++ zh-cn/application-dev/dfx/hilog-guidelines-ndk.md | 6 ++++-- .../apis-performance-analysis-kit/_hi_log.md | 13 +++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/zh-cn/application-dev/dfx/hilog-guidelines-arkts.md b/zh-cn/application-dev/dfx/hilog-guidelines-arkts.md index 4b00486d88a..1b49d06a29d 100644 --- a/zh-cn/application-dev/dfx/hilog-guidelines-arkts.md +++ b/zh-cn/application-dev/dfx/hilog-guidelines-arkts.md @@ -153,12 +153,14 @@ HiLog中定义了DEBUG、INFO、WARN、ERROR、FATAL五种日志级别,并提 5. 在DevEco Studio的底部,切换到“Log”窗口,设置日志的过滤条件。 选择当前的设备及进程,日志级别选择Verbose,搜索内容设置为“testTag”。此时窗口仅显示符合条件的日志。 + 打印日志结果为: ```txt 01-02 08:18:24.947 30988-30988 A0ff00/testTag com.example.hilogemo I hello World 3 01-02 08:18:24.947 30988-30988 A0ff00/testTag com.example.hilogemo I peter is {"name":"peter","age":15} 01-02 08:18:24.947 30988-30988 A00000/testTag com.example.hilogemo E this is an error level log ``` + \ No newline at end of file diff --git a/zh-cn/application-dev/dfx/hilog-guidelines-ndk.md b/zh-cn/application-dev/dfx/hilog-guidelines-ndk.md index 7e3d43a9b2c..2afca4b4e16 100644 --- a/zh-cn/application-dev/dfx/hilog-guidelines-ndk.md +++ b/zh-cn/application-dev/dfx/hilog-guidelines-ndk.md @@ -105,10 +105,12 @@ HiLog中定义了DEBUG、INFO、WARN、ERROR、FATAL五种日志级别,并提 4. 输出结果: + ``` - 01-02 08:39:38.915 9012-9012 A03200/MY_TAG pid-9012 I Failed to visit , reason:11. - 01-02 08:39:38.915 9012-9012 A03200/MY_TAG pid-9012 E this is an info level log + 01-02 08:39:38.915 9012-9012 A03200/MY_TAG com.example.hilogemo I Failed to visit , reason:11. + 01-02 08:39:38.915 9012-9012 A03200/MY_TAG com.example.hilogemo E this is an info level log ``` + ### 日志回调接口使用示例 diff --git a/zh-cn/application-dev/reference/apis-performance-analysis-kit/_hi_log.md b/zh-cn/application-dev/reference/apis-performance-analysis-kit/_hi_log.md index 9f410ea0cd7..6d26b5dd4a5 100644 --- a/zh-cn/application-dev/reference/apis-performance-analysis-kit/_hi_log.md +++ b/zh-cn/application-dev/reference/apis-performance-analysis-kit/_hi_log.md @@ -60,8 +60,17 @@ HiLog模块实现日志打印功能。 | int [OH_LOG_VPrint](#oh_log_vprint) ([LogType](#logtype) type, [LogLevel](#loglevel) level, unsigned int domain, const char \*tag, const char \*fmt, va_list ap) __attribute__((__format__(os_log | 写日志接口。指定日志类型、日志级别、业务领域、TAG,按照类printf格式类型和隐私指示确定需要输出的变参,变参为va_list类型。 | | bool [OH_LOG_IsLoggable](#oh_log_isloggable) (unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | 检查指定业务领域、TAG、级别的日志是否可以打印。 | | void [OH_LOG_SetCallback](#oh_log_setcallback) ([LogCallback](#logcallback) callback) | 注册函数。 | -| void [OH_LOG_SetMinLogLevel](#oh_log_setminloglevel) ([LogLevel](#loglevel) level) | 设置应用日志打印的最低日志级别。 进程在打印日志时,需要同时校验该日志级别和全局日志级别,
所以设置的日志级别不能低于全局日志级别,[全局日志级别](../../dfx/hilog.md#查看和设置日志级别)默认为Info。 | - +| void [OH_LOG_SetMinLogLevel](#oh_log_setminloglevel) ([LogLevel](#loglevel) level) | 设置应用日志打印的最低日志级别。用于拦截低级别日志打印,需要注意日志级别低于全局日志级别会导致日志打印失败。 | + + +> **说明:** +> +> - OH_LOG_IsLoggable()和具体日志打印接口使用的domain和tag应保持一致。 +> +> - OH_LOG_IsLoggable()使用的level,应和具体日志打印接口级别保持一致。 +> +> 全局日志级别,默认为info, 可参考[查看和设置日志级别](../../dfx/hilog.md#查看和设置日志级别) + ## 宏定义说明 -- Gitee