/*
 * MIT License
 *
 * Copyright (c) 2016 Yan QiDong
 */

package org.no_creativity.aar.alog;

import android.util.Log;

/**
 * It is a wrapper of {@link Log}, which provides some useful functions.
 *
 * @author yanqd0
 */
public abstract class ALog {
    private static final int TRACE_POSITION = 4;
    private static final String ERROR_INFO = "UNKNOWN_FILE.UNKNOWN_METHOD() ";

    private final String TAG;
    private final boolean DEBUG;

    protected ALog(String tag, boolean debug) {
        TAG = tag;
        DEBUG = debug;
    }

    private static String getThreadInfo() {
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        StackTraceElement element;
        try {
            element = stackTrace[TRACE_POSITION];
        } catch (IndexOutOfBoundsException e) {
            return ERROR_INFO;
        }
        return getFileName(element) + "." + element.getMethodName() + "() ";
    }

    private static String getFileName(StackTraceElement element) {
        String file = element.getFileName();
        return file.substring(0, file.lastIndexOf("."));
    }

    @SuppressWarnings("WeakerAccess")
    public void v() {
        if (DEBUG) {
            Log.v(TAG, getThreadInfo());
        }
    }

    @SuppressWarnings("WeakerAccess")
    public void d(String message) {
        if (DEBUG) {
            Log.d(TAG, getThreadInfo() + message);
        }
    }

    @SuppressWarnings("WeakerAccess")
    public void w(Throwable th) {
        if (DEBUG) {
            Log.w(TAG, getThreadInfo() + th.getMessage());
        }
    }
}

@@ -439,16 +439,181 @@
 DEBUG;%0A%0A
+    /**%0A     * The constructor is only used by extending.%0A     *%0A     * @param tag The global tag.%0A     * @param debug The environment is debuggable or not.%0A     */%0A
     prot
@@ -648,24 +648,24 @@
 an debug) %7B%0A
-
         TAG 
@@ -1266,32 +1266,141 @@
 f(%22.%22));%0A    %7D%0A%0A
+    /**%0A     * To show the file and method name only.%0A     * %3Cp%3E%0A     * It's logged only when debug.%0A     */%0A
     @SuppressWar
@@ -1514,32 +1514,147 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * @param message The information to be logged.%0A     * %3Cp%3E%0A     * It's logged only when debug.%0A     */%0A
     @SuppressWar
@@ -1796,24 +1796,197 @@
    %7D%0A    %7D%0A%0A
+    /**%0A     * To print the message of %7B@link Throwable%7D.%0A     * %3Cp%3E%0A     * It's logged only when debug.%0A     *%0A     * @param th The %7B@link Throwable%7D to be logged.%0A     */%0A
     @Suppres

Add some java docs.