From d418c344fb67201f44d3f062cc8e8857a5b44e22 Mon Sep 17 00:00:00 2001 From: wusongqing Date: Thu, 27 Jan 2022 19:35:41 +0800 Subject: [PATCH 1/3] updated docs Signed-off-by: wusongqing --- .../reference/apis/Readme-EN.md | 9 ++ .../reference/apis/js-apis-faultLogger.md | 111 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-faultLogger.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 4638d0eecbe..e5eeb0eb1fe 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -1,5 +1,13 @@ # APIs +- Ability Framework + - [FeatureAbility Module](js-apis-featureAbility.md) + - [ParticleAbility Module](js-apis-particleAbility.md) + - [DataUriUtils Module](js-apis-DataUriUtils.md) + - [Context Module](js-apis-Context.md) +- Event Notification + - [CommonEvent Module](js-apis-commonEvent.md) + - [Notification Module](js-apis-notification.md) - Resource Management - [Resource Manager](js-apis-resource-manager.md) - [Internationalization \(intl\) ](js-apis-intl.md) @@ -47,6 +55,7 @@ - [Animation](js-apis-basic-features-animator.md) - [HiAppEvent](js-apis-hiappevent.md) - [Performance Tracing](js-apis-bytrace.md) + - [Fault Logger](js-apis-faultLogger.md) - Language Base Class Library - [Obtaining Process Information](js-apis-process.md) - [URL String Parsing](js-apis-url.md) diff --git a/en/application-dev/reference/apis/js-apis-faultLogger.md b/en/application-dev/reference/apis/js-apis-faultLogger.md new file mode 100644 index 00000000000..7dba1772e4f --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-faultLogger.md @@ -0,0 +1,111 @@ +# Fault Logger +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import faultLogger from '@ohos.faultLogger' +``` + +## Required Permissions + +None + +## faultLogger.FaultType + +Enumerates the fault types. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| NO_SPECIFIC | 0 | No specific fault type.| +| CPP_CRASH | 2 | C++ program crash.| +| JS_CRASH | 3 | JS program crash.| +| APP_FREEZE | 4 | Application freezing.| + +## faultLogger.FaultLogInfo + +Defines the data structure of the fault log information. + +| Name| Type| Description| +| -------- | -------- | -------- | +| pid | number | Process ID of the faulty process.| +| uid | number | User ID of the faulty process.| +| type | [FaultType](#faultloggerfaulttype) | Fault type.| +| timestamp | number | Second-level timestamp when the log was generated.| +| reason | string | Reason for the fault.| +| module | string | Module on which the fault occurred.| +| summary | string | Summary of the fault.| +| fullLog | string | Full log text.| + +## faultLogger.querySelfFaultLog + +querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void + +Obtains the fault information about the current process. This method uses a callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | faultType | [FaultType](#faultloggerfaulttype) | Yes| Fault type.| + | callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloggerfaultloginfo)>> | Yes| Callback used to return the fault information array.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. + +- Example +``` +function queryFaultLogCallback(error, value) { + if (error) { + console.info('error is ' + error); + } else { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log ts: " + value[i].ts); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } + } +} +faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH, queryFaultLogCallback); +``` + +## faultLogger.querySelfFaultLog + +querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>>; + +Obtains the fault information about the current process. This method uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | faultType | [FaultType](#faultloggerfaulttype) | Yes| Fault type.| + +- Return values + | Type| Description| + | -------- | -------- | + | Promise<Array<[FaultLogInfo](#faultloggerfaultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.| + +- Example +``` +let value = await faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH); +if (value) { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log ts: " + value[i].ts); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } +} +``` -- Gitee From bbc8027caacf685c776911b06ff8240f82c0f40a Mon Sep 17 00:00:00 2001 From: wusongqing Date: Thu, 27 Jan 2022 19:39:27 +0800 Subject: [PATCH 2/3] updated docs Signed-off-by: wusongqing --- en/application-dev/reference/apis/js-apis-faultLogger.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/application-dev/reference/apis/js-apis-faultLogger.md b/en/application-dev/reference/apis/js-apis-faultLogger.md index 7dba1772e4f..958a9a886ab 100644 --- a/en/application-dev/reference/apis/js-apis-faultLogger.md +++ b/en/application-dev/reference/apis/js-apis-faultLogger.md @@ -1,5 +1,5 @@ # Fault Logger -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +>![](../../public_sys-resources/icon-note.gif) **Note:** > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import -- Gitee From f895840357bdb9ebcbfadefdf722c94692ce78aa Mon Sep 17 00:00:00 2001 From: wusongqing Date: Thu, 27 Jan 2022 19:41:58 +0800 Subject: [PATCH 3/3] updated docs Signed-off-by: wusongqing --- en/application-dev/reference/apis/Readme-EN.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index e5eeb0eb1fe..2a7fcb48c7c 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -2,12 +2,6 @@ - Ability Framework - [FeatureAbility Module](js-apis-featureAbility.md) - - [ParticleAbility Module](js-apis-particleAbility.md) - - [DataUriUtils Module](js-apis-DataUriUtils.md) - - [Context Module](js-apis-Context.md) -- Event Notification - - [CommonEvent Module](js-apis-commonEvent.md) - - [Notification Module](js-apis-notification.md) - Resource Management - [Resource Manager](js-apis-resource-manager.md) - [Internationalization \(intl\) ](js-apis-intl.md) -- Gitee