码迷,mamicode.com
首页 > 移动开发 > 详细

android中Log类的封装

时间:2017-06-14 02:44:59      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:creat   默认   使用   public   ring   tag   log打印   code   logs   

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需求

android中Log类的封装

标签:creat   默认   使用   public   ring   tag   log打印   code   logs   

原文地址:http://www.cnblogs.com/huipengbo/p/7004036.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!