Skip to content

Instantly share code, notes, and snippets.

@manicmonkey
Last active December 27, 2015 07:49
Show Gist options
  • Save manicmonkey/7291397 to your computer and use it in GitHub Desktop.
Save manicmonkey/7291397 to your computer and use it in GitHub Desktop.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author jbaxter - 2013-10-29
*/
public aspect Trace {
private static final Logger log = LoggerFactory.getLogger("com.manicmonkey.profiling");
pointcut profiledMethods():
execution(@com.manicmonkey.Profiled * com.manicmonkey..*(..));
Object around(): profiledMethods() {
long start = System.currentTimeMillis();
try {
return proceed();
} finally {
long end = System.currentTimeMillis();
log.debug(thisJoinPoint.getSignature().getDeclaringTypeName() + "." + thisJoinPoint.getSignature().getName() + " took " + (end - start) + " milliseconds");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment