Java 类okhttp3.logging.HttpLoggingInterceptor 实例源码

项目:in-store-api-java-sdk    文件:DHProvider.java   
default DH getDH() {
    Gson gson = NetworkUtilities.getGson();

    OkHttpClient.Builder clientBuilder = NetworkUtilities.getClient(getSatispayContext());
    if (getSatispayContext().enableLog()) {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        clientBuilder.addInterceptor(interceptor);
    }

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(getSatispayContext().getBaseUrl())
            .addConverterFactory(GsonConverterFactory.create(gson))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .client(clientBuilder.build())
            .build();

    return retrofit.create(DH.class);
}
项目:Andela-ALC-Challenge    文件:ApiClient.java   
public static Retrofit getClient() {

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder()
                .addInterceptor(interceptor)
                .readTimeout(60, TimeUnit.SECONDS)
                .connectTimeout(60, TimeUnit.SECONDS)
                .build();

        if (retrofit==null) {
            retrofit = new Retrofit.Builder()
                    .addCallAdapterFactory(rxAdapter)
                    .baseUrl(BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .client(client)
                    .build();
        }
        return retrofit;
    }
项目:popomusic    文件:ApiManager.java   
private ApiManager(){
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(message -> showRetrofitLog(message)).setLevel(HttpLoggingInterceptor.Level.BODY);//打印请求日志
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .readTimeout(READ_TIME_OUT, TimeUnit.SECONDS)
            .connectTimeout(CONNECT_TIME_OUT,TimeUnit.SECONDS)
            .addInterceptor(loggingInterceptor)
            .build();
    Retrofit retrofit1 = new Retrofit.Builder()

            .client(okHttpClient)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .baseUrl(Constant.QQ_MUSIC_BASE_URL)
            .build();
    mQQMusicApiService = retrofit1.create(QQMusicApi.class);
}
项目:OffIt    文件:RestClient.java   
private static Retrofit getRetrofit() {
    HttpLoggingInterceptor logger = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
        @Override
        public void log(@NonNull String s) {
            Log.d("Http", s);
        }
    });

    logger.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(logger).build();

    return new Retrofit.Builder()
            .client(client)
            .baseUrl("http://jsonplaceholder.typicode.com/")
            .addConverterFactory(GsonConverterFactory.create())
            .build();
}
项目:mvvm-template    文件:ServiceFactory.java   
public static OkHttpClient.Builder makeOkHttpClientBuilder(Context context, @NonNull UserTokenProducer producer) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();

    if (BuildConfig.DEBUG) {
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    }

    OkHttpClient.Builder builder;
    builder = new OkHttpClient.Builder()
            .addInterceptor(new AuthorizationInterceptor(producer))
            .addInterceptor(new PaginationInterceptor())
            .addInterceptor(new ContentTypeInterceptor())
            .addInterceptor(logging)
            .followRedirects(true)
            .followSslRedirects(true)
            .retryOnConnectionFailure(true)
            .cache(null)
            .connectTimeout(RemoteConstants.TIME_OUT_API, TimeUnit.SECONDS)
            .writeTimeout(RemoteConstants.TIME_OUT_API, TimeUnit.SECONDS)
            .readTimeout(RemoteConstants.TIME_OUT_API, TimeUnit.SECONDS);

    // add cache to client
    final File baseDir = context.getCacheDir();
    if (baseDir != null) {
        final File cacheDir = new File(baseDir, "HttpResponseCache");
        builder.cache(new Cache(cacheDir, 10 * 1024 * 1024)); // 10 MB
    }

    return enableTls12OnPreLollipop(builder);
}
项目:GitHub    文件:RetrofitUtils.java   
/**
 * 设置okHttp
 *
 * @author ZhongDaFeng
 */
private static OkHttpClient okHttpClient() {
    //开启Log
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
        @Override
        public void log(String message) {
            LogUtils.e("okHttp:" + message);
        }
    });
    logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
    OkHttpClient client = new OkHttpClient.Builder()
            .connectTimeout(CONNECT_TIME_OUT, TimeUnit.SECONDS)
            .writeTimeout(WRITE_TIME_OUT, TimeUnit.SECONDS)
            .readTimeout(READ_TIME_OUT, TimeUnit.SECONDS)
            .addInterceptor(logging)
            .build();
    return client;
}
项目:beegoapix-android-demo    文件:ApiClient.java   
private ApiClient() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder()
            .addInterceptor(interceptor)
            .addInterceptor(new SessionInterceptor())
            //.addInterceptor(new GzipRequsetInterceptor())
            .build();
    OKHttpUtils.cancelCallWithTag(client);
    this.retrofit = new Retrofit.Builder()
            .baseUrl(API_HOST)
            .client(client)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
}
项目:JueDiQiuSheng    文件:ZKConnectionManager.java   
private Retrofit getRetrofit() {

        //http://blog.csdn.net/u014695188/article/details/52985514
        OkHttpClient.Builder builder = new OkHttpClient.Builder();

        builder.connectTimeout(10, TimeUnit.SECONDS);
        builder.readTimeout(10, TimeUnit.SECONDS);
        builder.writeTimeout(10, TimeUnit.SECONDS);

        if (ZKBase.isDebug) {
            //log信息拦截器
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
            httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            //设置Debug Log模式
            builder.addInterceptor(httpLoggingInterceptor);
        }

        return new Retrofit.Builder()
                .baseUrl(Constant.ZKTEAM_DOMAIN_URL)
                .client(builder.build())
                .addConverterFactory(GsonConverterFactory.create(getGson()))
                .build();
    }
项目:GitHub    文件:Api.java   
private Api() {
    HttpLoggingInterceptor logInterceptor = new HttpLoggingInterceptor();
    logInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    File cacheFile = new File(App.getAppContext().getCacheDir(), "cache");
    Cache cache = new Cache(cacheFile, 1024 * 1024 * 100); //100Mb

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .readTimeout(7676, TimeUnit.MILLISECONDS)
            .connectTimeout(7676, TimeUnit.MILLISECONDS)
            .addInterceptor(headInterceptor)
            .addInterceptor(logInterceptor)
            .addNetworkInterceptor(new HttpCacheInterceptor())
            .cache(cache)
            .build();

    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").serializeNulls().create();

    retrofit = new Retrofit.Builder()
            .client(okHttpClient)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .baseUrl(C.BASE_URL)
            .build();
    service = retrofit.create(ApiService.class);
}
项目:Tusky    文件:BaseActivity.java   
protected void createMastodonApi() {
    mastodonApiDispatcher = new Dispatcher();

    Gson gson = new GsonBuilder()
            .registerTypeAdapter(Spanned.class, new SpannedTypeAdapter())
            .create();

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    OkHttpClient.Builder okBuilder =
            OkHttpUtils.getCompatibleClientBuilder(preferences)
                    .addInterceptor(new AuthInterceptor(this))
                    .dispatcher(mastodonApiDispatcher);

    if (BuildConfig.DEBUG) {
        okBuilder.addInterceptor(
                new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC));
    }

    Retrofit retrofit = new Retrofit.Builder().baseUrl(getBaseUrl())
            .client(okBuilder.build())
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();

    mastodonApi = retrofit.create(MastodonApi.class);
}
项目:ITSM    文件:GlideUtils.java   
public static synchronized OkHttpClient getOkHttpClient() {
  if (okHttpClient == null) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.connectTimeout(90, TimeUnit.SECONDS);
    builder.sslSocketFactory(createSSLSocketFactory());
    builder.hostnameVerifier(new HostnameVerifier() {
      @Override public boolean verify(String hostname, SSLSession session) {
        return true;
      }
    });
    if (BuildConfig.DEBUG) {
      // Log信息拦截器
      HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
      loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);//这里可以选择拦截级别

      //设置 Debug Log 模式
      builder.addInterceptor(loggingInterceptor);
    }
    okHttpClient = builder.build();
  }
  return okHttpClient;
}
项目:toshi-headless-client    文件:BalanceService.java   
public BalanceService(HDWallet wallet, String baseUrl) {
    //final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory
    //        .createWithScheduler(Schedulers.io());
    this.client = new OkHttpClient.Builder();
    this.client.addInterceptor(new UserAgentInterceptor());
    this.client.addInterceptor(new SigningInterceptor(wallet));

    final HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(new LoggingInterceptor());
    interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    this.client.addInterceptor(interceptor);

    final Moshi moshi = new Moshi.Builder()
                                .add(new BigIntegerAdapter())
                                .build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .client(client.build())
            .build();
    this.balanceInterface = retrofit.create(BalanceInterface.class);
}
项目:InstantAppStarter    文件:AppApiHelper.java   
private ApiClient getApiClient() {

        OkHttpClient.Builder client = new OkHttpClient.Builder();
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        client.addInterceptor(loggingInterceptor);

        OkHttpClient myClient = client.build();

        if (BuildConfig.DEBUG) {
            IdlingResources.registerOkHttp(myClient);
        }

        Retrofit retrofit = new Retrofit
                .Builder()
                .baseUrl(BuildConfig.BASE_URL)
                .client(myClient)
                .addConverterFactory(RaveConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
        return retrofit.create(ApiClient.class);
    }
项目:TVGuide    文件:TvApiClient.java   
public static Retrofit getClient() {
    if (sRetrofit == null) {
        synchronized (Retrofit.class) {
            if (sRetrofit == null) {
                HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
                interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
                OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
                sRetrofit = new Retrofit.Builder()
                        .baseUrl(BuildConfig.BASE_URL)
                        .addConverterFactory(GsonConverterFactory.create())
                        .client(client)
                        .build();
            }
        }
    }
    return sRetrofit;
}
项目:Mafia-TCoS-CS319-Group2A    文件:APICallHelper.java   
private static void setupRestClient() {

        String restApiURL = DEV_URL;


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

        OkHttpClient client = new OkHttpClient.Builder()
                .connectTimeout(30, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .addInterceptor(interceptor).build();

        retrofit = new Retrofit.Builder()
                .baseUrl(restApiURL)
                .client(client)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
项目:GCSApp    文件:AppClient2.java   
public static Retrofit retrofit() {
    if (mRetrofit == null) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();

        if (BuildConfig.DEBUG) {
            // Log信息拦截器
            HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            //设置 Debug Log 模式
            builder.addInterceptor(loggingInterceptor);
        }
        OkHttpClient okHttpClient = builder.build();
        mRetrofit = new Retrofit.Builder()
                .baseUrl(ApiStores2.URL_BASE)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .client(okHttpClient)
                .build();
    }
    return mRetrofit;
}
项目:GitHubRxJava    文件:ServiceFactory.java   
public static <T> T createRetrofitService(final Class<T> clazz, final String endPoint) {
    // Logs
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    final Retrofit restAdapter = new Retrofit.Builder()
            .baseUrl(endPoint)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .client(new OkHttpClient.Builder()
                    .addInterceptor(interceptor)
                    .build())
            .build();

    return restAdapter.create(clazz);
}
项目:movie-android    文件:NetworkUtils.java   
/**
 * Method to create a new Retrofit instance
 * Add the API key {@link MoviesApiInterceptor#intercept(Interceptor.Chain)}
 * Show debug information only in DEBUG build
 *
 * @return Retrofit - used for building API calls
 */
public static Retrofit buildRetrofit() {
    OkHttpClient.Builder httpClient =
            new OkHttpClient.Builder();
    httpClient.addInterceptor(new MoviesApiInterceptor());

    if (BuildConfig.DEBUG) {
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        httpClient.addInterceptor(loggingInterceptor);
    }

    return new Retrofit.Builder()
            .baseUrl(MOVIEDB_BASE_URL)
            .client(httpClient.build())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .build();
}
项目:retrofit-xmlrpc    文件:WordpressIntegrationTest.java   
@Before
public void setUp() {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient client = new OkHttpClient()
            .newBuilder()
            .addInterceptor(logging)
            .build();

    retrofit = new Retrofit.Builder()
            .client(client)
            .baseUrl(URL)
            .addConverterFactory(XmlRpcConverterFactory.create())
            .build();
}
项目:CrazyDaily    文件:HttpHelper.java   
@Inject
public HttpHelper() {
    if (mOkHttpClient == null) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLogger());
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        builder.addInterceptor(loggingInterceptor);
        //设置超时
        builder.connectTimeout(10, TimeUnit.SECONDS);
        builder.readTimeout(20, TimeUnit.SECONDS);
        builder.writeTimeout(20, TimeUnit.SECONDS);
        //错误重连
        builder.retryOnConnectionFailure(true);
        mOkHttpClient = builder.build();
    }
}
项目:GuardianReader    文件:NetModule.java   
@Provides
@Singleton
OkHttpClient provideOkhttpClient(final Cache cache, final Application application) {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient.Builder client = new OkHttpClient.Builder().addInterceptor(interceptor);
    client.cache(cache).addInterceptor(new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            // Read from the cache when there is no network
            if (NetworkUtils.isNetworkAvailable(application)) {
                request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
            } else {
                request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 7).build();
            }
            return chain.proceed(request);
        }
    });
    return client.build();
}
项目:AndroidMVP    文件:ApiClient.java   
public static Retrofit getClient(String url) {
    if (retrofit==null) {
        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);

        OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder()
                .connectTimeout(6000, TimeUnit.SECONDS)
                .readTimeout(6000, TimeUnit.SECONDS)
                .addInterceptor(logging);

        retrofit = new Retrofit.Builder()
                .baseUrl(url)
                .client(okHttpClientBuilder.build())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
    return retrofit;
}
项目:eggs-android    文件:ClientModule.java   
@Singleton
@Provides
public OkHttpClient provideOkHttpClient(HttpLoggingInterceptor loggingInterceptor,
                                        @Named("networkTimeoutInSeconds") int networkTimeoutInSeconds,
                                        @Named("isDebug") boolean isDebug,
                                        Cache cache,
                                        @Named("cacheInterceptor") Interceptor cacheInterceptor,
                                        @Named("offlineInterceptor") Interceptor offlineCacheInterceptor,
                                        @Named("retryInterceptor") Interceptor retryInterceptor) {

    OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder()
            .addNetworkInterceptor(cacheInterceptor)
            .addInterceptor(offlineCacheInterceptor)
            .addInterceptor(retryInterceptor)
            .cache(cache)
            .connectTimeout(networkTimeoutInSeconds, TimeUnit.SECONDS);

    //show logs if app is in Debug mode
    if (isDebug)
        okHttpClient.addInterceptor(loggingInterceptor);

    return okHttpClient.build();
}
项目:AppAuth-OAuth2-Books-Demo    文件:AuthRepo.java   
private UserInfoAPI createUserInfoAPI() {
    HttpLoggingInterceptor logger = new HttpLoggingInterceptor();
    logger.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient authClient = new OkHttpClient().newBuilder()
            .addInterceptor(getAccessTokenInterceptor())
            .addInterceptor(logger)
            .build();

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

    return retrofit.create(UserInfoAPI.class);
}
项目:OAuth-2.0-Cookbook    文件:ClientAPI.java   
private ClientAPI() {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder client = new OkHttpClient.Builder();
    client.addInterceptor(logging);
    client.addInterceptor(new BearerTokenHeaderInterceptor());
    client.addInterceptor(new ErrorInterceptor());

    retrofit = new Retrofit.Builder()
            .baseUrl("http://" + BASE_URL)
            .addConverterFactory(JacksonConverterFactory.create())
            .client(client.build())
            .build();

}
项目:OAuth-2.0-Cookbook    文件:ClientAPI.java   
private ClientAPI(OAuth2ClientAuthenticationInterceptor basicAuthentication) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder client = new OkHttpClient.Builder();
    client.addInterceptor(logging);
    client.addInterceptor(new ErrorInterceptor());
    client.addInterceptor(new BearerTokenHeaderInterceptor());

    if (basicAuthentication != null) {
        client.addInterceptor(basicAuthentication);
    }

    retrofit = new Retrofit.Builder()
            .baseUrl("http://" + BASE_URL)
            .addConverterFactory(JacksonConverterFactory.create())
            .client(client.build())
            .build();
}
项目:exchange-rates-mvvm    文件:NetModule.java   
@Override
@Provides
@Singleton
public OkHttpClient provideOkHttpClient(ApplicationProperties propertiesManager) {

    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    if (propertiesManager.logsEnabled()) {
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    } else {
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
    }

    return new OkHttpClient.Builder()
            .addInterceptor(loggingInterceptor)
            .build();
}
项目:Dalaran    文件:XApiServiceHelper.java   
public static   <T> T create(Class<T> c, String url) {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder()
            .addInterceptor(interceptor)//日志拦截器
            .addNetworkInterceptor(new CommonInterceptor())//网络拦截器,进行重定向等操作
            .connectTimeout(10, TimeUnit.SECONDS)//设置连接超时
            .build();
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(url)
            .addConverterFactory(XJsonConverterFactory.create())//json数据转换
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())//将Callable接口转换成Observable接口
            .client(client)//网络请求客户端为okhttp
            .build();
    return retrofit.create(c);
}
项目:gigreminder    文件:Injection.java   
@Override
@NonNull
public OkHttpClient provideOkHttpClient() {
    Level logLevel = BuildConfig.DEBUG ? Level.BASIC : Level.NONE;
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor().setLevel(logLevel);

    return new OkHttpClient.Builder()
            .addInterceptor(loggingInterceptor)
            .build();
}
项目:Barricade    文件:ChuckNorrisApiServiceTest.java   
private ChuckNorrisApiService getApiService() {
  HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
  httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

  OkHttpClient okHttpClient = new OkHttpClient.Builder().addInterceptor(new BarricadeInterceptor()).addInterceptor(httpLoggingInterceptor).build();
  Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL).client(okHttpClient).addConverterFactory(GsonConverterFactory.create()).build();
  return retrofit.create(ChuckNorrisApiService.class);
}
项目:clean-news    文件:NetworkModule.java   
protected void setLoggingInterceptor(OkHttpClient.Builder clientBuilder) {
    HttpLoggingInterceptor loggingHeaders = new HttpLoggingInterceptor();
    loggingHeaders.setLevel(HttpLoggingInterceptor.Level.HEADERS);
    clientBuilder.addInterceptor(loggingHeaders);

    HttpLoggingInterceptor loggingBody = new HttpLoggingInterceptor();
    loggingBody.setLevel(HttpLoggingInterceptor.Level.BODY);
    clientBuilder.addInterceptor(loggingBody);
}
项目:EasyAppleSyncAdapter    文件:HttpClient.java   
public static OkHttpClient create(@NonNull Context context, @NonNull Account account,
                                  @NonNull HttpLoggingInterceptor logging) throws InvalidAccountException {
    OkHttpClient.Builder builder = defaultBuilder(context);

    // use account settings for authentication
    AccountSettings settings = new AccountSettings(context, account);
    builder = addAuthentication(builder, null, settings.username(), settings.password());

    // Set logger
    builder.addInterceptor(logging);

    return builder.build();
}
项目:superglue    文件:DebugApiModule.java   
@Provides @Singleton @Named("Api") OkHttpClient provideApiClient(OkHttpClient client,
    HttpLoggingInterceptor loggingInterceptor) {
  return ApiModule.createApiClient(client)
      .addInterceptor(loggingInterceptor)
      .addInterceptor(new StethoInterceptor())
      .build();
}
项目:Impala    文件:ApiModule.java   
@Provides
@Singleton
OkHttpClient provideOkHttpClient() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    return new OkHttpClient.Builder().addInterceptor(interceptor).build();
}
项目:GitHub    文件:HttpUtils.java   
private HttpLoggingInterceptor getInterceptor() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    if (debug) {
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); // 测试
    } else {
        interceptor.setLevel(HttpLoggingInterceptor.Level.NONE); // 打包
    }
    return interceptor;
}
项目:react-native-android-library-humaniq-api    文件:ServiceBuilder.java   
public static void init(String baseURL, Context context) {
  HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
  interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
  //OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

  retrofit = new Retrofit.Builder().baseUrl(baseURL)
      //.client(client)
      .client(SelfSigningClientBuilder.createClient(context))
      .addConverterFactory(GsonConverterFactory.create())
      .build();
}
项目:INFOotball    文件:NetworkModule.java   
@Provides
@Singleton
public OkHttpClient provideOkHttpClient(){
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
    return client;
}
项目:Daejeon-People    文件:APIClient.java   
public static Retrofit getClient() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

    retrofit = new Retrofit.Builder()
            .baseUrl("http://52.79.134.200")
            .addConverterFactory(GsonConverterFactory.create())
            .addConverterFactory(ScalarsConverterFactory.create())
            .client(client)
            .build();

    return retrofit;
}
项目:TrackIt-Android    文件:TheTvdb.java   
protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
    builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
            .authenticator(new TheTvdbAuthenticator(this));
    if (enableDebugLogging) {
        logging = new HttpLoggingInterceptor();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);
        builder.addInterceptor(logging);
    }
}
项目:BeautifulGirls    文件:RetrofitSingleton.java   
private void initOkHttp() {
    OkHttpClient.Builder client = new OkHttpClient.Builder();
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    client.addInterceptor(loggingInterceptor);

    //设置超时
    client.connectTimeout(15, TimeUnit.SECONDS);
    client.readTimeout(20, TimeUnit.SECONDS);
    client.writeTimeout(20, TimeUnit.SECONDS);
    //错误重连
    client.retryOnConnectionFailure(true);
    sOkHttp = client.build();

}