提交 e554ea42 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 d4d3c15d
...@@ -11,25 +11,22 @@ import hiAppEvent from '@ohos.hiAppEvent'; ...@@ -11,25 +11,22 @@ import hiAppEvent from '@ohos.hiAppEvent';
``` ```
## System Capabilities
SystemCapability.HiviewDFX.HiAppEvent
## hiAppEvent.write ## hiAppEvent.write
write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback&lt;void&gt;): void write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback&lt;void&gt;): void
Writes event information to the event file of the current day. This function supports JSON parameters and uses an asynchronous callback to return the result. Writes event information to the event file of the current day. This API supports JSON parameters and uses an asynchronous callback to return the result.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| eventName | string | Yes| App event name.| | eventName | string | Yes | App 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.| | eventType | [EventType](#eventtype) | Yes | Application event type. |
| keyValues | object | Yes| Array of JSON parameters of the application event. 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).| | 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;The value **0** indicates that the event parameter 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 parameter verification fails, and the event will not be written to the event file asynchronously.| | 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** **Example**
...@@ -51,20 +48,22 @@ hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str ...@@ -51,20 +48,22 @@ hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str
write(eventName: string, eventType: EventType, keyValues: object): Promise&lt;void&gt; write(eventName: string, eventType: EventType, keyValues: object): Promise&lt;void&gt;
Writes event information to the event file of the current day. This function supports JSON parameters and uses a promise to return the result. Writes event information to the event file of the current day. This API supports JSON parameters and uses a promise to return the result.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | --------- | ----------------------- | ---- | ------------------------------------------------------------ |
| eventName | string | Yes| App event name.| | eventName | string | Yes | App 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.| | eventType | [EventType](#eventtype) | Yes | Application event type. |
| keyValues | object | Yes| Array of JSON parameters of the application event. 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).| | 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** **Return value**
| Type| Description| | 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** **Example**
...@@ -87,16 +86,18 @@ configure(config: ConfigOption): boolean ...@@ -87,16 +86,18 @@ configure(config: ConfigOption): boolean
Configures the application event logging function, such as setting the event logging switch and maximum size of the directory that stores the event logging files. Configures the application event logging function, such as setting the event logging switch and maximum size of the directory that stores the event logging files.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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** **Return value**
| Type| Description| | 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** **Example**
...@@ -117,41 +118,49 @@ hiAppEvent.configure({ ...@@ -117,41 +118,49 @@ hiAppEvent.configure({
Provides the configuration items for application event logging. Provides the configuration items for application event logging.
| Name| Type| Mandatory| Description| **System capability**: SystemCapability.HiviewDFX.HiAppEvent
| -------- | -------- | -------- | -------- |
| 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.| | Name | Type | Mandatory| Description |
| 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 ## EventType
Enumerates event types. Enumerates event types.
| Name| Default Value| Description| **System capability**: SystemCapability.HiviewDFX.HiAppEvent
| -------- | -------- | -------- |
| FAULT | 1 | Fault event| | Name | Default Value| Description |
| STATISTIC | 2 | Statistical event| | --------- | ------ | -------------- |
| SECURITY | 3 | Security event| | FAULT | 1 | Fault event|
| BEHAVIOR | 4 | Behavior event| | STATISTIC | 2 | Statistical event|
| SECURITY | 3 | Security event|
| BEHAVIOR | 4 | Behavior event|
## Event ## Event
Provides constants that define the names of all predefined events. Provides constants that define the names of all predefined events.
| Name| Type| Readable| Writable| Description| **System capability**: SystemCapability.HiviewDFX.HiAppEvent
| -------- | -------- | -------- | -------- | -------- |
| USER_LOGIN | string | Yes| No| User login event.| | Name | Type| Readable| Writable| Description |
| USER_LOGOUT | string | Yes| No| User logout event.| | ------------------------- | -------- | ---- | ---- | -------------------- |
| DISTRIBUTED_SERVICE_START | string | Yes| No| Distributed service startup event.| | 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.|
## Param ## Param
Provides constants that define the names of all predefined event parameters. Provides constants that define the names of all predefined event parameters.
| Name| Type| Readable| Writable| Description| **System capability**: SystemCapability.HiviewDFX.HiAppEvent
| -------- | -------- | -------- | -------- | -------- |
| USER_ID | string | Yes| No| Custom user ID.| | Name | Type| Readable| Writable| Description |
| DISTRIBUTED_SERVICE_NAME | string | Yes| No| Distributed service name.| | ------------------------------- | -------- | ---- | ---- | ------------------ |
| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes| No| Distributed service instance ID.| | 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.|
...@@ -12,24 +12,22 @@ import hidebug from '@ohos.hidebug'; ...@@ -12,24 +12,22 @@ import hidebug from '@ohos.hidebug';
``` ```
## System Capabilities
SystemCapability.HiviewDFX.HiProfiler.HiDebug
## hidebug.getNativeHeapSize ## hidebug.getNativeHeapSize
getNativeHeapSize(): bigint getNativeHeapSize(): bigint
Obtains the total size of the native heap memory. Obtains the total size of the native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
- **Return value** **Return Value**
| Type| Description|
| -------- | -------- |
| bigint | Total size of the native heap memory.|
| Type | Description |
| ------ | --------------------------- |
| bigint | Total size of the native heap memory.|
- **Example**
**Example**
``` ```
let nativeHeapSize = hidebug.getNativeHeapSize(); let nativeHeapSize = hidebug.getNativeHeapSize();
``` ```
...@@ -41,14 +39,16 @@ getNativeHeapAllocatedSize(): bigint ...@@ -41,14 +39,16 @@ getNativeHeapAllocatedSize(): bigint
Obtains the size of the allocated native heap memory. Obtains the size of the allocated native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
- **Return value**
| Type| Description|
| -------- | -------- |
| bigint | Size of the allocated native heap memory.|
**Return Value**
| Type | Description |
| ------ | --------------------------------- |
| bigint | Size of the allocated native heap memory.|
- **Example**
**Example**
``` ```
let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize();
``` ```
...@@ -60,14 +60,16 @@ getNativeHeapFreeSize(): bigint ...@@ -60,14 +60,16 @@ getNativeHeapFreeSize(): bigint
Obtains the size of the free native heap memory. Obtains the size of the free native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
- **Return value**
| Type| Description|
| -------- | -------- |
| bigint | Size of the free native heap memory.|
**Return Value**
| Type | Description |
| ------ | ------------------------------- |
| bigint | Size of the free native heap memory.|
- **Example**
**Example**
``` ```
let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize();
``` ```
...@@ -79,14 +81,16 @@ getPss(): bigint ...@@ -79,14 +81,16 @@ getPss(): bigint
Obtains the PSS of this process. Obtains the PSS of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
- **Return value**
| Type| Description|
| -------- | -------- |
| bigint | PSS of the process.|
**Return Value**
| Type | Description |
| ------ | ------------------------- |
| bigint | PSS of the process.|
- **Example**
**Example**
``` ```
let pss = hidebug.getPss(); let pss = hidebug.getPss();
``` ```
...@@ -98,14 +102,16 @@ getSharedDirty(): bigint ...@@ -98,14 +102,16 @@ getSharedDirty(): bigint
Obtains the size of the shared dirty memory of this process. Obtains the size of the shared dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
- **Return value**
| Type| Description|
| -------- | -------- |
| bigint | Size of the shared dirty memory of the process.|
**Return Value**
| Type | Description |
| ------ | -------------------------- |
| bigint | Size of the shared dirty memory of the process.|
- **Example**
**Example**
``` ```
let sharedDirty = hidebug.getSharedDirty(); let sharedDirty = hidebug.getSharedDirty();
``` ```
...@@ -117,11 +123,13 @@ startProfiling(filename : string) : void ...@@ -117,11 +123,13 @@ startProfiling(filename : string) : void
Starts the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. Starts the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes| User-defined profile name. The `filename.json` file is generated in the `files` directory of the application based on the specified `filename`.| | filename | string | Yes | User-defined profile name. The `filename.json` file is generated in the `files` directory of the application based on the specified `filename`.|
**Example** **Example**
...@@ -141,6 +149,8 @@ stopProfiling() : void ...@@ -141,6 +149,8 @@ stopProfiling() : void
Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Example** **Example**
```js ```js
...@@ -157,11 +167,13 @@ dumpHeapData(filename : string) : void ...@@ -157,11 +167,13 @@ dumpHeapData(filename : string) : void
Exports the heap data. Exports the heap data.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes| User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.| | filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.|
**Example** **Example**
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
> **Note:** > **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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -10,9 +10,6 @@ ...@@ -10,9 +10,6 @@
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
``` ```
## System Capabilities
SystemCapability.HiviewDFX.HiLog
## hilog.debug ## hilog.debug
...@@ -20,14 +17,16 @@ debug(domain: number, tag: string, format: string, ...args: any[]) : void ...@@ -20,14 +17,16 @@ debug(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the DEBUG level. Prints logs of the DEBUG level.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes| Service domain. The value ranges from **0x0** to **0xFFFFF**.| | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes| String constant used to identify the class or service behavior.| | tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes| String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| | format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.|
| args | any[] | Yes| Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| | args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.|
**Example** **Example**
...@@ -41,20 +40,22 @@ hilog.debug(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3 ...@@ -41,20 +40,22 @@ hilog.debug(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3
09-08 12:49:35.941 1547 2452 D FF00/testTag: 1: hello World 3.0 09-08 12:49:35.941 1547 2452 D FF00/testTag: 1: hello World 3.0
``` ```
## **hilog.info** ## hilog.info
info(domain: number, tag: string, format: string, ...args: any[]) : void info(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the INFO level. Prints logs of the INFO level.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes| Service domain. The value ranges from **0x0** to **0xFFFFF**.| | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes| String constant used to identify the class or service behavior.| | tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes| String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| | format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.|
| args | any[] | Yes| Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| | args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.|
**Example** **Example**
...@@ -74,14 +75,16 @@ warn(domain: number, tag: string, format: string, ...args: any[]) : void ...@@ -74,14 +75,16 @@ warn(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the WARN level. Prints logs of the WARN level.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes| Service domain. The value ranges from **0x0** to **0xFFFFF**.| | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes| String constant used to identify the class or service behavior.| | tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes| String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| | format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.|
| args | any[] | Yes| Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| | args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.|
**Example** **Example**
...@@ -101,14 +104,16 @@ error(domain: number, tag: string, format: string, ...args: any[]) : void ...@@ -101,14 +104,16 @@ error(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the ERROR level. Prints logs of the ERROR level.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes| Service domain. The value ranges from **0x0** to **0xFFFFF**.| | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes| String constant used to identify the class or service behavior.| | tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes| String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| | format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.|
| args | any[] | Yes| Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| | args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.|
**Example** **Example**
...@@ -128,14 +133,16 @@ fatal(domain: number, tag: string, format: string, ...args: any[]) : void ...@@ -128,14 +133,16 @@ fatal(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the FATAL level. Prints logs of the FATAL level.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ | | ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes| Service domain. The value ranges from **0x0** to **0xFFFFF**.| | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes| String constant used to identify the class or service behavior.| | tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes| String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.| | format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default.|
| args | any[] | Yes| Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.| | args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string.|
**Example** **Example**
...@@ -155,13 +162,15 @@ isLoggable(domain: number, tag: string, level: LogLevel) : boolean ...@@ -155,13 +162,15 @@ isLoggable(domain: number, tag: string, level: LogLevel) : boolean
Checks whether printing is enabled for a domain, tag, or log level. Checks whether printing is enabled for a domain, tag, or log level.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | --------------------- | ---- | ------------------------------------------ | | ------ | --------------------- | ---- | ------------------------------------------ |
| domain | number | Yes| Service domain. The value ranges from **0x0** to **0xFFFFF**.| | domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes| String constant used to identify the class or service behavior.| | tag | string | Yes | String constant used to identify the class or service behavior.|
| level | [LogLevel](#loglevel) | Yes| Log level.| | level | [LogLevel](#loglevel) | Yes | Log level. |
**Example** **Example**
...@@ -173,10 +182,12 @@ hilog.isLoggable(0xFF00, "testTag", hilog.DEBUG); ...@@ -173,10 +182,12 @@ hilog.isLoggable(0xFF00, "testTag", hilog.DEBUG);
Enumerates event types. Enumerates event types.
| Name| Default Value| Description| **System capability**: SystemCapability.HiviewDFX.HiLog
| Name | Default Value| Description |
| ----- | ------ | ----------- | | ----- | ------ | ----------- |
| DEBUG | 3 | DEBUG level| | DEBUG | 3 | DEBUG level|
| INFO | 4 | INFO level| | INFO | 4 | INFO level |
| WARN | 5 | WARN level| | WARN | 5 | WARN level |
| ERROR | 6 | ERROR level| | ERROR | 6 | ERROR level|
| FATAL | 7 | FATAL level| | FATAL | 7 | FATAL level|
...@@ -82,7 +82,7 @@ Starts call chain tracing. This API works in synchronous manner. ...@@ -82,7 +82,7 @@ Starts call chain tracing. This API works in synchronous manner.
| name | string | Yes| Traced service name.| | name | string | Yes| Traced service name.|
| flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag).| | flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag).|
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
...@@ -124,7 +124,7 @@ Obtains the trace ID. This API works in synchronous manner. ...@@ -124,7 +124,7 @@ Obtains the trace ID. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace **System capability**: SystemCapability.HiviewDFX.HiTrace
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
...@@ -184,7 +184,7 @@ Creates a trace span. This API works in synchronous manner. ...@@ -184,7 +184,7 @@ Creates a trace span. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace **System capability**: SystemCapability.HiviewDFX.HiTrace
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
...@@ -237,7 +237,7 @@ Checks whether a **HiTraceId** instance is valid. This API works in synchronous ...@@ -237,7 +237,7 @@ Checks whether a **HiTraceId** instance is valid. This API works in synchronous
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.|
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
...@@ -265,7 +265,7 @@ Checks whether the specified trace flag in the **HiTraceId** instance is enabled ...@@ -265,7 +265,7 @@ Checks whether the specified trace flag in the **HiTraceId** instance is enabled
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.|
| flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.| | flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.|
**Return value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
......
...@@ -11,21 +11,18 @@ import hiTraceMeter from '@ohos.hiTraceMeter'; ...@@ -11,21 +11,18 @@ import hiTraceMeter from '@ohos.hiTraceMeter';
``` ```
## System Capabilities
SystemCapability.HiviewDFX.HiTrace
## hiTraceMeter.startTrace ## hiTraceMeter.startTrace
startTrace(name: string, taskId: number): void startTrace(name: string, taskId: number): void
Starts a trace task. Starts a trace task. **expectedTime** is an optional parameter, which specifies the expected duration of the trace.
If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**.
If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For a specific example, refer to an example in [hiTraceMeter.finishTrace](#hitracemeterfinishtrace). If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For a specific example, refer to an example in [hiTraceMeter.finishTrace](#hitracemeterfinishtrace).
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -37,6 +34,7 @@ If the trace tasks with the same name are not performed at the same time, the sa ...@@ -37,6 +34,7 @@ If the trace tasks with the same name are not performed at the same time, the sa
``` ```
hiTraceMeter.startTrace("myTestFunc", 1); hiTraceMeter.startTrace("myTestFunc", 1);
hiTraceMeter.startTrace("myTestFunc", 1, 5); // The expected duration of the trace task is 5 ms.
``` ```
...@@ -48,6 +46,8 @@ Stops a trace task. ...@@ -48,6 +46,8 @@ Stops a trace task.
To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in [startTrace](#hitracemeterstarttrace). To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in [startTrace](#hitracemeterstarttrace).
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -90,6 +90,8 @@ traceByValue(name: string, count: number): void ...@@ -90,6 +90,8 @@ traceByValue(name: string, count: number): void
Traces the value changes of a variable. Traces the value changes of a variable.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册