Skip to main content

Crate data_hook

Crate data_hook 

Source
Expand description

§Data Hook

A lightweight data collection facade similar to the log crate.

The data_hook crate provides a simple API for collecting data that abstracts over the actual data processing implementation. Libraries can use the data collection API provided by this crate, and the consumer can choose the collector implementation that is most suitable for their use case.

If no collector implementation is selected, the facade falls back to a “noop” implementation that ignores all data collection requests. The overhead in this case is very small - just an integer load, comparison and jump.

§Usage

The basic use of the data_hook crate is through the data_hook! macro:

use data_hook::data_hook;

data_hook!("user_action", "User clicked button: {}", "submit");
data_hook!("performance", "Request took {} ms", 150);

§Collectors

Data hook supports pluggable collectors through the Collect trait. The consumer of libraries using data_hook should provide a collector implementation.

Macros§

data_hook
The main data collection macro

Structs§

Record
A data record containing collected information

Traits§

Collect
Trait for data collectors

Functions§

collect
Collect data using the global collector
set_collector
Set the global data collector