抱歉,好久没更新了,主要是在折腾笔友城堡(直通车:https://www.biumall.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;

 

相关文章

暂无评论

none
暂无评论...