Created
October 9, 2017 19:16
-
-
Save jakubhalun/ebee2722029e04d44e30b7fd9b7a0779 to your computer and use it in GitHub Desktop.
Interceptor logs method execution and its parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void intercept(@AllArguments Object[] allArguments, | |
@Origin Method method) { | |
Logger logger = LoggerFactory.getLogger(method.getDeclaringClass()); | |
logger.info("Method {} of class {} called", method.getName(), method | |
.getDeclaringClass().getSimpleName()); | |
for (Object argument : allArguments) { | |
logger.info("Method {}, parameter type {}, value={}", | |
method.getName(), argument.getClass().getSimpleName(), | |
argument.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment