How would I go about making every method call of every groovy class of mine print “Entering ${methodname}” as it enters the method call?
Without having to wrap every new object I create with new TracingDecorator(new Object())?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’d need to override metaClass.invokeMethod on all of your classes and have it wrap the method call to the original class with your tracing stuff.
You could probably spin through the class list that you get from the classloader matching some sort of naming/package pattern and then for each of those do something like this decorateMethodsWithLogging:
this prints