From 272c63f04890fe79327493142dd50d1c8bc0fe25 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Fri, 16 May 2025 18:31:42 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=B7=BB=E5=8A=A0=20loglibrary=20ar?= =?UTF-8?q?kts1.2=20=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujia178 --- .../js-apis-loglibrary-sys.md | 112 ++++++++++++++++-- 1 file changed, 104 insertions(+), 8 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-loglibrary-sys.md b/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-loglibrary-sys.md index 6952fe1633c..ae8042070aa 100644 --- a/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-loglibrary-sys.md +++ b/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-loglibrary-sys.md @@ -6,12 +6,17 @@ > > - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块为系统接口。 - +> - 本模块适用于ArkTS 1.1 和 ArkTS1.2。 ## 导入模块 +ArkTS1.1 ```ts import { logLibrary } from '@kit.PerformanceAnalysisKit'; ``` +ArkTS1.2 +```ts +import logLibrary from "@ohos.logLibrary"; +``` ## LogEntry @@ -19,7 +24,9 @@ import { logLibrary } from '@kit.PerformanceAnalysisKit'; **系统能力:** SystemCapability.HiviewDFX.Hiview.LogLibrary -| 名称 | 类型 | 可读 | 可写 | 说明 | +**ArkTS版本:** 该接口适用于ArkTS1.1和ArkTS1.2。 + +| 名称 | 类型 | 只读 | 可选 | 说明 | | -------- | -------- | -------- | -------- | -------- | | name | string | 是 | 否 | 文件名称。 | | mtime | number | 是 | 否 | 上次修改该文件的时间,表示距1970年1月1日0时0分0秒的秒数。 | @@ -35,6 +42,8 @@ list(logType: string): LogEntry[] **系统能力:** SystemCapability.HiviewDFX.Hiview.LogLibrary +**ArkTS版本:** 该接口适用于ArkTS1.1和ArkTS1.2。 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -57,7 +66,7 @@ list(logType: string): LogEntry[] | 202 | Permission denied, non-system app called system api. | | 401 | Invalid argument.| -**示例:** +**ArkTS1.1示例:** ```ts import { logLibrary } from '@kit.PerformanceAnalysisKit'; @@ -69,6 +78,19 @@ try { console.error(`error code: ${error?.code}, error msg: ${error?.message}`); } ``` +**ArkTS1.2示例:** + +```ts +import logLibrary from "@ohos.logLibrary" +import { BusinessError } from '@ohos.base' + +try { + let logObj = logLibrary.list('HILOG'); + // do something here. +} catch (err: BusinessError) { + console.error(`error code: ${err?.code}, error msg: ${err?.message}`); +} +``` ## logLibrary.copy @@ -80,6 +102,8 @@ copy(logType: string, logName: string, dest: string): Promise<void> **系统能力:** SystemCapability.HiviewDFX.Hiview.LogLibrary +**ArkTS版本:** 该接口适用于ArkTS1.1和ArkTS1.2。 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -105,7 +129,7 @@ copy(logType: string, logName: string, dest: string): Promise<void> | 401 | Invalid argument.| | 21300001 | Source file does not exists. | -**示例:** +**ArkTS1.1示例:** ```ts import { logLibrary } from '@kit.PerformanceAnalysisKit'; @@ -126,6 +150,18 @@ try { console.error(`error code: ${error?.code}, error msg: ${error?.message}`); } ``` +**ArkTS1.2示例:** + +```ts +import logLibrary from "@ohos.logLibrary" +import { BusinessError } from '@ohos.base' + +try { + await logLibrary.copy('HILOG', 'hiapplogcat-1.zip', ''); +} catch (err: BusinessError) { + console.error(`error code: ${err?.code}, error msg: ${err?.message}`); +} +``` ## logLibrary.copy @@ -137,6 +173,8 @@ copy(logType: string, logName: string, dest: string, callback: AsyncCallback< **系统能力:** SystemCapability.HiviewDFX.Hiview.LogLibrary +**ArkTS版本:** 该接口适用于ArkTS1.1和ArkTS1.2。 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -157,7 +195,7 @@ copy(logType: string, logName: string, dest: string, callback: AsyncCallback< | 401 | Invalid argument.| | 21300001 | Source file does not exists. | -**示例:** +**ArkTS1.1示例:** ```ts import { logLibrary } from '@kit.PerformanceAnalysisKit'; @@ -174,6 +212,20 @@ try { console.error(`error code: ${error?.code}, error msg: ${error?.message}`); } ``` +**ArkTS1.2示例:** + +```ts +import logLibrary from "@ohos.logLibrary" +import { BusinessError } from '@ohos.base' + +try { + logLibrary.copy('HILOG', 'hiapplogcat-1.zip', 'dir1', (err: BusinessError) => { + //copy结果 + }); +} catch (err: BusinessError) { + console.error(`error code: ${err?.code}, error msg: ${err?.message}`); +} +``` ## logLibrary.move @@ -185,6 +237,8 @@ move(logType: string, logName: string, dest: string): Promise<void> **系统能力:** SystemCapability.HiviewDFX.Hiview.LogLibrary +**ArkTS版本:** 该接口适用于ArkTS1.1和ArkTS1.2。 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -210,7 +264,7 @@ move(logType: string, logName: string, dest: string): Promise<void> | 401 | Invalid argument.| | 21300001 | Source file does not exists. | -**示例:** +**ArkTS1.1示例:** ```ts import { logLibrary } from '@kit.PerformanceAnalysisKit'; @@ -231,6 +285,18 @@ try { console.error(`error code: ${error?.code}, error msg: ${error?.message}`); } ``` +**ArkTS1.2示例:** + +```ts +import logLibrary from "@ohos.logLibrary" +import { BusinessError } from '@ohos.base' + +try { + await logLibrary.move('FAULTLOG', 'fault_log_test.zip', ''); +} catch (err: BusinessError) { + console.error(`error code: ${err?.code}, error msg: ${err?.message}`); +} +``` ## logLibrary.move @@ -242,6 +308,8 @@ move(logType: string, logName: string, dest: string, callback: AsyncCallback< **系统能力:** SystemCapability.HiviewDFX.Hiview.LogLibrary +**ArkTS版本:** 该接口适用于ArkTS1.1和ArkTS1.2。 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -262,7 +330,7 @@ move(logType: string, logName: string, dest: string, callback: AsyncCallback< | 401 | Invalid argument.| | 21300001 | Source file does not exists. | -**示例:** +**ArkTS1.1示例:** ```ts import { logLibrary } from '@kit.PerformanceAnalysisKit'; @@ -279,6 +347,20 @@ try { console.error(`error code: ${error?.code}, error msg: ${error?.message}`); } ``` +**ArkTS1.2示例:** + +```ts +import logLibrary from "@ohos.logLibrary" +import { BusinessError } from '@ohos.base' + +try { + logLibrary.move('FAULTLOG', 'fault_log_test.zip', 'dir1/dir2', (err: BusinessError) => { + //move结果 + }); +} catch (err: BusinessError) { + console.error(`error code: ${err?.code}, error msg: ${err?.message}`); +} +``` ## logLibrary.remove @@ -290,6 +372,8 @@ remove(logType: string, logName: string): void **系统能力:** SystemCapability.HiviewDFX.Hiview.LogLibrary +**ArkTS版本:** 该接口适用于ArkTS1.1和ArkTS1.2。 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -308,7 +392,7 @@ remove(logType: string, logName: string): void | 401 | Invalid argument.| | 21300001 | Source file does not exists. | -**示例:** +**ArkTS1.1示例:** ```ts import { logLibrary } from '@kit.PerformanceAnalysisKit'; @@ -318,4 +402,16 @@ try { } catch (error) { console.error(`error code: ${error?.code}, error msg: ${error?.message}`); } +``` +**ArkTS1.2示例:** + +```ts +import logLibrary from "@ohos.logLibrary" +import { BusinessError } from '@ohos.base' + +try { + logLibrary.remove('FAULTLOG', 'fault_log_test.zip'); +} catch (err: BusinessError) { + console.error(`error code: ${err?.code}, error msg: ${err?.message}`); +} ``` \ No newline at end of file -- Gitee