0

Getting Execution Function name for debugging.

FROM: JAVA FORUM

The "standard" way to accomplish this is to raise an Exception and then parse its stack-trace. If you encapsulate that inside your "myDebugger()" call, you'd want the second method on the stack. Take a look at StackElement (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackTraceElement.html) for the kind of info you can get.There are aspect-oriented libraries out there that hide this from you - you could look at them for entry/exit debuging.Or, you could use CPP and just plug __FILE__ and __LINE__ into your code...Grant

class Debugger {
public static String getWhoCalledMe() {
StackTraceElement
stack[] = new Throwable().getStackTrace();
return
(stack[1].getMethodName());
}
}

|

0 Comments

Copyright © 2009 So That I Can Remember All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.