Android log management tool, androidlog

Source: Internet
Author: User

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 ;}}}

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.