提交 2ba372a0 编写于 作者: W wusongqing

updated faultlogger api

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 484128ba
# Fault Logger # Fault Logger
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![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. > 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 ## Modules to Import
...@@ -8,14 +8,13 @@ ...@@ -8,14 +8,13 @@
import faultLogger from '@ohos.faultLogger' import faultLogger from '@ohos.faultLogger'
``` ```
## System Capabilities
SystemCapability.HiviewDFX.Hiview.FaultLogger
## FaultType ## FaultType
Enumerates the fault types. Enumerates the fault types.
**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
| Name| Default Value| Description| | Name| Default Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| NO_SPECIFIC | 0 | No specific fault type.| | NO_SPECIFIC | 0 | No specific fault type.|
...@@ -27,6 +26,8 @@ Enumerates the fault types. ...@@ -27,6 +26,8 @@ Enumerates the fault types.
Defines the data structure of the fault log information. Defines the data structure of the fault log information.
**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| pid | number | Process ID of the faulty process.| | pid | number | Process ID of the faulty process.|
...@@ -42,14 +43,16 @@ Defines the data structure of the fault log information. ...@@ -42,14 +43,16 @@ Defines the data structure of the fault log information.
querySelfFaultLog(faultType: FaultType, callback: AsyncCallback&lt;Array&lt;FaultLogInfo&gt;&gt;) : void querySelfFaultLog(faultType: FaultType, callback: AsyncCallback&lt;Array&lt;FaultLogInfo&gt;&gt;) : 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. Obtains the fault information about the current process. This API uses a callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| faultType | [FaultType](#faulttype) | Yes| Fault type.| | faultType | [FaultType](#faulttype) | Yes| Fault type.|
| callback | AsyncCallbackArray&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Yes| Callback used to return the fault information array. <br/>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. | callback | AsyncCallbackArray&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Yes| Callback used to return the fault information array.<br>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** **Example**
...@@ -73,14 +76,16 @@ function queryFaultLogCallback(error, value) { ...@@ -73,14 +76,16 @@ function queryFaultLogCallback(error, value) {
} }
} }
} }
faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH, queryFaultLogCallback); faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback);
``` ```
## faultLogger.querySelfFaultLog ## faultLogger.querySelfFaultLog
querySelfFaultLog(faultType: FaultType) : Promise&lt;Array&lt;FaultLogInfo&gt;&gt;; querySelfFaultLog(faultType: FaultType) : Promise&lt;Array&lt;FaultLogInfo&gt;&gt;
Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
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. **System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
**Parameters** **Parameters**
...@@ -92,13 +97,14 @@ Obtains the fault information about the current process. This method uses a prom ...@@ -92,13 +97,14 @@ Obtains the fault information about the current process. This method uses a prom
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.| | Promise&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.<br>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.|
**Example** **Example**
``` ```
let value = await faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH); async function getLog() {
if (value) { let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH);
if (value) {
console.info("value length is " + value.length); console.info("value length is " + value.length);
let len = value.length; let len = value.length;
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
...@@ -112,5 +118,6 @@ if (value) { ...@@ -112,5 +118,6 @@ if (value) {
console.info("Log summary: " + value[i].summary); console.info("Log summary: " + value[i].summary);
console.info("Log text: " + value[i].fullLog); console.info("Log text: " + value[i].fullLog);
} }
}
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册