Community
Participate
Working Groups
Hi, I'd like to be able to call a "log_enter" template inside the following method public void myMethod(String arg1, int arg2) { // ... } that should produce this result public void myMethod(String arg1, int arg2) { logger.debug("entering myClass.myMethod(" + arg1 + ", " + arg2 ")"); // ... } and a log_exit should add this line to all return points. logger.debug("returning from myClass.myMethod with " + returnValue); Now the ${enclosing_type} and ${enclosing_method} allow only part of this kind of logging. I found nothing like an ${enclosing_method_args} neither as a unique block neither as an "array". Another thing that is missing is the possibility to specify a location for the code insertion like a location:method_start/method_exit and I suppose multiple code insertion is not supported. Of course the actual logging text line should be customizable but this is already provided by the template functionality. I think adding a ${enclosing_method_args} and a ${enclosing_method_return_value} keywords should be enough to provide 90% of the functionality, with the first one being the most important. Maybe the "location" suggestion is not a good idea. The actual formatting of the args could be a fixed one. In this case it would be nice to be able to use both "old style" string concatenation and a varargs call. If some kind of iteration is provided the formatting could be defined "calling" another template. So I could define the log_enter template in this way logger.debug("entering ${enclosing_type}.${enclosing_method}(${call:format_args}); where format_args is another template with access to the same context of the caller where the actual formatting can take place. Another example could be ${log_exception}: called inside a catch should be able to log the current exception, already possibile, and methods args. Thanks, bye Lorenzo
*** This bug has been marked as a duplicate of bug 75407 ***