Go to file
openharmony_ci 032502c2d8
!580 add accessibility_ue domain id
Merge pull request !580 from 李浔/master
2024-11-18 13:23:47 +00:00
adapter/native/idl rust接口相关代码回退 2024-08-05 08:43:25 +08:00
figures update OpenHarmony 2.0 Canary 2021-06-02 02:18:56 +08:00
frameworks/native bug: fix the leak of HiSysEventRecord 2024-11-15 10:27:35 +08:00
interfaces add accessibility_ue domain 2024-11-18 09:58:54 +08:00
test fix:add isObject verification before calling isMember or getMemberNames 2024-10-16 17:45:51 +08:00
.gitattributes update OpenHarmony 2.0 Canary 2021-06-02 02:18:56 +08:00
.gitignore rust代码添加Cargo.toml 2023-11-08 10:55:48 +08:00
bundle.json rust接口相关代码回退 2024-08-05 08:43:25 +08:00
Cargo.toml rust接口相关代码回退 2024-08-05 08:43:25 +08:00
LICENSE CodeCheck清理 2022-03-28 10:31:14 +08:00
OAT.xml add figures/* to OAT.xml 2021-09-29 15:56:44 +08:00
README_zh.md 移除hisysevent_native部件定义 2023-07-12 17:02:46 +08:00
README.md 移除hisysevent_native部件定义 2023-07-12 17:02:46 +08:00
rustfmt.toml rust代码添加Cargo.toml 2023-11-08 10:55:48 +08:00

HiSysEvent

Introduction

HiSysEvent provides event logging APIs for OpenHarmony to record important information of key processes during system running, helping you locate faults. In addition, you can upload the log data to the cloud for big data analytics.

Figure 1 HiSysEvent architecture

Directory Structure

/base/hiviewdfx/hisysevent   # HiSysEvent source code
├── adapter                  # Platform adaptation code
│  └── native               # native adaptation code
├── frameworks               # Framework code
│  └── native               # C/C++ APIs
├── interfaces               # External APIs
    └── native               # C++ APIs
        └── innerkits        # C++ APIs opened to internal subsystems

Description

Available APIs

The following table lists the C++ APIs provided by the HiSysEvent class.

Table 1 C++ APIs provided by HiSysEvent

API

Description

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

Logs system events.

Input parameters:

  • domain: Indicates the domain related to the event. You can use a preconfigured domain or customize a domain as needed. The name of a custom domain can contain a maximum of 16 characters, including digits (0-9), lowercase letters (a-z), uppercase letters (A-Z), and underscores (_). It must start with a letter.
  • eventName: Indicates the event name. The value contains a maximum of 32 characters, including digits (0 to 9), lowercase letters (a-z), uppercase letters (A-Z), and underscores (_). It must start with a letter.
  • type: Indicates the event type. For details, see EventType.
  • keyValues: Indicates the key-value pairs of event parameters. It can be in the format of the basic data type, std::string, std::vector<basic data type>, or std:vector<std::string>. The value contains a maximum of 48 characters, including digits (0 to 9), lowercase letters (a-z), uppercase letters (A-Z), and underscores (_). It must start with a letter. The number of parameters cannot exceed 128.

Return value: If the operation is successful, 0 is returned. If the operation fails, a negative value is returned.

Sample Code

C++

  1. Develop the source code.

    Include the HiSysEvent header file in the class definition header file or class implementation source file. For example:

    #include "hisysevent.h"
    

    Add the event logging code. For example, if you want to log events specific to the app start time start\_app, then add the following code to the service implementation source file:

    HiSysEvent::Write(HiSysEvent::Domain::AAFWK, "start_app", HiSysEvent::EventType::BEHAVIOR, "app_name", "com.demo");
    
  2. Configure compilation information. Specifically, add the subsystem SDK dependency to BUILD.gn.

    external_deps = [ "hisysevent:libhisysevent" ]
    

Repositories Involved

DFX subsystem

hiviewdfx_hiview

hiviewdfx_hilog

hiviewdfx_hiappevent

hiviewdfx_hisysevent

hiviewdfx_faultloggerd

hiviewdfx_hilog_lite

hiviewdfx_hievent_lite

hiviewdfx_hiview_lite