本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例6: httpLoggingLevel
import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public Builder httpLoggingLevel(HttpLoggingInterceptor.Level level) {
logging.setLevel(level);
return this;
}
示例7: addLoggingInterceptor
import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
protected void addLoggingInterceptor(HttpLoggingInterceptor.Level level) {
addInterceptor(new HttpLoggingInterceptor().setLevel(level));
}
示例8: getLoggingInterceptor
import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public static Interceptor getLoggingInterceptor(HttpLoggingInterceptor.Level logLevel) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(logLevel);
return loggingInterceptor;
}
示例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;
}
示例10: level
import okhttp3.logging.HttpLoggingInterceptor; //导入方法依赖的package包/类
public HttpLoggingInterceptor.Level level() { return httpLoggingLevel;}