public class HiAppEvent extends Object
You need to customize event names, parameters, and types based on your own requirements.
The following is an example of the event logging code:
HiAppEvent.write("app_exception", HiAppEvent.EventType.FAULT, "num", 101, "reason", "connect fail");
| 限定符和类型 | 类 | 说明 |
|---|---|---|
class |
HiAppEvent.Event |
Preset event.
|
static class |
HiAppEvent.EventType |
Enumerates application event types.
|
class |
HiAppEvent.Param |
Preset param.
|
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
DISABLE |
Application event logging switch.
|
static String |
MAX_STORAGE |
Event file directory storage quota size.
|
| 构造器 | 说明 |
|---|---|
HiAppEvent() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static boolean |
configure(String name,
String value) |
Application event logging configuration interface, which is used to configure event logging switch,
event file directory storage quota size and other functions.
|
static int |
write(String eventName,
HiAppEvent.EventType type,
Object... keyValues) |
Implements asynchronous logging of application events whose parameters are of a variable length.
|
static int |
write(String eventName,
HiAppEvent.EventType type,
Map<String,Object> keyValues) |
Implements asynchronous logging of application events whose parameters are of the Map type.
|
public static int write(String eventName, HiAppEvent.EventType type, Object... keyValues)
eventName - Indicates the event name. You can customize the event name as needed.type - Indicates the event type, which is defined in EventType.keyValues - Indicates an array of event parameters, each of which is comprised of the parameter name and
parameter value. The parameter name must be a string, and the parameter value must be a basic data element,
a string, or a list (which can only be a basic data element or a string).0 if the event parameter verification is successful, and the event will be written to
the event file asynchronously; returns a positive integer if invalid parameters are present in the event, and
the event will be written to the event file asynchronously after the invalid parameters are ignored; returns a
negative integer if the event parameter verification fails, and the event will not be written to the event file
asynchronously.public static int write(String eventName, HiAppEvent.EventType type, Map<String,Object> keyValues)
eventName - Indicates the event name. You can customize the event name as needed.type - Indicates the event type, which is defined in EventType.keyValues - Indicates an array of event parameters, each of which is comprised of the parameter name and
parameter value. The parameter name must be a map key, and the parameter value must be a basic data element,
a string, or a list (which can only be a basic data element or a string).0 if the event parameter verification is successful, and the event will be written to
the event file asynchronously; returns a positive integer if invalid parameters are present in the event, and
the event will be written to the event file asynchronously after the invalid parameters are ignored; returns a
negative integer if the event parameter verification fails, and the event will not be written to the event file
asynchronously.public static boolean configure(String name, String value)
name - Configuration item name.value - Configuration item value.