未验证 提交 103dde85 编写于 作者: O openharmony_ci 提交者: Gitee

!6078 翻译已完成5519&5901

Merge pull request !6078 from shawn_he/0629-a
......@@ -2,13 +2,13 @@
This module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import hiAppEvent from '@ohos.hiAppEvent';
```
......@@ -25,14 +25,14 @@ Writes event information to the event file of the current day. This API supports
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| eventName | string | Yes | Application event name.<br>You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter.|
| eventName | string | Yes | Application event name.<br>You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter. |
| eventType | [EventType](#eventtype) | Yes | Application event type. |
| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.<br>- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).<br>- The number of event parameters must be less than or equal to 32.<br>- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).<br>- A string value can contain a maximum of 8*1024 characters.<br>- An array value can contain a maximum of 100 elements. Excess elements will be truncated.|
| callback | AsyncCallback&lt;void&gt; | No | Callback used to process the received return value.<br>-&nbsp; Value **0** indicates that the event verification is successful, and the event will be written to the event file asynchronously. <br>-&nbsp; A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored. <br>-&nbsp; A value smaller than **0** indicates that the event verification fails, and the event will not be written to the event file.|
| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.<br>- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).<br>- The number of event parameters must be less than or equal to 32.<br>- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).<br>- A string value can contain a maximum of 8*1024 characters.<br>- An array value can contain a maximum of 100 elements. Excess elements will be truncated. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to process the received return value.<br>-&nbsp; Value **0** indicates that the event verification is successful, and the event will be written to the event file asynchronously. <br>-&nbsp; A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored. <br>-&nbsp; A value smaller than **0** indicates that the event verification fails, and the event will not be written to the event file. |
**Example**
```
```js
hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}, (err, value) => {
if (err) {
// Event writing exception: Write the event to the event file after the invalid parameters in the event are ignored, or stop writing the event if the event verification fails.
......@@ -58,19 +58,19 @@ Writes event information to the event file of the current day. This API supports
| Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ------------------------------------------------------------ |
| eventName | string | Yes | Application event name.<br>You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter.|
| eventName | string | Yes | Application event name.<br>You need to customize the event name. It can contain a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter. |
| eventType | [EventType](#eventtype) | Yes | Application event type. |
| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.<br>- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).<br>- The number of event parameters must be less than or equal to 32.<br>- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).<br>- A string value can contain a maximum of 8*1024 characters.<br>- An array value can contain a maximum of 100 elements. Excess elements will be truncated.|
| keyValues | object | Yes | Parameter key-value pair. For a variable-length parameter, enter each pair of parameter name and value in sequence. For a JSON parameter, enter the parameter name as the key and parameter value as the value.<br>- A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).<br>- The number of event parameters must be less than or equal to 32.<br>- The parameter name can contain a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter and cannot end with an underscore (\_).<br>- A string value can contain a maximum of 8*1024 characters.<br>- An array value can contain a maximum of 100 elements. Excess elements will be truncated. |
**Return value**
| Type | Description |
| ------------------- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed.|
| Promise&lt;void&gt; | Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed. |
**Example**
```
```js
hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"})
.then((value) => {
// Event writing succeeded.
......@@ -94,16 +94,16 @@ Configures the application event logging function, such as setting the event log
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | ------------------------ |
| config | [ConfigOption](#configoption) | Yes | Configuration items for application event logging.|
| config | [ConfigOption](#configoption) | Yes | Configuration items for application event logging. |
**Return value**
| Type | Description |
| ------- | ----------------------------------------------------------- |
| boolean | Returns **true** if the configuration is successful; returns **false** otherwise.|
| boolean | Returns **true** if the configuration is successful; returns **false** otherwise. |
**Example**
```
```js
// Set the application event logging switch.
hiAppEvent.configure({
disable: true
......@@ -124,8 +124,8 @@ Provides the configuration items for application event logging.
| Name | Type | Mandatory| Description |
| ---------- | ------- | ---- | ------------------------------------------------------------ |
| disable | boolean | No | Application event logging switch. The value <b>true</b> means to disable the application event logging function, and the value <b>false</b> means the opposite.|
| maxStorage | string | No | Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space.|
| disable | boolean | No | Application event logging switch. The value <b>true</b> means to disable the application event logging function, and the value <b>false</b> means the opposite. |
| maxStorage | string | No | Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space. |
## EventType
......@@ -152,7 +152,7 @@ Provides constants that define the names of all predefined events.
| ------------------------- | -------- | ---- | ---- | -------------------- |
| USER_LOGIN | string | Yes | No | User login event. |
| USER_LOGOUT | string | Yes | No | User logout event. |
| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event.|
| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event. |
## Param
......@@ -161,8 +161,8 @@ Provides constants that define the names of all predefined event parameters.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
| Name | Type| Readable| Writable| Description |
| Name | Type | Readable | Writable | Description |
| ------------------------------- | -------- | ---- | ---- | ------------------ |
| USER_ID | string | Yes | No | Custom user ID. |
| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. |
| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID.|
| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. |
| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID. |
\ No newline at end of file
# Distributed Call Chain Tracing
This module implements call chain tracing throughout a service process. It provides functions such as starting and stopping call chain tracing and configuring trace points.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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.
......
# Performance Tracing
This module provides the functions of tracing service processes and monitoring the system performance. It provides the data needed for hiTraceMeter to carry out performance analysis.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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.
......
......@@ -134,11 +134,11 @@ Obtains the new version information. This function uses an asynchronous callback
**Example**
```
updater.getNewVersionInfo(info => {
updater.getNewVersionInfo((err, info) => {
console.log("getNewVersionInfo success " + info.status);
console.log(`info versionName = ` + info.checkResult[0].versionName);
console.log(`info versionCode = ` + info.checkResult[0].versionCode);
console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo);
console.log(`info versionName = ` + info.checkResults[0].versionName);
console.log(`info versionCode = ` + info.checkResults[0].versionCode);
console.log(`info verifyInfo = ` + info.checkResults[0].verifyInfo);
});
```
......@@ -160,9 +160,9 @@ Obtains the new version information. This function uses a promise to return the
```
updater.getNewVersionInfo().then(value => {
console.log(`info versionName = ` + value.checkResult[0].versionName);
console.log(`info versionCode = ` + value.checkResult[0].versionCode);
console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo);
console.log(`info versionName = ` + value.checkResults[0].versionName);
console.log(`info versionCode = ` + value.checkResults[0].versionCode);
console.log(`info verifyInfo = ` + value.checkResults[0].verifyInfo);
}).catch(err => {
console.log("getNewVersionInfo promise error: " + err.code);
});
......@@ -185,11 +185,11 @@ Checks whether the current version is the latest. This function uses an asynchro
**Example**
```
updater.checkNewVersion(info => {
updater.checkNewVersion((err, info) => {
console.log("checkNewVersion success " + info.status);
console.log(`info versionName = ` + info.checkResult[0].versionName);
console.log(`info versionCode = ` + info.checkResult[0].versionCode);
console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo);
console.log(`info versionName = ` + info.checkResults[0].versionName);
console.log(`info versionCode = ` + info.checkResults[0].versionCode);
console.log(`info verifyInfo = ` + info.checkResults[0].verifyInfo);
});
```
......@@ -211,9 +211,9 @@ Checks whether the current version is the latest. This function uses a promise t
```
updater.checkNewVersion().then(value => {
console.log(`info versionName = ` + value.checkResult[0].versionName);
console.log(`info versionCode = ` + value.checkResult[0].versionCode);
console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo);
console.log(`info versionName = ` + value.checkResults[0].versionName);
console.log(`info versionCode = ` + value.checkResults[0].versionCode);
console.log(`info verifyInfo = ` + value.checkResults[0].verifyInfo);
}).catch(err => {
console.log("checkNewVersion promise error: " + err.code);
});
......@@ -284,7 +284,7 @@ Reboots the device and clears the user partition data. This function uses a prom
**Example**
```
updater.rebootAndCleanUserData(result => {
updater.rebootAndCleanUserData((err, result) => {
console.log("rebootAndCleanUserData ", result)
});
```
......@@ -330,7 +330,7 @@ Installs the update package. This function uses a promise to return the result.
**Example**
```
updater.applyNewVersion(result => {
updater.applyNewVersion((err, result) => {
console.log("applyNewVersion ", result)
});
```
......@@ -399,7 +399,7 @@ let policy = {
autoUpgradeInterval: [ 2, 3 ],
autoUpgradeCondition: 2
}
updater.setUpdatePolicy(policy, result => {
updater.setUpdatePolicy(policy, (err, result) => {
console.log("setUpdatePolicy ", result)
});
```
......@@ -458,7 +458,7 @@ Obtains the update policy. This function uses an asynchronous callback to return
**Example**
```
updater.getUpdatePolicy(policy => {
updater.getUpdatePolicy((err, policy) => {
console.log("getUpdatePolicy success");
console.log(`policy autoDownload = ` + policy.autoDownload);
console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册