My Android advanced tour ------> A simple Log encapsulation for Android, android advanced
Android. util. Log class, which can be easily used to print logs during encoding and debugging. However, if too many logs are printed in the released products, the performance will be seriously affected. Make a simple encapsulation for the android. util. Log class. when the product is to be released, set Debug to false.
The Code is as follows.
Public class LogUtil {/** is set to false when it is officially launched */private final static boolean debug = true; private final static String TAG = "oyp "; public static void v (String tag, String msg) {if (debug) {Log. v (tag, msg) ;}} public static void v (String msg) {if (debug) {Log. v (TAG, msg) ;}} public static void d (String tag, String msg) {if (debug) {Log. d (tag, msg) ;}} public static void d (String msg) {if (debug) {Log. d (TAG, msg) ;}} public static void I (String tag, String msg) {if (debug) {Log. I (tag, msg) ;}} public static void I (String msg) {if (debug) {Log. I (TAG, msg) ;}} public static void w (String tag, String msg) {if (debug) {Log. w (tag, msg) ;}} public static void w (String msg) {if (debug) {Log. w (TAG, msg) ;}} public static void e (String tag, String msg) {if (debug) {Log. e (tag, msg) ;}} public static void e (String msg) {if (debug) {Log. e (TAG, msg );}}}
========================================================== ========================================================== ============================
Author: Ouyang Peng: Welcome to repost. sharing with others is the source of progress!
Reprinted Please retain the original address: http://blog.csdn.net/ouyang_peng
========================================================== ========================================================== ============================
Copyright statement: This article is the original author article, welcome to reprint, reprint please indicate the source of http://blog.csdn.net/ouyang_peng