public class HttpLoggingInterceptor
extends java.lang.Object
描述:设置日志拦截器
提供了详细、易懂的日志打印| Modifier and Type | Class and Description |
|---|---|
static class |
HttpLoggingInterceptor.Level |
| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger |
protected java.lang.String |
tag |
| Constructor and Description |
|---|
HttpLoggingInterceptor(java.lang.String tag) |
HttpLoggingInterceptor(java.lang.String tag,
boolean isPrintStack) |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
bodyToString(Request request) |
HttpLoggingInterceptor.Level |
getLevel() |
java.lang.String |
getTag() |
Response |
intercept(Chain chain) |
void |
log(java.lang.String message) |
protected void |
logForRequest(Request request,
Connection connection)
记录请求日志
|
protected Response |
logForResponse(Response response,
long tookMs)
记录响应日志
|
protected void |
onError(java.lang.Throwable t) |
HttpLoggingInterceptor |
setLevel(HttpLoggingInterceptor.Level level) |
HttpLoggingInterceptor |
setTag(java.lang.String tag) |
public HttpLoggingInterceptor(java.lang.String tag)
public HttpLoggingInterceptor(java.lang.String tag,
boolean isPrintStack)
public void log(java.lang.String message)
public HttpLoggingInterceptor setLevel(HttpLoggingInterceptor.Level level)
public HttpLoggingInterceptor setTag(java.lang.String tag)
public java.lang.String getTag()
public HttpLoggingInterceptor.Level getLevel()
public Response intercept(Chain chain)
throws java.io.IOException
java.io.IOExceptionprotected void logForRequest(Request request,
Connection connection)
throws java.io.IOException
request - connection - java.io.IOExceptionprotected Response logForResponse(Response response,
long tookMs)
response - tookMs - 请求花费的时间protected java.lang.String bodyToString(Request request)
protected void onError(java.lang.Throwable t)