Skip to content

Commit

Permalink
Enable http logging only in Debug variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Fakher-Hakim committed Sep 28, 2018
1 parent df907b0 commit d67136e
Showing 1 changed file with 10 additions and 7 deletions.
Expand Up @@ -33,14 +33,17 @@ Interceptor requestInterceptor(RequestInterceptor interceptor) {
@Provides
@Singleton
OkHttpClient provideOkHttpClient(RequestInterceptor requestInterceptor) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.connectTimeout(CONNECT_TIMEOUT_IN_MS, TimeUnit.MILLISECONDS)
.addInterceptor(requestInterceptor);

return new okhttp3.OkHttpClient.Builder()
.connectTimeout(CONNECT_TIMEOUT_IN_MS, TimeUnit.MILLISECONDS)
.addInterceptor(loggingInterceptor)
.addInterceptor(requestInterceptor)
.build();
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(loggingInterceptor);
}

return builder.build();
}

@Singleton
Expand Down

0 comments on commit d67136e

Please sign in to comment.