import android.util.Log;
public class LogUtil {
private static final boolean DEBUG = true;
private static final boolean ERROR = true;
private static final boolean INFO = true;
private static final boolean WARN = true;
public static void Info(Object i) {
if ((i == null) || !INFO) {
return;
}
Thread mThread = Thread.currentThread();
StackTraceElement[] mStackTrace = mThread.getStackTrace();
String mMethodName = mStackTrace[3].getMethodName();
String TAG = mStackTrace[3].getClassName();
i = "[" + mMethodName + "] " + i;
Log.i(TAG, i + "");
}
public static void Warn(Object w) {
if ((w == null) || !WARN) {
return;
}
Thread mThread = Thread.currentThread();
StackTraceElement[] mStackTrace = mThread.getStackTrace();
String mMethodName = mStackTrace[3].getMethodName();
String TAG = mStackTrace[3].getClassName();
w = "[" + mMethodName + "] " + w;
Log.w(TAG, w + "");
}
public static void Debug(Object d) {
if ((d == null) || !DEBUG) {
return;
}
Thread mThread = Thread.currentThread();
StackTraceElement[] mStackTrace = mThread.getStackTrace();
String mMethodName = mStackTrace[3].getMethodName();
String TAG = mStackTrace[3].getClassName();
d = "[" + mMethodName + "] " + d;
Log.d(TAG, d + "");
}
public static void DebugStack(Object d) {
if ((d == null) || !DEBUG) {
return;
}
Thread mThread = Thread.currentThread();
StackTraceElement[] mStackTrace = mThread.getStackTrace();
String mMethodName = mStackTrace[3].getMethodName();
String TAG = mStackTrace[3].getClassName();
d = "[" + mMethodName + "] " + d;
Log.d(TAG, d + "", new RuntimeException());
}
public static void Error(Object e) {
if ((e == null) || !ERROR) {
return;
}
Thread mThread = Thread.currentThread();
StackTraceElement[] mStackTrace = mThread.getStackTrace();
String mMethodName = mStackTrace[3].getMethodName();
String TAG = mStackTrace[3].getClassName();
e = "[" + mMethodName + "] " + e;
Log.e(TAG, e + "");
}
public static void In() {
if (!INFO) {
return;
}
Thread mThread = Thread.currentThread();
StackTraceElement[] mStackTrace = mThread.getStackTrace();
String mMethodName = mStackTrace[3].getMethodName();
String TAG = mStackTrace[3].getClassName();
String i = "in "+"[" + mMethodName + "]";
Log.i(TAG, i);
}
public static void Out() {
if (!INFO) {
return;
}
Thread mThread = Thread.currentThread();
StackTraceElement[] mStackTrace = mThread.getStackTrace();
String mMethodName = mStackTrace[3].getMethodName();
String TAG = mStackTrace[3].getClassName();
String i = "out "+"[" + mMethodName + "]";
Log.i(TAG, i);
}
}
Log Util
最新推荐文章于 2018-11-03 22:43:26 发布