當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpLoggingInterceptor.setLevel方法代碼示例

本文整理匯總了Java中com.squareup.okhttp.logging.HttpLoggingInterceptor.setLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpLoggingInterceptor.setLevel方法的具體用法?Java HttpLoggingInterceptor.setLevel怎麽用?Java HttpLoggingInterceptor.setLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.squareup.okhttp.logging.HttpLoggingInterceptor的用法示例。


在下文中一共展示了HttpLoggingInterceptor.setLevel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newVineyardService

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
public static AndroidTvBoilerplateService newVineyardService() {
    OkHttpClient client = new OkHttpClient();
    client.interceptors().add(new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Response response = chain.proceed(chain.request());
            // Catch unauthorised error
            return response;
        }
    });

    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    client.interceptors().add(interceptor);

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(AndroidTvBoilerplateService.ENDPOINT)
            .client(client)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
    return retrofit.create(AndroidTvBoilerplateService.class);
}
 
開發者ID:hitherejoe,項目名稱:AndroidTvBoilerplate,代碼行數:24,代碼來源:AndroidTvBoilerplateService.java

示例2: provideRetrofit

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
@Provides
@PerApplication
Retrofit provideRetrofit() {
    String endpointUrl = BuildConfig.apiEndpointUrl;
    Gson gson = new GsonBuilder()
            .setDateFormat(API_DATE_FORMAT)
            .setFieldNamingPolicy(API_JSON_NAMING_POLICY)
            .registerTypeAdapter(ResponseWrapper.class, new ResponseDeserializer())
            .addSerializationExclusionStrategy(new JsonExclusionStrategy())
            .addDeserializationExclusionStrategy(new JsonExclusionStrategy())
            .create();
    GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(gson);
    OkHttpClient client = new OkHttpClient();
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    client.interceptors().add(logging);
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(endpointUrl)
            .client(client)
            .addConverterFactory(gsonConverterFactory)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
    return retrofit;
}
 
開發者ID:macoscope,項目名稱:RoomBookerMVP,代碼行數:25,代碼來源:NetworkModule.java

示例3: APIClient

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
APIClient() {
    OkHttpClient client = new OkHttpClient();
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    client.interceptors().add(logging);
    client.setConnectTimeout(10, TimeUnit.SECONDS);
    client.setReadTimeout(10, TimeUnit.SECONDS);
    client.setWriteTimeout(10, TimeUnit.SECONDS);
    Retrofit retrofit = new Retrofit.Builder()
            .client(client)
            .baseUrl("http://gank.avosapps.com/api/")
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .build();
    service = retrofit.create(MeizhiService.class);
}
 
開發者ID:Alluretears,項目名稱:ImageLoaders,代碼行數:17,代碼來源:APIClient.java

示例4: openConnection

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
/**
 * Opens a connection to the server over websocket
 *
 * @param isReconnect whether this is a re-connect attempt or not
 */
public void openConnection(final boolean isReconnect) {

    if (isReconnect) {
        if (isConnected()) {
            connect(mSessionID);
            return;
        }
    }

    OkHttpClient client = new OkHttpClient();
    client.setConnectTimeout(1, TimeUnit.MINUTES);
    client.setReadTimeout(1, TimeUnit.MINUTES);
    client.setWriteTimeout(1, TimeUnit.MINUTES);
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    client.networkInterceptors().add(loggingInterceptor);

    Request request = new Request.Builder()
            .url(mServerUri)
            .build();
    WebSocketCall.create(client, request).enqueue(mWebSocketObserver);
}
 
開發者ID:lukamarin,項目名稱:Rocket.Chat-android,代碼行數:28,代碼來源:Meteor.java

示例5: CreateNsMethods

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
private INsRestApi CreateNsMethods(String baseUrl) {
    Retrofit retrofit;

    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();  
    // set your desired log level
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient httpClient = new OkHttpClient();  
    // add your other interceptors ...

    // add logging as last interceptor
    httpClient.interceptors().add(logging);  // <-- this is the important line for logging

    Gson gson = new GsonBuilder().create();
    retrofit = new Retrofit.Builder()
    .baseUrl(baseUrl)
    .addConverterFactory(GsonConverterFactory.create(gson))
    .client(httpClient)
    .build();

    return retrofit.create(INsRestApi.class);
}
 
開發者ID:StephenBlackWasAlreadyTaken,項目名稱:xDrip-Experimental,代碼行數:23,代碼來源:NsRestApiReader.java

示例6: instance

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
public static BibleGatewayService instance(@NonNull Context context) {
    if (sService == null) {
        final Cache cache = new Cache(new File(context.getCacheDir(), HTTP_CACHE_FILE_NAME),
                HTTP_CACHE_SIZE);

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

        final OkHttpClient okHttpClient = new OkHttpClient();
        okHttpClient.setConnectTimeout(30, TimeUnit.SECONDS);
        okHttpClient.setReadTimeout(30, TimeUnit.SECONDS);
        okHttpClient.setCache(cache);
        okHttpClient.interceptors().add(interceptor);

        Retrofit retrofit = new Retrofit.Builder().
                baseUrl(BibleGatewayService.API_BASE_URL).
                addConverterFactory(GsonConverterFactory.create()).
                addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
                client(okHttpClient).
                build();

        sService = retrofit.create(BibleGatewayService.class);
    }
    return sService;
}
 
開發者ID:filipebezerra,項目名稱:VerseOfTheDay,代碼行數:26,代碼來源:BibleGatewayApiController.java

示例7: newVineyardService

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
public static VineyardService newVineyardService() {
    OkHttpClient client = new OkHttpClient();
    client.interceptors().add(new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Response response = chain.proceed(chain.request());
            // Catch unauthorised error
            return response;
        }
    });

    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    client.interceptors().add(interceptor);

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(VineyardService.ENDPOINT)
            .client(client)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
    return retrofit.create(VineyardService.class);
}
 
開發者ID:hitherejoe,項目名稱:Vineyard,代碼行數:24,代碼來源:VineyardService.java

示例8: connectToApi

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
private void connectToApi() {
    HttpLoggingInterceptor.Level logLevel = HttpLoggingInterceptor.Level.BODY;
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(logLevel);

    OkHttpClient okHttpClient = this.createClient();
    final Request request = new Request.Builder()
            .url(this.url)
            .addHeader(CONTENT_TYPE_LABEL, CONTENT_TYPE_VALUE_JSON)
            .get()
            .build();

    try {
        this.response = okHttpClient.newCall(request).execute().body().string();
    } catch (IOException e) {
        Log.e(this.getClass().getName(), "An error occured while trying to execute the HTTP call", e);
    }
}
 
開發者ID:feragusper,項目名稱:BuenosAiresAntesYDespues,代碼行數:19,代碼來源:ApiConnection.java

示例9: SimWatchClient

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
private SimWatchClient(Configuration configuration) {
    OkHttpClient client = new OkHttpClient();
    if (configuration.isRequestLoggingEnabled()) {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(
                new HttpLoggingInterceptor.Logger() {
                    @Override
                    public void log(String message) {
                        LOG.info(message);
                    }
                });
        interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
        client.interceptors().add(interceptor);
    }

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(configuration.getUrl())
            .client(client)
            .addConverterFactory(GsonConverterFactory.create(GsonUtil.getGson()))
            .build();
    backend = retrofit.create(BackendService.class);
}
 
開發者ID:WiReSEP,項目名稱:SimWatch,代碼行數:22,代碼來源:SimWatchClient.java

示例10: providesOkHttpClient

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
@Provides
@Singleton
public OkHttpClient providesOkHttpClient(Context context) {
    OkHttpClient client = new OkHttpClient();
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
    client.interceptors().add(interceptor);
    client.networkInterceptors().add(new StethoInterceptor());
    File httpCacheDir = new File(context.getCacheDir() + "/okhttp");
    httpCacheDir.mkdirs();
    cleanDir(httpCacheDir);
    long httpCacheSize = 50 * 1024 * 1024; // 50 MiB
    Cache cache = new Cache(httpCacheDir, httpCacheSize);
    client.setCache(cache);
    return client;
}
 
開發者ID:tevjef,項目名稱:Vapor,代碼行數:17,代碼來源:OkCloudAppModule.java

示例11: setDebugging

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:ina-foss,項目名稱:afp-api-client,代碼行數:21,代碼來源:ApiClient.java

示例12: providesOkHttpClient

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
@Provides
@Singleton
public OkHttpClient providesOkHttpClient(Application application) {
    OkHttpClient client = new OkHttpClient();
    client.setCache(new Cache(application.getCacheDir(), CACHE_SIZE));

    HttpLoggingInterceptor logger = new HttpLoggingInterceptor();
    logger.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.HEADERS : HttpLoggingInterceptor.Level.NONE);
    client.interceptors().add(logger);

    return client;
}
 
開發者ID:asadmshah,項目名稱:moviegur,代碼行數:13,代碼來源:NetworkModule.java

示例13: newTMDBService

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
public static TMDBService newTMDBService(){
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient httpClient = new OkHttpClient();
    httpClient.interceptors().add(logging);

    Retrofit movieAPIRest = new Retrofit.Builder()
            .baseUrl(TMDBService.MOVIE_DB_HOST)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .client(httpClient)
            .build();

    return movieAPIRest.create(TMDBService.class);
}
 
開發者ID:lucastanziano,項目名稱:Blockbuster,代碼行數:16,代碼來源:ServiceFactory.java

示例14: setUp

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
@Before
public void setUp() {
    twitter = new TwitterOAuth();

    myConsumer = new DefaultOAuthConsumer("vp3R3eeSvXcYAJLot3TJOE1SJ", "qqI5GFRqJCnHFiIaK10gyVqDhrvGftZFUNIfO7bWGiSvhIyoM0");

    OkHttpClient okHttpClient = new OkHttpClient();
    HttpLoggingInterceptor log = new HttpLoggingInterceptor();
    log.setLevel(HttpLoggingInterceptor.Level.BODY);
    okHttpClient.networkInterceptors().add(log);
    client = new OkHttpOAuthClient(okHttpClient, myConsumer, twitter, twitter);
}
 
開發者ID:dherges,項目名稱:okhttp-oauth,代碼行數:13,代碼來源:TwitterIntegrationTest.java

示例15: ApiClient

import com.squareup.okhttp.logging.HttpLoggingInterceptor; //導入方法依賴的package包/類
public ApiClient() {
    Gson gson = new GsonBuilder()
            .setDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'")
            .enableComplexMapKeySerialization()
            .setPrettyPrinting()
            .create();

    OkHttpClient client = new OkHttpClient();
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    client.interceptors().add(loggingInterceptor);
    Retrofit retrofit = new Retrofit.Builder()
            .client(client)
            .baseUrl(Constants.BASE_API_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();


    apiService = retrofit.create(ApiService.class);


    Retrofit sessionRetrofit = new Retrofit.Builder()
            .baseUrl(Constants.BASE_API_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .client(createRequestInterceptorClient())
            .build();



    sessionApiService = sessionRetrofit.create(ApiService.class);
}
 
開發者ID:vinsol-spree-contrib,項目名稱:spree-android,代碼行數:32,代碼來源:ApiClient.java


注:本文中的com.squareup.okhttp.logging.HttpLoggingInterceptor.setLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。