当前位置: 首页>>代码示例>>Java>>正文


Java HttpLoggingInterceptor.Level方法代码示例

本文整理汇总了Java中okhttp3.logging.HttpLoggingInterceptor.Level方法的典型用法代码示例。如果您正苦于以下问题:Java HttpLoggingInterceptor.Level方法的具体用法?Java HttpLoggingInterceptor.Level怎么用?Java HttpLoggingInterceptor.Level使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在okhttp3.logging.HttpLoggingInterceptor的用法示例。


在下文中一共展示了HttpLoggingInterceptor.Level方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setLogging

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
/**
 * Sets logging level to apply.
 * 
 * @param level
 *            logging level @see {@link CallLogLevel}
 */
public void setLogging(CallLogLevel level) {
    final HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    HttpLoggingInterceptor.Level logLevel = null;
    switch (level) {
        case BASIC:
            logLevel = HttpLoggingInterceptor.Level.BASIC;
            break;
        case BODY:
            logLevel = HttpLoggingInterceptor.Level.BODY;
            break;
        case HEADERS:
            logLevel = HttpLoggingInterceptor.Level.HEADERS;
            break;
        case NONE:
            logLevel = HttpLoggingInterceptor.Level.NONE;
            break;
        default:
            logLevel = HttpLoggingInterceptor.Level.NONE;
            break;

    }
    interceptor.setLevel(logLevel);
    this.client.getOkBuilder().addInterceptor(interceptor);
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:31,代码来源:ApiClientWrapper.java

示例2: getOkHttpClient

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
/**
 * 获取OkHttpClient
 * 用于打印请求参数
 *
 * @return OkHttpClient
 */
public static OkHttpClient getOkHttpClient() {
    // 日志显示级别
    HttpLoggingInterceptor.Level level = HttpLoggingInterceptor.Level.BODY;
    // 新建log拦截器
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
        @Override
        public void log(String message) {
            Log.i("http请求参数:", message);
        }
    });
    loggingInterceptor.setLevel(level);
    // 定制OkHttp
    OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
    // OkHttp进行添加拦截器loggingInterceptor
    httpClientBuilder.addInterceptor(loggingInterceptor);
    return httpClientBuilder.build();
}
 
开发者ID:alidili,项目名称:Demos,代码行数:24,代码来源:RetrofitUtils.java

示例3: Config

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public Config(String clientId,
              String secret,
              String apiHost,
              boolean useHttps,
              List<Scope> scopes,
              OkHttpClient httpClient,
              HttpLoggingInterceptor.Level httpLoggingLevel) {
    this.clientId = clientId;
    this.secret = secret;
    this.scopes = Collections.unmodifiableList(scopes);
    this.apiHost = stripPrefix(apiHost);
    this.useHttps = useHttps;
    this.httpLoggingLevel = httpLoggingLevel;

    if(httpClient == null) {
        throw new IllegalStateException("HttpClient is required");
    }
    this.httpClient = httpClient;
}
 
开发者ID:domoinc,项目名称:domo-java-sdk,代码行数:20,代码来源:Config.java

示例4: getHttpLoggingInterceptor

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public HttpLoggingInterceptor getHttpLoggingInterceptor(LogLevel logLevel) {
  HttpLoggingInterceptor.Level level;
  if (BuildConfig.DEBUG) {
    level = HttpLoggingInterceptor.Level.NONE;
    return new HttpLoggingInterceptor().setLevel(level);
  }
  switch (logLevel) {
    case body:
      level = HttpLoggingInterceptor.Level.BODY;
      break;
    case header:
      level = HttpLoggingInterceptor.Level.HEADERS;
      break;
    case basic:
      level = HttpLoggingInterceptor.Level.BASIC;
      break;
    default:
      level = HttpLoggingInterceptor.Level.BODY;
      break;
  }
  return new HttpLoggingInterceptor().setLevel(level);
}
 
开发者ID:MixAndroid,项目名称:MixUtils,代码行数:23,代码来源:Api.java

示例5: getHttpLoggingInterceptor

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
/**
 * 日志输出
 * 自行判定是否添加
 * @return
 */
private HttpLoggingInterceptor getHttpLoggingInterceptor(){
    //日志显示级别
    HttpLoggingInterceptor.Level level= HttpLoggingInterceptor.Level.BODY;
    //新建log拦截器
    HttpLoggingInterceptor loggingInterceptor=new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
        @Override
        public void log(String message) {
            Log.d("RxRetrofit","Retrofit====Message:"+message);
        }
    });
    loggingInterceptor.setLevel(level);
    return loggingInterceptor;
}
 
开发者ID:guzhigang001,项目名称:Bailan,代码行数:19,代码来源:HttpManager.java

示例6: httpLoggingLevel

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public Builder httpLoggingLevel(HttpLoggingInterceptor.Level level) {
    logging.setLevel(level);
    return this;
}
 
开发者ID:domoinc,项目名称:domo-java-sdk,代码行数:5,代码来源:Config.java

示例7: addLoggingInterceptor

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
protected void addLoggingInterceptor(HttpLoggingInterceptor.Level level) {
    addInterceptor(new HttpLoggingInterceptor().setLevel(level));
}
 
开发者ID:SpryRocks,项目名称:AndroidModules-Samples,代码行数:4,代码来源:ApiBase.java

示例8: getLoggingInterceptor

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public static Interceptor getLoggingInterceptor(HttpLoggingInterceptor.Level logLevel) {
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(logLevel);
    return loggingInterceptor;
}
 
开发者ID:ehsunshine,项目名称:memory-game,代码行数:6,代码来源:ServiceUtils.java

示例9: createLoggingInterceptor

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
private Interceptor createLoggingInterceptor() {

        final HttpLoggingInterceptor.Level level = enableDebug ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE;

        final HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(level);

        return interceptor;
    }
 
开发者ID:MikeFot,项目名称:Java--Steam-Loader,代码行数:10,代码来源:OkHttpFactoryImpl.java

示例10: level

import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public HttpLoggingInterceptor.Level level() { return httpLoggingLevel;} 
开发者ID:domoinc,项目名称:domo-java-sdk,代码行数:2,代码来源:Config.java


注:本文中的okhttp3.logging.HttpLoggingInterceptor.Level方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。