首页 > 其他 > 详细

自定义logutils

时间:2015-07-22 19:05:29      阅读:242      评论:0      收藏:0      [点我收藏+]

//log管理类,开发阶段  level设为verbose,记录全部数据。
//上线后,将level设置为nothing,屏蔽全部数据
//app维修,将level再次设置为level,便于维修

 


public class LogUtils {
 public final static int verbose = 1;
 public static final int debug = 2;
 public static final int info = 3;
 public static final int warn = 4;
 public static final int error = 5;
 public static final int nothing = 6;

 public static final int level = verbose;

 public static void verbose(String tag, String msg) {
  if (level<=verbose) {
              Log.v(tag, msg);
  }
 }
 public static void debug(String tag, String msg) {
  if (level<=debug) {
              Log.d(tag, msg);
  }
 }
 public static void info(String tag, String msg) {
  if (level<=info) {
              Log.i(tag, msg);
  }
 }
 public static void warn(String tag, String msg) {
  if (level<= warn) {
              Log.w(tag, msg);
  }
 }
 
 public static void error(String tag, String msg) {
  if (level<=error) {
              Log.e(tag, msg);
  }
 }

}

 

 

 

使用方式:

直接使用该类中的方法

LogUtils.i("tag","记录的数据");

 

 

自定义logutils

原文:http://my.oschina.net/u/2406195/blog/482458

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!