Created
June 24, 2015 17:13
-
-
Save pietrocaselani/ec35a2cc146f56b06f26 to your computer and use it in GitHub Desktop.
DebugUtils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void printStackTrace(Throwable exception) { | |
if (DEBUG) { | |
String fullClassName = exception.getStackTrace()[2].getClassName(); | |
String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1); | |
String methodName = exception.getStackTrace()[2].getMethodName(); | |
int lineNumber = exception.getStackTrace()[2].getLineNumber(); | |
Log.v("DebugUtils", className + "." + methodName + "():" + lineNumber + ":\nMessage:" + exception.getLocalizedMessage()); | |
for (StackTraceElement stackTraceElement : exception.getStackTrace()) { | |
Log.e("DebugUtils", stackTraceElement.toString()); | |
} | |
Log.e("DebugUtils", exception.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment