1.为了方便的使用Log打印日志,以及后续方便撤销日志打印,所以对Log类进行封装是一件好事。
1 package market.phone; 2 3 import android.util.Log; 4 5 /** 6 * 自己封装的log类,按是调试或者是实际 7 * Created by Administrator on 2017/6/13. 8 */ 9 10 public class LogU { 11 /*m默认不打印Log,如果要打印,置为true*/ 12 private static boolean enableLog = false; 13 14 public static void Le(String tag,String msg){ 15 if(enableLog) 16 Log.e(tag,msg); 17 18 } 19 public static void Ld(String tag,String msg){ 20 if(enableLog) 21 Log.d(tag,msg); 22 23 } 24 25 public static void Li(String tag,String msg){ 26 if(enableLog) 27 Log.i(tag,msg); 28 29 } 30 public static void Lv(String tag,String msg){ 31 if(enableLog) 32 Log.v(tag,msg); 33 34 } 35 public static void Lw(String tag,String msg){ 36 if(enableLog) 37 Log.w(tag,msg); 38 39 } 40 41 42 }
2.通过修改enableLog的值来实现我们的打印Log需求