Log Util

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);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值