提交 0644bb3a 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 d253f86e
......@@ -89,7 +89,7 @@ Writes event information to the event file. This API uses a promise to return th
| Name | Type | Mandatory| Description|
| --------- | ----------------------- | ---- | --------------- |
| eventType | [EventType](#eventtype) | Yes | Application event type.|
| info | [SysEventInfo](#syseventinfo) | Yes | System event information.|
**Return value**
......
# Internationalization – I18N
This module provides system-related or enhanced I18N capabilities, such as locale management, phone number formatting, and calendar, through supplementary I18N APIs that are not defined in ECMA 402.
The [Intl](js-apis-intl.md) module provides basic I18N capabilities through the standard I18N APIs defined in ECMA 402. It works with the I18N module to provide a complete suite of I18N capabilities.
> **NOTE**
>
> - 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.
>
> - This module provides system-related or enhanced I18N capabilities, such as locale management, phone number formatting, and calendar, through supplementary I18N interfaces that are not defined in ECMA 402. For details about the basic I18N capabilities, see [Intl](js-apis-intl.md).
> 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
......
# Internationalization – Intl
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N interfaces defined in ECMA 402. For details about the enhanced I18N capabilities, see [I18N](js-apis-i18n.md).
This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N APIs defined in ECMA 402.
The [I18N](js-apis-i18n.md) module provides enhanced I18N capabilities through supplementary APIs that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities.
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......
# HiSysEvent Query<a name="EN-US_TOPIC_0000001231455461"></a>
# HiSysEvent Query
## Overview<a name="section279684125212"></a>
HiSysEvent provides an API for you to query system events. You can query concerned events by specifying search criteria. For example, for a power consumption module, you can query required system events for analysis.
## Overview
## Development Guidelines<a name="section315316761113"></a>
HiSysEvent allows you to query system events by specifying search criteria. For example, for a power consumption module, you can query required system events for analysis.
### Available APIs<a name="section03869128521"></a>
**Table 1** Description of the HiSysEvent query API
## Development Guidelines
| Name| Description |
| -------- | --------- |
| int32_t HiSysEventManager::QueryHiSysEvent(struct QueryArg&amp; queryArg, std::vector&lt;QueryRule&gt;&amp; queryRules, std::shared_ptr&lt;HiSysEventQueryCallBack&gt; queryCallBack) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.<br><br>Input arguments:<ul><li>**queryArg**: event query parameter. </li><li>**queryRules**: event filtering rules. </li><li>**queryRules**: callback object for query results. </li></ul>Return value:<ul><li>**0**: The query is successful. </li><li>Other values: The query has failed.</li></ul> |
### Available APIs
**Table 2** Description of QueryArg
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> For details about the **HiSysEventRecord** argument in the **OnQuery()** method of **HiSysEventQueryCallback**, see Table 5 in [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md).
| Attribute| Description |
| -------- | --------- |
| beginTime | Start time, in the **long long int** format.|
| endTime | End time, in the **long long int** format.|
| maxEvents | Maximum number of returned events, in the **int** format.|
**Table 3** Description of QueryRule
| API| Description |
| -------- | --------- |
| QueryRule(const std::string& domain, const std::vector&lt;std::string&gt;& eventList) | Constructor used to create a **QueryRule** object.<br><br>Input arguments:<ul><li>**domain: domain to which the event of the **QueryRule** object belongs, in the **string** format. By default, an empty string indicates that the domain is successfully matched. </li><li>**eventList**: event name list, in the **std::vector&lt;std::string&gt;** format. By default, an empty string indicates that the event names on the list are successfully matched.</li></ul> |
**Table 4** Description of HiSysEventQueryCallBack
| API| Description |
| -------- | --------- |
| void HiSysEventQueryCallBack::OnQuery(const ::std::vector&lt;std::string&gt;&amp; sysEvent, const ::std::vector&lt;int64_t&gt;&amp; seq) | Callback object for event query.<br><br>Input arguments:<ul><li>**sysEvent**: event set. </li><li>**seq**: event sequence set. </li></ul>Return value:<br>None.|
| void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.<br><br>Input arguments:<ul><li>**reason**: reason for completion of event query. The default value is **0**. </li><li>**total**: total number of events returned in this query. </li></ul>Return value:<br>None.|
### Development Example<a name="section14286111855212"></a>
C++
1. Develop the source code.
- Import the corresponding header file:
**Table 1** Description of the HiSysEvent query API
hisysevent\_manager.h
| API| Description|
| -------- | -------- |
| int32_t HiSysEventManager::Query(struct QueryArg&amp; arg, std::vector&lt;QueryRule&gt;&amp; rules, std::shared_ptr&lt;HiSysEventQueryCallback&gt; callback) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.<br>Input arguments:<br>- **arg**: event query parameter.<br>- **rules**: rules for event filtering.<br>- **callback**: callback object for event query.<br>Return value:<br>- **0**: Query is successful.<br>- A negative value: Query has failed.|
- Implement the callback API.
**Table 2** Description of QueryArg
void HiSysEventQueryCallBack::OnQuery\(const ::std::vector&lt;std::string&gt;& sysEvent, const ::std::vector<int64\_t\>& seq\)
void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\)
- Invoke the query API in the corresponding service logic.
HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector<QueryRule\>& queryRules, std::shared\_ptr<HiSysEventQueryCallBack\> queryCallBack\)
```
// In this example, you'll query all system events.
#include "hisysevent_manager.h"
#include <iostream>
namespace OHOS {
namespace HiviewDFX {
// Implement the query callback API.
void HiSysEventToolQuery::OnQuery(const ::std::vector<std::string>& sysEvent,
const ::std::vector<int64_t>& seq)
{
for_each(sysEvent.cbegin(), sysEvent.cend(), [](const std::string &tmp) {
std::cout << tmp << std::endl;
});
}
void HiSysEventToolQuery::OnComplete(int32_t reason, int32_t total)
{
return;
}
} // namespace HiviewDFX
} // namespace OHOS
// Invoke the query callback API to obtain system events.
std::shared_ptr<HiSysEventToolQuery> queryCallBack = nullptr;
try {
queryCallBack = std::make_shared<HiSysEventToolQuery>();
} catch(...) {
// Catch exception thrown by make_shared
}
if (queryCallBack != nullptr) {
struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents);
std::vector<QueryRule> rules;
HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack);
}
```
2. Modify the **BUILD.gn** file.
In the **BUILD.gn** file, add the **libhisyseventmanager** library that depends on the **hisysevent\_native** component.
| Attribute| Description|
| -------- | -------- |
| beginTime | Start time, in the **long long int** format.|
| endTime | End time, in the **long long int** format.|
| maxEvents | Maximum number of returned events, in the **int** format.|
```
external_deps = [ "hisysevent_native:libhisyseventmanager", ]
```
**Table 3** Description of QueryRule
| API| Description|
| -------- | -------- |
| QueryRule(const std::string&amp; domain, const std::vector&lt;std::string&gt;&amp; eventList) | Constructor used to create a **QueryRule** object.<br>Input arguments:<br>- **domain**: domain to which the event of the **QueryRule** object belongs, in the string format. By default, an empty string indicates that the domain is successfully matched.<br>- **eventList**: event name list, in the **std::vector&lt;std::string&gt;** format. By default, an empty string indicates that the event names on the list are successfully matched.|
**Table 4** Description of HiSysEventQueryCallback
| API| Description|
| -------- | -------- |
| void HiSysEventQueryCallback::OnQuery(std::shared_ptr&lt;std::vector&lt;HiSysEventRecord&gt;&gt; sysEvents) | Callback object for event query.<br>Input arguments:<br>- **sysEvents**: event list.<br>Return value:<br>None.|
| void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.<br>Input arguments:<br>- **reason**: reason for completion of event query. The default value is **0**.<br>- **total**: total number of events returned in this query.<br>Return value:<br>None.|
### How to Develop
**C++**
1. Develop the source code.
Import the corresponding header file:
```
#include "hisysevent_manager.h"
```
Implement the callback API.
```
void HiSysEventQueryCallback::OnQuery(std::shared_ptr<std::vector<HiSysEventRecord>> sysEvents)
void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total)
```
Invoke the query API in the corresponding service logic.
```
HiSysEventManager::Query(struct QueryArg& queryArg,
std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallback> queryCallBack)
```
In this example, you'll query all system events.
```
#include "hisysevent_manager.h"
#include <iostream>
namespace OHOS {
namespace HiviewDFX {
// Implement the query callback API.
void HiSysEventToolQuery::OnQuery(std::shared_ptr<std::vector<HiSysEventRecord>> sysEvents)
{
if (sysEvents == nullptr) {
return;
}
for_each((*sysEvents).cbegin(), (*sysEvents).cend(), [](const HiSysEventRecord& event) {
std::cout << event.AsJson() << std::endl;
});
}
void HiSysEventToolQuery::OnComplete(int32_t reason, int32_t total)
{
return;
}
} // namespace HiviewDFX
} // namespace OHOS
// Invoke the query callback API to obtain system events.
auto queryCallBack = std::make_shared<HiSysEventToolQuery>();
struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents);
std::vector<QueryRule> rules;
HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack);
```
2. Modify the **BUILD.gn** file.
In the **BUILD.gn** file, add the **libhisysevent** and **libhisyseventmanager** libraries that depend on the **hisysevent_native** component.
```
external_deps = [
"hisysevent_native:libhisysevent",
"hisysevent_native:libhisyseventmanager",
]
```
......@@ -17,7 +17,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin**
| Option| Description|
| -------- | -------- |
| -r | Subscribes to real-time system events based on the default settings. When this option is specified, any real-time system event will be printed on the console.|
| -r | Subscription to real-time system events based on the default settings. When this option is specified, any real-time system event will be printed on the console.|
- Command for enabling the debugging mode:
......@@ -29,7 +29,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin**
| Option| Description|
| -------- | -------- |
| -d | Subscribes to real-time system events in debugging mode.|
| -d | Subscription to real-time system events in debugging mode.|
- Command for subscribing to real-time system events by event tag:
......@@ -96,7 +96,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin**
| Option| Description|
| -------- | -------- |
| -l | Queries historical system events based on the default settings. A maximum of 1,000 latest system events will be returned.|
| -l | Query of historical system events based on the default settings. A maximum of 10,000 system events will be returned.|
- Command for querying historical system events within the specified period of time:
......@@ -130,7 +130,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin**
| Option| Description|
| -------- | -------- |
| -m | Maximum number of historical system events that can be queried. The value ranges from **0** to **1000**. The number of returned system events is not more than the value of this parameter.|
| -m | Maximum number of historical system events that can be queried. The number of returned system events is not more than the value of this parameter.|
Example:
......@@ -151,7 +151,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin**
| Option| Description|
| -------- | -------- |
| -v | Used with the subscription command **-r** and query command **-l**. If system event validity check is enabled, invalid content contained in system events will be highlighted in red.|
| -v | Used with the **-r** and **-l** commands. If system event validity check is enabled, invalid content contained in system events will be highlighted in red.|
Example:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册