Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

JoinPoint Context

The JoinPoint struct provides metadata about the function being executed.

Definition

#![allow(unused)]
fn main() {
pub struct JoinPoint {
    pub function_name: &'static str,
    pub module_path: &'static str,
    pub file: &'static str,
    pub line: u32,
}
}

Example

#![allow(unused)]
fn main() {
impl Aspect for LoggingAspect {
    fn before(&self, ctx: &JoinPoint) {
        println!("[{}] {}::{} at {}:{}",
            chrono::Utc::now(),
            ctx.module_path,
            ctx.function_name,
            ctx.file,
            ctx.line
        );
    }
}
}

See The Aspect Trait for more context.