Androdi 封装Log类

sancaiodm Android源码学习 2021-11-30 1284 0

下类会在输出信息中打印当前类及所在的方法名


public class LogUtils {

    public static String TAG = "shoujidom";

    public static void logi(Object object) {

        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();

        String fileName = stackTrace[3].getFileName();

        String methodName = stackTrace[3].getMethodName();

        object = "[" +fileName + "] " + "[" + methodName + "] " + object;

        Log.i(TAG, object + "");

    }

}


评论