Search in sources :

Example 1 with HttpLoggingInterceptor

use of com.squareup.okhttp.logging.HttpLoggingInterceptor in project FloatingSearchView by renaudcerrato.

the class RetrofitModule method provideHttpClient.

@Provides
@Singleton
OkHttpClient provideHttpClient() {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient httpClient = new OkHttpClient();
    httpClient.interceptors().add(logging);
    return httpClient;
}
Also used : OkHttpClient(com.squareup.okhttp.OkHttpClient) HttpLoggingInterceptor(com.squareup.okhttp.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 2 with HttpLoggingInterceptor

use of com.squareup.okhttp.logging.HttpLoggingInterceptor in project java by kubernetes-client.

the class ApiClient method setDebugging.

/**
 * Enable/disable debugging for this API client.
 *
 * @param debugging To enable (true) or disable (false) debugging
 * @return ApiClient
 */
public ApiClient setDebugging(boolean debugging) {
    if (debugging != this.debugging) {
        if (debugging) {
            loggingInterceptor = new HttpLoggingInterceptor();
            loggingInterceptor.setLevel(Level.BODY);
            httpClient.interceptors().add(loggingInterceptor);
        } else {
            httpClient.interceptors().remove(loggingInterceptor);
            loggingInterceptor = null;
        }
    }
    this.debugging = debugging;
    return this;
}
Also used : HttpLoggingInterceptor(com.squareup.okhttp.logging.HttpLoggingInterceptor)

Aggregations

HttpLoggingInterceptor (com.squareup.okhttp.logging.HttpLoggingInterceptor)2 OkHttpClient (com.squareup.okhttp.OkHttpClient)1 Provides (dagger.Provides)1 Singleton (javax.inject.Singleton)1