LogUtils.java
// BuildConfig.LOG_DEBUG 为 在build.gradle 中定义的属性,使用方式: buildConfigField "boolean", "LOG_DEBUG", "false"//是否输出LOG信息
/**
* Logger Simple, pretty and powerful logger for android
* 地址:https://github.com/orhanobut/logger
* build.gradle 中需添加: compile 'com.orhanobut:logger:1.15'
* 使用时需 在 Application 中定义相关 设置:
* Logger.init(AppContact.APK_LOG_TAG) // default PRETTYLOGGER or use just init()
.methodCount(2) // default 2
.hideThreadInfo() // default shown
.logLevel(LogLevel.FULL) // default LogLevel.FULL
.methodOffset(2) ; // default 0
*
*/
public class LogUtils {
public static final boolean DEBUG = BuildConfig.LOG_DEBUG;
public LogUtils() {
/* cannot be instantiated */
throw new UnsupportedOperationException("cannot be instantiated");
}
public static final void analytics(String log) {
if (DEBUG)
Logger.d(log);
}
public static final void error(String log) {
if (DEBUG)
Logger.e(log);
}
public static final void log(String log) {
if (DEBUG)
Logger.i(log);
}
public static final void log(String tag, String log) {
if (DEBUG)
Logger.i(tag, log);
}
public static final void logv(String log) {
if (DEBUG)
Logger.v(log);
}
public static final void warn(String log) {
if (DEBUG)
Logger.w(log);
}
}