1 Star 0 Fork 5.1K

戈英祯 / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
subsys-dfx-hisysevent.md 22.68 KB
一键复制 编辑 原始数据 按行查看 历史
duangavin123 提交于 2021-07-20 22:06 . update 导入OpenHarmony工程

Development Guidelines on HiSysEvent

Overview

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.

Available APIs

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

For details about the HiSysEvent class, see the API reference.

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 arguments:

  • 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) and uppercase letters (A-Z). 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 and cannot end with an underscore (_).
  • 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 and cannot end with an underscore (_). The number of parameter names cannot exceed 32.

Return value: Returns 0 if the operation is successful; returns a value less than 0 otherwise.

Table 2 Description of HiSysEvent::Domain APIs

API

Description

static const std::string AAFWK

Ability management framework

static const std::string APPEXECFWK

Application framework

static const std::string ACCOUNT

Account subsystem

static const std::string ACE

ACE subsystem

static const std::string AI

AI subsystem

static const std::string BARRIER_FREE

Accessibility subsystem

static const std::string BIOMETRICS

Biometric recognition subsystem

static const std::string CCRUNTIME

C/C++ operating environment subsystem

static const std::string COMMUNICATION

Communication subsystem

static const std::string DEVELOPTOOLS

Development toolchain subsystem

static const std::string DISTRIBUTED_DATAMGR

Distributed data management subsystem

static const std::string DISTRIBUTED_SCHEDULE

Distributed scheduler subsystem

static const std::string GLOBAL

Globalization subsystem

static const std::string GRAPHIC

Graphics subsystem

static const std::string HIVIEWDFX

DFX subsystem

static const std::string IAWARE

Scheduling and resource management subsystem

static const std::string INTELLI_ACCESSORIES

Smart accessory subsystem

static const std::string INTELLI_TV

Smart TV subsystem

static const std::string IVI_HARDWARE

IVI-dedicated hardware subsystem

static const std::string LOCATION

Location subsystem

static const std::string MSDP

MSDP subsystem

static const std::string MULTI_MEDIA

Multimedia subsystem

static const std::string MULTI_MODAL_INPUT

Multimodal input subsystem

static const std::string NOTIFICATION

Common event and notification subsystem

static const std::string POWERMGR

Power management subsystem

static const std::string ROUTER

Router subsystem

static const std::string SECURITY

Security subsystem

static const std::string SENSORS

Pan-sensor subsystem

static const std::string SOURCE_CODE_TRANSFORMER

Application porting subsystem

static const std::string STARTUP

Startup subsystem

static const std::string TELEPHONY

Telephony subsystem

static const std::string UPDATE

Update subsystem

static const std::string USB

USB subsystem

static const std::string WEARABLE_HARDWARE

Wearable-dedicated hardware subsystem

static const std::string WEARABLE

Wearable-dedicated service subsystem

static const std::string OTHERS

Others

Table 3 Description of HiSysEvent::EventType APIs

API

Description

FAULT

Fault event

STATISTIC

Statistical event

SECURITY

Security event

BEHAVIOR

System behavior event

How to Develop

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::FAULT, "app_name", "com.demo");
  2. Configure compilation information. Specifically, add the subsystem SDK dependency to BUILD.gn.

    external_deps = [ "hisysevent_native:libhisysevent" ]
1
https://gitee.com/geyingzhen/docs.git
git@gitee.com:geyingzhen/docs.git
geyingzhen
docs
docs
master

搜索帮助