If you think the Android project PatternAndroid 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
/**
* 2012 Foxykeep (http://datadroid.foxykeep.com)
* <p>/*www.java2s.com*/
* Licensed under the Beerware License : <br />
* As long as you retain this notice you can do whatever you want with this stuff. If we meet some
* day, and you think this stuff is worth it, you can buy me a beer in return
*/package com.foxykeep.datadroid.util;
import com.foxykeep.datadroid.BuildConfig;
import android.util.Log;
/**
* Centralized helper for logging information for DataDroid.
* <p>
* To modify the log level, use the following command :
*
* <pre>
* adb shell setprop log.tag.DataDroid <LOGLEVEL>
* with LOGLEVEL being one of the following :
* VERBOSE, DEBUG, INFO, WARN or ERROR
* </pre>
* <p>
* The default log level is DEBUG.
* <p>
* Also the logs are disabled in a release build by default. If you want them to be enabled, modify
* the value of {@link #ENABLE_LOGS_IN_RELEASE}.
*
* @author Foxykeep
*/publicfinalclass DataDroidLog {
/**
* Primary log tag for games output.
*/privatestaticfinal String LOG_TAG = "DataDroid";
/**
* Whether the logs are enabled in release builds or not.
*/privatestaticfinalboolean ENABLE_LOGS_IN_RELEASE = false;
publicstaticboolean canLog(int level) {
return (ENABLE_LOGS_IN_RELEASE || BuildConfig.DEBUG) && Log.isLoggable(LOG_TAG, level);
}
publicstaticvoid d(String tag, String message) {
if (canLog(Log.DEBUG)) {
Log.d(tag, message);
}
}
publicstaticvoid v(String tag, String message) {
if (canLog(Log.VERBOSE)) {
Log.v(tag, message);
}
}
publicstaticvoid i(String tag, String message) {
if (canLog(Log.INFO)) {
Log.i(tag, message);
}
}
publicstaticvoid i(String tag, String message, Throwable thr) {
if (canLog(Log.INFO)) {
Log.i(tag, message, thr);
}
}
publicstaticvoid w(String tag, String message) {
if (canLog(Log.WARN)) {
Log.w(tag, message);
}
}
publicstaticvoid w(String tag, String message, Throwable thr) {
if (canLog(Log.WARN)) {
Log.w(tag, message, thr);
}
}
publicstaticvoid e(String tag, String message) {
if (canLog(Log.ERROR)) {
Log.e(tag, message);
}
}
publicstaticvoid e(String tag, String message, Throwable thr) {
if (canLog(Log.ERROR)) {
Log.e(tag, message, thr);
}
}
}