提交 70ab54c3 编写于 作者: X xuyong

hisysevent tag订阅文档更新

Signed-off-by: Nxuyong <xuyong59@huawei.com>
上级 488ba472
......@@ -124,57 +124,57 @@ C++接口实例
自定义订阅回调实现类DemoListener:
```
#ifndef DEMO_LISTENER_H
#define DEMO_LISTENER_H
```
#ifndef DEMO_LISTENER_H
#define DEMO_LISTENER_H
#include "hisysevent_subscribe_callback_native.h"
#include "hisysevent_subscribe_callback_native.h"
#include <string>
#include <string>
class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBackNative {
public:
explicit DemoListener() : HiSysEventSubscribeCallBackNative() {}
void OnHandle(const std::string& domain, const std::string& eventName, const int eventType,
const std::string& eventDetail);
virtual ~DemoListener() {}
void OnServiceDied();
};
```
class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBackNative {
public:
explicit DemoListener() : HiSysEventSubscribeCallBackNative() {}
void OnHandle(const std::string& domain, const std::string& eventName, const int eventType,
const std::string& eventDetail);
virtual ~DemoListener() {}
void OnServiceDied();
};
```
实现订阅回调接口:
```
#include "demo_listener.h"
```
#include "demo_listener.h"
#include <iostream>
#include <iostream>
void DemoListener::OnHandle(const std::string& domain, const std::string& eventName,
const int eventType, const std::string& eventDetail)
{
std::cout << eventDetail << std::endl;
}
void DemoListener::OnHandle(const std::string& domain, const std::string& eventName,
const int eventType, const std::string& eventDetail)
{
std::cout << eventDetail << std::endl;
}
void DemoListener::OnServiceDied()
{
std::cout << std::string("service disconnect, exit") << std::endl;
exit(0);
}
```
void DemoListener::OnServiceDied()
{
std::cout << std::string("service disconnect, exit") << std::endl;
exit(0);
}
```
通过HiSysEventManager类提供的AddEventListener接口注册回调对象:
通过HiSysEventManager类提供的AddEventListener接口注册回调对象:
```
auto demoListener = std::make_shared<DemoListener>();
// 事件标签规则订阅,规则类型为默认的全词匹配类型
ListenerRule tagRule("dfx");
// 事件标签规则订阅,规则类型为正则匹配类型
ListenerRule regRule("dfx.*", RuleType::REGULAR);
// 事件领域及事件名称规则订阅,规则类型为前缀匹配类型
ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX);
std::vector<ListenerRule> sysRules;
sysRules.push_back(tagRule);
sysRules.push_back(regRule);
sysRules.push_back(domainNameRule);
HiSysEventManager::AddEventListener(demoListener, sysRules);
```
```
auto demoListener = std::make_shared<DemoListener>();
// 事件标签规则订阅,规则类型为默认的全词匹配类型
ListenerRule tagRule("dfx");
// 事件标签规则订阅,规则类型为正则匹配类型
ListenerRule regRule("dfx.*", RuleType::REGULAR);
// 事件领域及事件名称规则订阅,规则类型为前缀匹配类型
ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX);
std::vector<ListenerRule> sysRules;
sysRules.push_back(tagRule);
sysRules.push_back(regRule);
sysRules.push_back(domainNameRule);
HiSysEventManager::AddEventListener(demoListener, sysRules);
```
......@@ -17,7 +17,7 @@
### 基本概念<a name="section123181432175143"></a>
在配置HiSysEvent打点之前,开发者应了解下基本概念:
在配置HiSysEvent打点之前,开发者应了解下基本概念:
- 事件领域:用于标识事件所属的领域,在yaml文件中以domain为键值指定,可参考yaml文件样例中的[domain](#section123181432175123)
......@@ -28,7 +28,7 @@
### 约束与限制<a name="section123181432175114"></a>
**定义事件领域、事件名称及参数的约束限制:**
**定义事件领域、事件名称及参数的约束限制:**
- 事件领域:每个yaml文件只能有一个事件领域,且不能与其他事件领域重名。
......@@ -94,7 +94,7 @@
<p id="p877916477213"><a name="p877916477213"></a><a name="p877916477213"></a>desc</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.3.1.2 ">
<p id="p14727725133218"><a name="p14727725133218"></a><a name="p14727725133218"></a>字段作用:<br>&emsp;&emsp;必选字段,用来对该event进行描述。</p>
<p id="p14727725133218"><a name="p14727725133218"></a><a name="p14727725133218"></a>字段作用:<br>&emsp;&emsp;必选字段,用来对该事件名称进行描述。</p>
<p id="p167277525203215"><a name="p167277525203215"></a><a name="p167277525203215"></a>定义规则:</p>
<a name="ul6777142214921"></a><a name="ul6777142214921"></a>
<ul id="ul6777142214921">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册