Java Code Examples for okhttp3.logging.HttpLoggingInterceptor#level()
The following examples show how to use
okhttp3.logging.HttpLoggingInterceptor#level() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArchPackagesRepository.java From ArchPackages with GNU General Public License v3.0 | 6 votes |
private ArchPackagesRepository() {
// http logging interceptor
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.level(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
// okhttp client
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder();
okHttpClient.connectTimeout(30, TimeUnit.SECONDS);
okHttpClient.readTimeout(30, TimeUnit.SECONDS);
okHttpClient.addInterceptor(httpLoggingInterceptor);
// retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(ArchPackagesConstants.ARCH_PACKAGES_API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient.build())
.build();
// service
archPackagesService = retrofit.create(ArchPackagesService.class);
}
Example 2
Source File: OkHttpPlugin.java From gradle-plugins with MIT License | 6 votes |
public OkHttpClient getOkHttpClient() {
if (okHttpClient == null) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(project.getLogger()::info);
loggingInterceptor.level(HttpLoggingInterceptor.Level.BASIC);
okHttpClient = new OkHttpClient.Builder()
.addInterceptor(chain -> {
Request request = chain.request();
if (project.getGradle().getStartParameter().isOffline()) {
request = request.newBuilder()
.cacheControl(CacheControl.FORCE_CACHE)
.build();
}
return chain.proceed(request);
})
.addInterceptor(loggingInterceptor)
.cache(okHttpCachePlugin.getCache())
.build();
}
return okHttpClient;
}
Example 3
Source File: OkHttpPlugin.java From gradle-plugins with MIT License | 6 votes |
public OkHttpClient getOkHttpClient() {
if (okHttpClient == null) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(project.getLogger()::info);
loggingInterceptor.level(HttpLoggingInterceptor.Level.BASIC);
okHttpClient = new OkHttpClient.Builder()
.addInterceptor(chain -> {
Request request = chain.request();
if (project.getGradle().getStartParameter().isOffline()) {
request = request.newBuilder()
.cacheControl(CacheControl.FORCE_CACHE)
.build();
}
return chain.proceed(request);
})
.addInterceptor(loggingInterceptor)
.cache(okHttpCachePlugin.getCache())
.build();
}
return okHttpClient;
}
Example 4
Source File: SimpleStreamSenderIT.java From quilt with Apache License 2.0 | 5 votes |
private OkHttpClient constructOkHttpClient() {
ConnectionPool connectionPool = new ConnectionPool(10, 5, TimeUnit.MINUTES);
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS).build();
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.level(HttpLoggingInterceptor.Level.BASIC);
OkHttpClient.Builder builder = new OkHttpClient.Builder()
.connectionSpecs(Arrays.asList(spec, ConnectionSpec.CLEARTEXT))
.cookieJar(NO_COOKIES)
.connectTimeout(5000, TimeUnit.MILLISECONDS)
.addInterceptor(logging)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS);
return builder.connectionPool(connectionPool).build();
}
Example 5
Source File: OkHttp3LoggingInterceptorAutoConfiguration.java From okhttp-spring-boot with MIT License | 5 votes |
@Bean
@ApplicationInterceptor
@ConditionalOnMissingBean
public HttpLoggingInterceptor okHttp3LoggingInterceptor(
OkHttp3LoggingInterceptorProperties properties,
ObjectProvider<HttpLoggingInterceptor.Logger> logger
) {
HttpLoggingInterceptor.Logger actualLogger = logger.getIfUnique(() -> HttpLoggingInterceptor.Logger.DEFAULT);
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(actualLogger);
httpLoggingInterceptor.level(properties.getLevel());
return httpLoggingInterceptor;
}
Example 6
Source File: OkHttp3LoggingInterceptorAutoConfiguration.java From okhttp-spring-boot with MIT License | 5 votes |
@Bean
@ApplicationInterceptor
@ConditionalOnMissingBean
public HttpLoggingInterceptor okHttp3LoggingInterceptor(
OkHttp3LoggingInterceptorProperties properties,
ObjectProvider<HttpLoggingInterceptor.Logger> logger
) {
HttpLoggingInterceptor.Logger actualLogger = logger.getIfUnique(() -> HttpLoggingInterceptor.Logger.DEFAULT);
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(actualLogger);
httpLoggingInterceptor.level(properties.getLevel());
return httpLoggingInterceptor;
}
Example 7
Source File: OAuthAsyncHttpClient.java From android-oauth-handler with MIT License | 4 votes |
public static HttpLoggingInterceptor createLogger() {
HttpLoggingInterceptor logger = new HttpLoggingInterceptor();
logger.level(HttpLoggingInterceptor.Level.HEADERS);
return logger;
}