I\'m using Groovy 1.8.4, trying to get the name of the enclosing function...
def myFunction() {
println functionName??
}
I\'ve tried
@CompileStatic
class LogUtils {
// can be called the Groovy or Java way
public static String getCurrentMethodName(){
StackTraceElement[] stackTrace = StackTraceUtils.sanitize(new Throwable()).stackTrace
stackTrace[2].methodName != 'jlrMethodInvoke' ? stackTrace[2].methodName : stackTrace[3].methodName
}
}