common_macro

Attribute Macro print_caller

source
#[print_caller]
Expand description

Attribute macro to print the caller to the annotated function. The caller is printed as its filename and the call site line number.

This macro works like this: inject the tracking codes as the first statement to the annotated function body. The tracking codes use backtrace-rs to get the callers. So you must dependent on the backtrace-rs crate.

§Arguments

  • depth: The max depth of call stack to print. Optional, defaults to 1.

§Example


#[print_caller(depth = 3)]
fn foo() {}