Android Open Source - mcdroid Logger






From Project

Back to project page mcdroid.

License

The source code is released under:

Apache License

If you think the Android project mcdroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package cn.mibcxb.android.util;
//from  www . java 2 s  . c  om
import org.mibcxb.android.BuildConfig;

import android.util.Log;

public final class Logger {
    public static final int VERBOSE = Log.VERBOSE;
    public static final int DEBUG = Log.DEBUG;
    public static final int INFO = Log.INFO;
    public static final int WARN = Log.WARN;
    public static final int ERROR = Log.ERROR;

    private static int sLevel = BuildConfig.DEBUG ? DEBUG : WARN;

    public static int getLevel() {
        return sLevel;
    }

    public static void setLevel(int level) {
        sLevel = Math.min(Math.max(level, VERBOSE), ERROR);
    }

    public static void v(String tag, String msg) {
        if (sLevel <= VERBOSE) {
            Log.v(tag, msg);
        }
    }

    public static void v(String tag, String msg, Throwable tr) {
        if (sLevel <= VERBOSE) {
            Log.v(tag, msg, tr);
        }
    }

    public static void d(String tag, String msg) {
        if (sLevel <= DEBUG) {
            Log.d(tag, msg);
        }
    }

    public static void d(String tag, String msg, Throwable tr) {
        if (sLevel <= DEBUG) {
            Log.d(tag, msg, tr);
        }
    }

    public static void i(String tag, String msg) {
        if (sLevel <= INFO) {
            Log.i(tag, msg);
        }
    }

    public static void i(String tag, String msg, Throwable tr) {
        if (sLevel <= INFO) {
            Log.i(tag, msg, tr);
        }
    }

    public static void w(String tag, String msg) {
        if (sLevel <= WARN) {
            Log.w(tag, msg);
        }
    }

    public static void w(String tag, String msg, Throwable tr) {
        if (sLevel <= WARN) {
            Log.w(tag, msg, tr);
        }
    }

    public static void e(String tag, String msg) {
        if (sLevel <= ERROR) {
            Log.e(tag, msg);
        }
    }

    public static void e(String tag, String msg, Throwable tr) {
        if (sLevel <= ERROR) {
            Log.e(tag, msg, tr);
        }
    }

    public static String getSimpleTag(Class<?> cls) {
        if (cls == null) {
            return "mcdroid";
        } else {
            return cls.getSimpleName();
        }
    }
}




Java Source Code List

cn.mibcxb.acra.CrashReportWriter.java
cn.mibcxb.android.app.McApplication.java
cn.mibcxb.android.os.McHandler.java
cn.mibcxb.android.util.Logger.java
cn.mibcxb.android.util.NetworkWatcher.java
cn.mibcxb.util.McIO.java
cn.mibcxb.util.McMath.java