List of usage examples for java.lang StackTraceElement getMethodName
public String getMethodName()
From source file:Main.java
public static String getLineMethod() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[2]; StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getLineNumber()).append(" | ") .append(traceElement.getMethodName()).append("]"); return toStringBuffer.toString(); }
From source file:com.clustercontrol.selfcheck.monitor.ThreadActivityMonitor.java
private static String getStackTrace(Thread t) { StackTraceElement[] eList = t.getStackTrace(); StringBuilder trace = new StringBuilder(); for (StackTraceElement e : eList) { trace.append("\n\tat "); trace.append(e.getClassName() + "." + e.getMethodName() + "(" + e.getFileName() + ":" + e.getLineNumber() + ")"); }//from ww w . j a v a 2 s . co m return trace.toString(); }
From source file:Main.java
/** * Formats a stack trace into a single line that provides relevant information for debugging * @param element the element to format/*from www.j a va 2 s. co m*/ * @return a well-formatted stack-trace line containing the class name, method name, and line number * that, when clicked in the logcat, will display the line or source from where the message originated. */ public static String formatStackTrace(StackTraceElement element) { StringBuilder b = new StringBuilder(); b.append(" at "); String clazz = element.getClassName(); b.append(clazz).append("."); b.append(element.getMethodName()).append("("); b.append(clazz.substring(clazz.lastIndexOf(".") + 1)).append(".java:"); b.append(element.getLineNumber()).append(")").append(" , ##"); return b.toString(); }
From source file:Main.java
public static String getFileLineMethod() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[2]; StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getFileName()).append(" | ") .append(traceElement.getLineNumber()).append(" | ").append(traceElement.getMethodName()) .append("]"); return toStringBuffer.toString(); }
From source file:Main.java
private static String generateTag(StackTraceElement caller) { String tag = "%s.%s(L:%d)"; String callerClazzName = caller.getClassName(); callerClazzName = callerClazzName.substring(callerClazzName.lastIndexOf(".") + 1); tag = String.format(tag, callerClazzName, caller.getMethodName(), caller.getLineNumber()); tag = TextUtils.isEmpty(customTagPrefix) ? tag : customTagPrefix + ":" + tag; return tag;//from w w w . j a v a 2s. co m }
From source file:Main.java
private static String getTag(Exception exception) { StackTraceElement traceElement = ((exception).getStackTrace())[1]; StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getFileName()).append(" | ") .append(traceElement.getLineNumber()).append(" | ").append(traceElement.getMethodName()) .append("()").append("]"); String TAG = toStringBuffer.toString(); return TAG;/*w w w. ja v a 2 s . c o m*/ }
From source file:Main.java
private static void print(StackTraceElement element, Object message, Throwable error) { String className = element.getClassName(); className = className.substring(className.lastIndexOf(".") + 1); String tag = className + '.' + element.getMethodName() + '(' + element.getFileName() + ':' + element.getLineNumber() + ')'; String text = toString(message); if (error != null) { Log.e("[KakaCache]", tag + "\n\t" + text, error); } else {/*from w w w. j a v a 2s . co m*/ Log.e("[KakaCache]", tag + "\n\t" + text); } }
From source file:Main.java
public static String getThreadStack(Thread t) { StackTraceElement[] stacks = t.getStackTrace(); StringBuffer buffer = new StringBuffer(); for (StackTraceElement stack : stacks) { String filename = stack.getFileName(); if (filename == null) { filename = "NULL"; }//from w ww . j a v a 2 s .c o m String className = stack.getClassName(); String methodName = stack.getMethodName(); int line = stack.getLineNumber(); buffer.append(String.format("%s.%s(%s:%d)\r", className, methodName, filename, line)); } return buffer.toString(); }
From source file:Main.java
public static String getFileLineMethod() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[1]; StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getFileName()).append(" | ") .append(traceElement.getLineNumber()).append(" | ").append(traceElement.getMethodName()) .append("()").append("]"); return toStringBuffer.toString(); }
From source file:Main.java
private static String rebuildMsg(StackTraceElement stackTraceElement, String msg) { StringBuffer sb = new StringBuffer(); sb.append(stackTraceElement.getFileName()); sb.append(" ("); sb.append(stackTraceElement.getLineNumber()); sb.append(") "); sb.append(stackTraceElement.getMethodName()); sb.append(": "); sb.append(msg);/* ww w. j a v a 2s.c om*/ return sb.toString(); }