Common Log printing and Output

Source: Internet
Author: User


/*** Log ** @ author Jenly **/public class LogUtils {private static final String TAG = "Jenly"; private static final String COLON = ":"; private static final String ARROW = "->";/** whether to display Log logs */private static boolean isShowLog = true; public static void setIsShowLog (boolean isShow) {isShowLog = isShow;} public static boolean getIsShoWlOG () {return isShowLog;} // ------------------------------------- Log. v/*** Log. v * @ param e */public static void v (Throwable e) {if (isShowLog) v (TAG, e);} public static void v (String tag, Throwable e) {if (isShowLog) Log. v (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (e. getMessage ()). toString ();} public static void v (Throwable e, String msg) {if (isShowLog) v (TAG, e, msg);} public static void v (String tag, throwable e, String msg) {if (isShowLog) Log. v (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (msg ). toString ();} public static void v (String msg) {if (isShowLog) v (TAG, msg);} public static void v (String tag, String msg) {if (isShowLog) Log. v (tag, msg);} public static void v (Class
 Cls, String msg) {if (isShowLog) v (TAG, cls, msg);} public static void v (String tag, Class
 Cls, String msg) {if (isShowLog) Log. v (tag, new StringBuilder (). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} public static void v (Class
 Cls, String line, String msg) {if (isShowLog) v (TAG, cls, line, msg);} public static void v (String tag, Class
 Cls, String line, String msg) {if (isShowLog) Log. e (tag, new StringBuilder (). append (line ). append (COLON ). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} // ------------------------------------- Log. d/*** Log. d * @ param e */public static void d (Throwable e) {if (isShowLog) d (TAG, e);} public static void d (String tag, Throwable e) {if (isShowLog) Log. d (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (e. getMessage ()). toString ();} public static void d (Throwable e, String msg) {if (isShowLog) d (TAG, e, msg);} public static void d (String tag, throwable e, String msg) {if (isShowLog) Log. d (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (msg ). toString ();} public static void d (String msg) {if (isShowLog) d (TAG, msg);} public static void d (String tag, String msg) {if (isShowLog) Log. d (tag, msg);} public static void d (Class
 Cls, String msg) {if (isShowLog) d (TAG, cls, msg);} public static void d (String tag, Class
 Cls, String msg) {if (isShowLog) Log. d (tag, new StringBuilder (). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} public static void d (Class
 Cls, String line, String msg) {if (isShowLog) d (TAG, cls, line, msg);} public static void d (String tag, Class
 Cls, String line, String msg) {if (isShowLog) Log. d (tag, new StringBuilder (). append (line ). append (COLON ). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} // ------------------------------------- Log. i/*** Log. I * @ param e */public static void I (Throwable e) {if (isShowLog) I (TAG, e);} public static void I (String tag, Throwable e) {if (isShowLog) Log. I (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (e. getMessage ()). toString ();} public static void I (Throwable e, String msg) {if (isShowLog) I (TAG, e, msg);} public static void I (String tag, throwable e, String msg) {if (isShowLog) Log. I (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (msg ). toString ();} public static void I (String msg) {if (isShowLog) I (TAG, msg);} public static void I (String tag, String msg) {if (isShowLog) Log. I (tag, msg);} public static void I (Class
 Cls, String msg) {if (isShowLog) I (TAG, cls, msg);} public static void I (String tag, Class
 Cls, String msg) {if (isShowLog) Log. I (tag, new StringBuilder (). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} public static void I (Class
 Cls, String line, String msg) {if (isShowLog) v (TAG, cls, line, msg);} public static void I (String tag, Class
 Cls, String line, String msg) {if (isShowLog) Log. I (tag, new StringBuilder (). append (line ). append (COLON ). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} // ------------------------------------- Log. w/*** Log. w * @ param e */public static void w (Throwable e) {if (isShowLog) w (TAG, e);} public static void w (String tag, Throwable e) {if (isShowLog) Log. w (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (e. getMessage ()). toString ();} public static void w (Throwable e, String msg) {if (isShowLog) w (TAG, e, msg);} public static void w (String tag, throwable e, String msg) {if (isShowLog) Log. w (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (msg ). toString ();} public static void w (String msg) {if (isShowLog) w (TAG, msg);} public static void w (String tag, String msg) {if (isShowLog) Log. w (tag, msg);} public static void w (Class
 Cls, String msg) {if (isShowLog) w (TAG, cls, msg);} public static void w (String tag, Class
 Cls, String msg) {if (isShowLog) Log. w (tag, new StringBuilder (). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} public static void w (Class
 Cls, String line, String msg) {if (isShowLog) w (TAG, cls, line, msg);} public static void w (String tag, Class
 Cls, String line, String msg) {if (isShowLog) Log. w (tag, new StringBuilder (). append (line ). append (COLON ). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} // ------------------------------------- Log. e/*** Log. e * @ param e */public static void e (Throwable e) {if (isShowLog) e (TAG, e);} public static void e (String tag, Throwable e) {if (isShowLog) Log. e (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (e. getMessage ()). toString ();} public static void e (Throwable e, String msg) {if (isShowLog) e (TAG, e, msg);} public static void e (String tag, throwable e, String msg) {if (isShowLog) Log. e (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (msg ). toString ();} public static void e (String msg) {if (isShowLog) e (TAG, msg);} public static void e (String tag, String msg) {if (isShowLog) Log. e (tag, msg);} public static void e (Class
 Cls, String msg) {if (isShowLog) e (TAG, cls, msg);} public static void e (String tag, Class
 Cls, String msg) {if (isShowLog) Log. e (tag, new StringBuilder (). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} public static void e (Class
 Cls, String line, String msg) {if (isShowLog) e (TAG, cls, line, msg);} public static void e (String tag, Class
 Cls, String line, String msg) {if (isShowLog) Log. w (tag, new StringBuilder (). append (line ). append (COLON ). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} // ------------------------------------- Log. wtf/*** Log. wtf * @ param e */public static void wtf (Throwable e) {if (isShowLog) wtf (TAG, e);} public static void wtf (String tag, Throwable e) {if (isShowLog) Log. wtf (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (e. getMessage ()). toString ();} public static void wtf (Throwable e, String msg) {if (isShowLog) wtf (TAG, e, msg);} public static void wtf (String tag, throwable e, String msg) {if (isShowLog) Log. wtf (tag, new StringBuilder (). append (e. getStackTrace () [0]. getLineNumber ()). append (COLON ). append (e. getStackTrace () [0]. getClassName ()). append (ARROW ). append (e. getStackTrace () [0]. getMethodName ()). append (COLON ). append (msg ). toString ();} public static void wtf (String msg) {if (isShowLog) wtf (TAG, msg);} public static void wtf (String tag, String msg) {if (isShowLog) Log. wtf (tag, msg);} public static void wtf (Class
 Cls, String msg) {if (isShowLog) wtf (TAG, cls, msg);} public static void wtf (String tag, Class
 Cls, String msg) {if (isShowLog) Log. wtf (tag, new StringBuilder (). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} public static void wtf (Class
 Cls, String line, String msg) {if (isShowLog) e (TAG, cls, line, msg);} public static void wtf (String tag, Class
 Cls, String line, String msg) {if (isShowLog) Log. wtf (tag, new StringBuilder (). append (line ). append (COLON ). append (cls. getSimpleName ()). append (COLON ). append (msg ). toString ();} // ------------------------------------- System. out. print/*** System. out. print * @ param msg */public static void print (String msg) {if (isShowLog) System. out. print (msg);} public static void print (Object obj) {if (isShowLog) System. out. print (obj);} // ------------------------------------- System. out. printf/*** System. out. printf * @ param msg */public static void printf (String msg) {if (isShowLog) System. out. printf (msg);} // ------------------------------------- System. out. println/*** System. out. println * @ param msg */public static void println (String msg) {if (isShowLog) System. out. println (msg);} public static void println (Object obj) {if (isShowLog) System. out. println (obj );}}

It is a simple encapsulation, easy to record and manage,

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.