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 .
isDebug
For 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