Android log management tool, androidlog
1. logger
Project address: https://github.com/orhanobut/logger
2. KLog
Project address: https://github.com/ZhaoKaiQiang/KLog
Blog Introduction: http://kaizige.vip/2016/06/13/klog/
3. Custom logs
Package www.yiba.com. wifisdk. utils; import android. util. log; /*** the log tool class makes printing logs simple and automatic identification of the class name and position of calling log functions. No complicated TAG is required. You can easily set the debug mode to be released. * You can directly modify it. if debug is false, logs will not be output */public class LogUtil {/*** true: open log false: Disable all logs */public static boolean OPEN_LOG = true;/*** true: Enable debug log false: Disable debug log */public static boolean DEBUG = true; /*** TAG name */private static String tag = "yiba_sdk"; priva Te String mClassName; private static LogUtil log; private static final String USER_NAME = "@ tool @"; private LogUtil (String name) {mClassName = name ;} /*** Get The Current Function Name ** @ return Name */private String getFunctionName () {StackTraceElement [] sts = Thread. currentThread (). getStackTrace (); if (sts = null) {return null;} for (StackTraceElement st: sts) {if (st. isNativeMethod () {Continue;} if (st. getClassName (). equals (Thread. class. getName () {continue;} if (st. getClassName (). equals (this. getClass (). getName () {continue;} return mClassName + "[" + Thread. currentThread (). getName () + ":" + st. getFileName () + ":" + st. getLineNumber () + "" + st. getMethodName () + "]";} return null;} public static void I (Object str) {print (Log. INFO, str);} public static void d (Object str) {print (Log. DEBUG, str);} public static void v (Object str) {print (Log. VERBOSE, str);} public static void w (Object str) {print (Log. WARN, str);} public static void e (Object str) {print (Log. ERROR, str);}/*** used to differentiate data from different interfaces. print input parameters ** @ param index * @ param str */private static void print (int index, Object str) {if (! OPEN_LOG) {return;} if (log = null) {log = new LogUtil (USER_NAME);} String name = log. getFunctionName (); if (name! = Null) {str = name + "-" + str;} // Close the debug log When DEBUG is false if (! DEBUG) {if (index <= Log. DEBUG) {return ;}switch (index) {case Log. VERBOSE: Log. v (tag, str. toString (); break; case Log. DEBUG: Log. d (tag, str. toString (); break; case Log. INFO: Log. I (tag, str. toString (); break; case Log. WARN: Log. w (tag, str. toString (); break; case Log. ERROR: Log. e (tag, str. toString (); break; default: break ;}}}