Skip to content

Instantly share code, notes, and snippets.

@greyaperez
Created March 13, 2014 19:13
Show Gist options
  • Save greyaperez/9534885 to your computer and use it in GitHub Desktop.
Save greyaperez/9534885 to your computer and use it in GitHub Desktop.
Get nice output of the current relevant stack in your app. Insert this snippet anywhere in your code (ideally closer to the last class / method being called).
System.out.println("##################\n Relevant Stack\n##################");
for(StackTraceElement stackelement : Thread.currentThread().getStackTrace()){
String[] elementClass = stackelement.getClassName().split("\\.");
// Set Relevant Packages Here (com by default)
if( elementClass.length > 3 && elementClass[0].equals("com") ) {
System.out.println( stackelement.getClassName() + " :: " + stackelement.getMethodName() + "()");
}
}
System.out.println("##################\n [end] Relevant Stack\n##################\n\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment