Log工具类

Android2019年7月11日 pm7:31发布5年前 (2019)更新 3xcn.com@站长
0 0 0
广告也精彩


抱歉,好久没更新了,主要是在折腾125啦读书(直通车:https://www.91es.com)。

最近发现项目中很多都用重复的类,因此后续多整理一下常用的实用的工具类。或许以后直接复用即可。

今天重新定义了一个Log工具类VLog。(这个网上一大把),直接上代码:

public class Vlog {
	// 默认TAG
	private static String tag = "ToolClass";

	private static int level = 3;

	public static void initLogTag(String new_tag) {
		tag = new_tag;
		return;
	}

	public static void initLogLevel(int log_level) {
		level = log_level;
		return;
	}

	/**
	 * ERROR
	 * 
	 * @param msg
	 */
	public static void e(String msg) {
		if (level >= Constants.ERROR) {
			Log.e(tag, msg);
		}
		return;
	}

	public static void e(String tag, String msg) {
		if (level >= Constants.ERROR) {
			Log.e(tag, msg);
		}
		return;
	}

	/**
	 * WARN
	 * 
	 * @param msg
	 */
	public static void w(String msg) {
		if (level >= Constants.WARN) {
			Log.w(tag, msg);
		}
		return;
	}

	public static void w(String tag, String msg) {
		if (level >= Constants.WARN) {
			Log.w(tag, msg);
		}
		return;
	}

	/**
	 * INFO
	 * 
	 * @param msg
	 */
	public static void i(String msg) {
		if (level >= Constants.INFO) {
			Log.i(tag, msg);
		}
		return;
	}

	public static void i(String tag, String msg) {
		if (level >= Constants.INFO) {
			Log.i(tag, msg);
		}
		return;
	}

	/**
	 * DEBUG
	 * 
	 * @param msg
	 */
	public static void d(String msg) {
		if (level >= Constants.DEBUG) {
			Log.d(tag, msg);
		}
		return;
	}

	public static void d(String tag, String msg) {
		if (level >= Constants.DEBUG) {
			Log.d(tag, msg);
		}
		return;
	}
}
	/**
	 * log level
	 */
	public static final int ERROR = 0;
	public static final int WARN = 1;
	public static final int INFO = 2;
	public static final int DEBUG = 3;

 

 历史上的今天

版权声明 1、 本站名称: 91易搜
2、 本站网址: 91es.com3xcn.com
3、 本站文章: 部分来源于网络,仅供站长学习和参考,若侵权请留言
广告也精彩

相关文章

广告也精彩

暂无评论

评论审核已启用。您的评论可能需要一段时间后才能被显示。

暂无评论...

网站升级中

公告

近期网站升级中,可能存在一些bug。欢迎反馈 https://www.91es.com/we.html

本站域名

本站域名 : 91es.com3xcn.com。本站邮箱 : 站长邮箱 i@oorr.cn,通知邮箱we@oorr.cn ,如有更新,请看公告 。