Log打印
package com.example.framework.manager;
import android.util.Log;
import com.example.framework.BuildConfig;
public class LogUtil {
private static String className;
private static String methodName;
private static int lineName;
private static final String TAG = "Shopmall18809";
public static void v(String message) {
if (BuildConfig.LOG_DEBUG) {
createLogName(new Throwable().getStackTrace());
Log.v(TAG, className + " " + methodName + " " + lineName);
}
}
public static void d(String message) {
if (BuildConfig.LOG_DEBUG) {
createLogName(new Throwable().getStackTrace());
Log.d(TAG, "" + className + " " + methodName + " " + lineName + " " + message);
}
}
public static void i(String message) {
if (BuildConfig.LOG_DEBUG) {
createLogName(new Throwable().getStackTrace());
Log.i(TAG, className + " " + methodName + " " + lineName);
}
}
public static void e(String message) {
if (BuildConfig.LOG_ERROR) {
createLogName(new Throwable().getStackTrace());
Log.e(TAG, className + " " + methodName + " " + lineName);
}
}
private static void createLogName(StackTraceElement[] stackTraceElements) {
className = stackTraceElements[1].getClassName();
methodName = stackTraceElements[1].getMethodName();
lineName = stackTraceElements[1].getLineNumber();
}
}
build.gradle
apply plugin: 'com.android.library'
apply plugin: 'org.greenrobot.greendao'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
sourceSets {
main.jniLibs.srcDirs = ['libs']
}
defaultConfig {
minSdkVersion 22
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
debug{
buildConfigField("boolean","LOG_DEBUG","false");
buildConfigField("boolean","LOG_ERROR","false");
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
greendao {
schemaVersion 1
targetGenDir 'src/main/java'
daoPackage 'com.example.framework.greendao'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.jakewharton:disklrucache:2.0.2'
api 'com.blankj:utilcodex:1.26.0'
implementation 'com.android.support:recyclerview-v7:30.0.0'
implementation project(path: ':commened')
implementation project(path: ':net')
api 'org.greenrobot:greendao:3.3.0'
api 'com.blankj:utilcodex:1.26.0'
}