public static void print(String text){
boolean debug = true;
if (debug) {
Context context = BaseApp.getContext();
StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[3];
// 获取类名.即包名+类名
String className = stackTraceElement.getClassName();
// 获取方法名称
String methodName = stackTraceElement.getMethodName();
// 获取生日输出行数
int lineNumber = stackTraceElement.getLineNumber();
String log = className + "->" + methodName + "(), line=" + lineNumber + ": " + text;
String tag = getLastSubStringFromSplit(context.getPackageName(), "."); // 获取报名(自定义方法)
Log.v(tag, log);
}
}
转载于:https://www.cnblogs.com/ftrako/p/5150038.html