macro_rules! trace_event {
    ($category:ident, $name:literal, $($arg:expr),+) => { ... };
    ($category:ident, $name:expr) => { ... };
}
Expand description

Returns a Trace object with a new name and index and traces its enter state, if the given category identifier is enabled. Extra args can be provided for easier debugging. Upon exiting its scope, it is automatically collected and its exit gets traced.

If the category identifier is not enabled for this event, nothing happens and the trace event is skipped.

Example usage

{
   let _trace = trace_event!(Category, "exec", param1, param2);

   // ... Rest of code ...

   // End of `_trace`'s lifetime so `trace_event_end` is called.
}

This will output in trace_marker:

  • $uid: $category Enter: exec - (param1: ...)(param2: ...)

and when _trace runs out of scope, it will output:

  • $uid: Exit: exec

where $uid will be the same unique value across those two events.