import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
/**
* Aspect to log the message when object is saved
*/
@Slf4j
@Aspect
@Component
public class MyLoggerAspect {
// "obj" is object_which_is_saved_in_save_method i.e in com.foo.save(*)
@After("execution(* com.foo.save(*)) && args(obj)")
public void logAfterSavingTheObject(CustomObject obj) {
log.info("Logging after the CustomObject is saved, id : {}", obj.getId())
}
}