Log Exception trace
class Log {
public static final String TAG = "tag";
public static void debug(String tag, String content) {
StackTraceElement[] trace = new Throwable().getStackTrace();
String msg = "";
if (trace.length >= 1) {
StackTraceElement elt = trace[1];
msg = "[" + elt.getFileName() + " Line:" + elt.getLineNumber()
+ "] " + elt.getMethodName() + " " + content;
android.util.Log.i(tag, msg);
} else {
android.util.Log.i(tag, msg);
}
}
public static void error(String tag, String content) {
StackTraceElement[] trace = new Throwable().getStackTrace();
String msg = "";
if (trace.length >= 1) {
StackTraceElement elt = trace[1];
msg = "[" + elt.getFileName() + " Line:" + elt.getLineNumber()
+ "] " + elt.getMethodName() + " " + content;
android.util.Log.e(tag, msg);
} else {
android.util.Log.e(tag, msg);
}
}
}
Related examples in the same category