3.4. Log & Alert¶
3.4.1. Log¶
- log_level¶
Logging level constants.
- const char *level_to_str(log_level level)¶
Convert a logging level to a human readable string.
Returns: A string representing the logging level. This string is constant and should not be freed.
- void message(log_level level, const wchar_t *module, const wchar_t *message)¶
Log a message without string formating.
- void messagef(log_level level, const wchar_t *module, const wchar_t *fmt, ...)¶
Log a message with string formating.
3.4.2. Alert¶
- struct alert
Structure used to describe the alert.
- time_us start_time¶
- time_us end_time¶
Alert times.
- alert_level severity¶
Severity of the alert.
- alert_level confidence¶
Confidence of the detection.
- double confidence_num¶
If confidence is HAKA_ALERT_NUMERIC, set this value as custom confidence value.
- alert_completion completion¶
Completion of the alert.
- struct alert_node **sources¶
NULL terminated list of alert sources.
- struct alert_node **targets¶
NULL terminated list of alert targets.
- size_t alert_ref_count¶
Number of external alert references.
- ALERT(name, nsrc, ntgt)¶
Construct a static alert description.
Parameters: - name – Name of the variable to create.
- nsrc – Number of sources.
- ntgt – Number of targets.
Example:
ALERT(invalid_packet, 1, 1) description: L"invalid tcp packet, size is too small", severity: HAKA_ALERT_LOW, ENDALERT
- ALERT_NODE(alert, mode, index, type, ...)¶
Append an alert node.
Parameters: - alert – Alert name.
- mode – sources or target.
- index – Index of the node.
- type – Type of node (see alert_node_type).
- ... – List of strings (wchar_t *).
Example:
ALERT_NODE(invalid_packet, sources, 0, HAKA_ALERT_NODE_ADDRESS, "127.0.0.1");
- ALERT_REF(alert, count, ...)¶
Append a list of alert references.
Parameters: - alert – Alert name.
- count – Number of references.
- ... – List of alert ids.
- ALERT_METHOD_REF(alert, ...)¶
Append a list of method references.
Parameters: - alert – Alert name.
- ... – List of strings (wchar_t *).
- uint64 alert(const struct alert *alert)
Raise a new alert.
Returns: A unique alert id.