mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-15 06:40:58 +00:00
disable http logging when in production mode
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
package org.houxg.leamonax.network;
|
package org.houxg.leamonax.network;
|
||||||
|
|
||||||
|
import com.elvishew.xlog.XLog;
|
||||||
|
|
||||||
|
import org.houxg.leamonax.BuildConfig;
|
||||||
import org.houxg.leamonax.model.Account;
|
import org.houxg.leamonax.model.Account;
|
||||||
import org.houxg.leamonax.network.api.AuthApi;
|
import org.houxg.leamonax.network.api.AuthApi;
|
||||||
import org.houxg.leamonax.network.api.NoteApi;
|
import org.houxg.leamonax.network.api.NoteApi;
|
||||||
@@ -37,9 +40,7 @@ public class ApiProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init(String host) {
|
public void init(String host) {
|
||||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
|
||||||
OkHttpClient client = new OkHttpClient.Builder()
|
|
||||||
.addNetworkInterceptor(new Interceptor() {
|
.addNetworkInterceptor(new Interceptor() {
|
||||||
@Override
|
@Override
|
||||||
public Response intercept(Chain chain) throws IOException {
|
public Response intercept(Chain chain) throws IOException {
|
||||||
@@ -57,9 +58,18 @@ public class ApiProvider {
|
|||||||
.build();
|
.build();
|
||||||
return chain.proceed(newRequest);
|
return chain.proceed(newRequest);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.addNetworkInterceptor(interceptor)
|
if (BuildConfig.DEBUG) {
|
||||||
.build();
|
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
|
||||||
|
@Override
|
||||||
|
public void log(String message) {
|
||||||
|
XLog.i(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
|
builder.addNetworkInterceptor(interceptor);
|
||||||
|
}
|
||||||
|
OkHttpClient client = builder.build();
|
||||||
mApiRetrofit = new Retrofit.Builder()
|
mApiRetrofit = new Retrofit.Builder()
|
||||||
.baseUrl(host + "/api/")
|
.baseUrl(host + "/api/")
|
||||||
.client(client)
|
.client(client)
|
||||||
|
Reference in New Issue
Block a user