Skip to content

Commit

Permalink
Merge pull request esoxjem#87 from Fakher-Hakim/network_enhancement
Browse files Browse the repository at this point in the history
Enable http logging only in Debug variant
  • Loading branch information
esoxjem authored Sep 29, 2018
2 parents df907b0 + d67136e commit e7f6327
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
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 e7f6327

Please sign in to comment.