# hiviewdfx_hisysevent **Repository Path**: lidalonggit/hiviewdfx_hisysevent ## Basic Information - **Project Name**: hiviewdfx_hisysevent - **Description**: System event logging | 系统事件记录接口 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 194 - **Created**: 2024-11-18 - **Last Updated**: 2024-12-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HiSysEvent组件 - [简介](#section11660541593) - [目录](#section161941989596) - [说明](#section1312121216216) - [接口说明](#section1551164914237) - [使用说明](#section129654513264) - [相关仓](#section1371113476307) ## 简介 HiSysEvent提供OpenHarmony埋点接口,通过在关键路径埋点记录系统在运行过程中的重要信息,辅助开发者定位问题,此外还支持开发者将数据上传到云进行大数据质量度量。 **图 1** HiSysEvent架构图 ![](figures/zh-cn_image_0000001115534248.png) ## 目录 ``` /base/hiviewdfx/hisysevent # hisysevent部件代码 ├── adapter # 平台适配 │ └── native # C++适配 ├── frameworks # 框架代码 │ └── native # 对内部子系统暴露的C++接口 ├── interfaces # 对外接口存放目录 └── native # C++接口 └── innerkits # 对内部子系统暴露的C++接口 ``` ## 说明 ### 接口说明 C++埋点接口如下: **表 1** HiSysEvent接口介绍

接口名

描述

template<typename... Types> static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues)

接口功能:记录系统事件。

输入参数:

  • domain:事件的相关领域,需要使用预置领域请参考Domain,可自定义领域。自定义领域长度在16个字符以内,有效的字符是0-9、a-z, A-Z、_,以字母开头。
  • eventName:事件名,长度在32个字符以内,有效的字符是0-9、a-z, A-Z、_,以字母开头。
  • type:事件类型,参考EventType。
  • keyValues:事件参数键值对,支持基本类型、std::string,以及std::vector<基本类型>、std:vector<std::string>。参数名长度在48个字符以内,有效的字符是0-9、a-z, A-Z、_,以字母开头。事件参数键值对的个数不超过128个。

返回值:成功返回0,错误返回小于0的值。

### 使用说明 C++接口实例 1. 源代码开发 在类定义头文件或者类实现源文件中,包含HiSysEvent头文件: ``` #include "hisysevent.h" ``` 假设在业务关注应用启动时间start\_app,在业务类实现相关源文件中使用(调用接口埋点): ``` HiSysEvent::Write(HiSysEvent::Domain::AAFWK, "start_app", HiSysEvent::EventType::BEHAVIOR, "app_name", "com.demo"); ``` 2. 编译设置,在BUILD.gn里增加子系统SDK依赖: ``` external_deps = [ "hisysevent:libhisysevent" ] ``` ## 相关仓 [DFX子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/DFX%E5%AD%90%E7%B3%BB%E7%BB%9F.md) [hiviewdfx\_hiview](https://gitee.com/openharmony/hiviewdfx_hiview/blob/master/README_zh.md) [hiviewdfx\_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README_zh.md) [hiviewdfx\_hiappevent](https://gitee.com/openharmony/hiviewdfx_hiappevent/blob/master/README_zh.md) **hiviewdfx\_hisysevent** [hiviewdfx\_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README_zh.md) [hiviewdfx\_hilog\_lite](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README_zh.md) [hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README_zh.md) [hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README_zh.md)