Last active
August 29, 2015 14:04
-
-
Save yelinaung/8b7c92a4c36c3a9f8c17 to your computer and use it in GitHub Desktop.
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 class L { | |
| private static final String LOG_PREFIX = "ys_"; | |
| private static final int LOG_PREFIX_LENGTH = LOG_PREFIX.length(); | |
| private static final int MAX_LOG_TAG_LENGTH = 23; | |
| public L() { | |
| } | |
| public static String makeLogTag(String str) { | |
| if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) { | |
| return LOG_PREFIX + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH - 1); | |
| } | |
| return LOG_PREFIX + str; | |
| } | |
| public static String makeLogTag(Class<?> cls) { | |
| return makeLogTag(cls.getSimpleName()); | |
| } | |
| public static void LOGI(final String tag, String message) { | |
| Throwable throwable = new Throwable(); | |
| StackTraceElement[] e = throwable.getStackTrace(); | |
| String c_name = e[1].getMethodName(); | |
| if (BuildConfig.DEBUG) { | |
| Log.i(tag, "[" + c_name + "] " + message); | |
| } | |
| } | |
| public static void LOGE(String tag, String message) { | |
| Throwable throwable = new Throwable(); | |
| StackTraceElement[] e = throwable.getStackTrace(); | |
| String c_name = e[1].getMethodName(); | |
| if (BuildConfig.DEBUG) { | |
| Log.e(tag, "[" + c_name + "] " + message); | |
| } | |
| } | |
| public static void LOGE(final String tag, String message, Throwable throwable) { | |
| StackTraceElement[] e = throwable.getStackTrace(); | |
| String c_name = e[1].getMethodName(); | |
| if (BuildConfig.DEBUG) { | |
| Log.e(tag, "[" + c_name + "] " + message); | |
| } | |
| } | |
| public static void LOGD(String tag, String message) { | |
| Throwable throwable = new Throwable(); | |
| StackTraceElement[] e = throwable.getStackTrace(); | |
| String c_name = e[1].getMethodName(); | |
| if (BuildConfig.DEBUG) { | |
| Log.d(tag, "[" + c_name + "] " + message); | |
| } | |
| } | |
| public static void LOGV(String tag, String message) { | |
| Throwable throwable = new Throwable(); | |
| StackTraceElement[] e = throwable.getStackTrace(); | |
| String c_name = e[1].getMethodName(); | |
| if (BuildConfig.DEBUG) { | |
| Log.v(tag, "[" + c_name + "] " + message); | |
| } | |
| } | |
| public static void WTF(String tag, String message) { | |
| Throwable throwable = new Throwable(); | |
| StackTraceElement[] e = throwable.getStackTrace(); | |
| String c_name = e[1].getMethodName(); | |
| if (BuildConfig.DEBUG) { | |
| Log.wtf(tag, "[" + c_name + "] " + message); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment