package com.hwc.oklib.util;
import android.util.Log;
/**
* 创建时间:2017/6/8
* 编写者:黄伟才
* 功能描述:
* 1、支持自定义打印标签
* 2、支持打印基础类型、对象类型
*/
public class Debug {
private static final String TAG = "Debug";//默认打印tag
private static final String EMPTY_TAG = "打印标签不可为null";
public static void d(String msg) {
d(TAG, msg);
}
public static void d(Object tag, Object msg) {
if (UtilEntry.isDebug) {
if (null != tag) {
if (tag instanceof String) {
Log.d((String) tag, "" + msg);
} else {
//打印类名
Log.d(tag.getClass().getSimpleName(), "" + msg);
}
} else {
Log.d(TAG, EMPTY_TAG);
}
}
}
public static void v(String msg) {
v(TAG, msg);
}
public static void v(String tag, String msg) {
if (UtilEntry.isDebug) {
if (null != tag) {
if (tag instanceof String) {
Log.v(tag, "" + msg);
} else {
//打印类名
Log.v(tag.getClass().getSimpleName(), "" + msg);
}
} else {
Log.v(TAG, EMPTY_TAG);
}
}
}
public static void i(String msg) {
i(TAG, msg);
}
public static void i(String tag, String msg) {
if (UtilEntry.isDebug) {
if (null != tag) {
if (tag instanceof String) {
Log.i(tag, "" + msg);
} else {
//打印类名
Log.i(tag.getClass().getSimpleName(), "" + msg);
}
} else {
Log.i(TAG, EMPTY_TAG);
}
}
}
public static void e(String msg) {
e(TAG, msg);
}
public static void e(String tag, String msg) {
if (UtilEntry.isDebug) {
if (null != tag) {
if (tag instanceof String) {
Log.e((String) tag, "" + msg);
} else {
//打印类名
Log.e(tag.getClass().getSimpleName(), "" + msg);
}
} else {
Log.e(TAG, EMPTY_TAG);
}
}
}
public static void w(String msg) {
w(TAG, msg);
}
public static void w(String tag, String msg) {
if (UtilEntry.isDebug) {
if (null != tag) {
if (tag instanceof String) {
Log.w(tag, "" + msg);
} else {
//打印类名
Log.w(tag.getClass().getSimpleName(), "" + msg);
}
} else {
Log.d(TAG, EMPTY_TAG);
}
}
}
}
Debug打印工具类
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 转载请注明出处 http://www.jianshu.com/p/f66bcb2a39d4 写Android时必不...
- 我们在打印调试时候经常会遇到这种,然后看不懂的一些文字。我们可以通过加入一段代码去转码 转码之后的效果图 直接上代...
- 在Android开发当中log是个很重要的东西,方便开发者定位bug的位置,但是打包正式发布的时候就不能再打印lo...