Android logutils Print Log Tool class

Source: Internet
Author: User
Tags return tag

Logutils Print Log Tool class

This is a print Log tool class that is extracted from the XUTILS3. This kind of print log is more detailed, you can print the class name, method name .
isDebugFor the print log switch, the initialization can be used LogUtils.isDebug(boolean b) to control the switching state.

public class Logutils {public static String Customtagprefix = "X_log";    private static Boolean isdebug = true;    Private Logutils () {} public static void Isdebug (Boolean b) {isdebug = b;        } private static String Generatetag () {stacktraceelement caller = new Throwable (). Getstacktrace () [2];        String tag = "%s.%s (l:%d)";        String callerclazzname = Caller.getclassname ();        Callerclazzname = callerclazzname.substring (Callerclazzname.lastindexof (".") + 1);        Tag = String.Format (tag, Callerclazzname, Caller.getmethodname (), Caller.getlinenumber ()); Tag = Textutils.isempty (Customtagprefix)?        Tag:customtagprefix + ":" + tag;    return tag;        public static void D (String content) {if (!isdebug) return;        String tag = Generatetag ();    LOG.D (tag, content);        public static void D (String content, Throwable tr) {if (!isdebug) return;        String tag = Generatetag (); LOG.D (tag, content, tr);        public static void E (String content) {if (!isdebug) return;        String tag = Generatetag ();    LOG.E (tag, content);        public static void E (String content, Throwable tr) {if (!isdebug) return;        String tag = Generatetag ();    LOG.E (tag, content, TR);        public static void I (String content) {if (!isdebug) return;        String tag = Generatetag ();    LOG.I (tag, content);        public static void I (String content, Throwable tr) {if (!isdebug) return;        String tag = Generatetag ();    LOG.I (tag, content, TR);        public static void V (String content) {if (!isdebug) return;        String tag = Generatetag ();    LOG.V (tag, content);        public static void V (String content, Throwable tr) {if (!isdebug) return;        String tag = Generatetag ();    LOG.V (tag, content, TR);        public static void W (String content) {if (!isdebug) return; String tag = Generatetag ();    LOG.W (tag, content);        public static void W (String content, Throwable tr) {if (!isdebug) return;        String tag = Generatetag ();    LOG.W (tag, content, TR);        public static void W (Throwable tr) {if (!isdebug) return;        String tag = Generatetag ();    LOG.W (tag, tr);        public static void WTF (String content) {if (!isdebug) return;        String tag = Generatetag ();    LOG.WTF (tag, content);        public static void WTF (String content, Throwable tr) {if (!isdebug) return;        String tag = Generatetag ();    LOG.WTF (tag, content, TR);        public static void WTF (Throwable tr) {if (!isdebug) return;        String tag = Generatetag ();    LOG.WTF (tag, tr); }}

Android logutils Print Log tool class

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.