Package com.microsoft.rest.interceptors
Class LoggingInterceptor
- java.lang.Object
-
- com.microsoft.rest.interceptors.LoggingInterceptor
-
- All Implemented Interfaces:
okhttp3.Interceptor
public class LoggingInterceptor extends Object implements okhttp3.Interceptor
An OkHttp interceptor that handles logging of HTTP requests and responses.
-
-
Constructor Summary
Constructors Constructor Description LoggingInterceptor(LogLevel logLevel)Creates an interceptor with a LogLevel enum.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description okhttp3.Responseintercept(okhttp3.Interceptor.Chain chain)protected voidlog(org.slf4j.Logger logger, String s)Process the log using an SLF4j logger and an HTTP message.LogLevellogLevel()LoggingInterceptorwithLogLevel(LogLevel logLevel)Sets the current logging level.
-
-
-
Constructor Detail
-
LoggingInterceptor
public LoggingInterceptor(LogLevel logLevel)
Creates an interceptor with a LogLevel enum.- Parameters:
logLevel- the level of traffic to log
-
-
Method Detail
-
log
protected void log(org.slf4j.Logger logger, String s)Process the log using an SLF4j logger and an HTTP message.- Parameters:
logger- the SLF4j logger with the context of the requests- the message for logging
-
intercept
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException- Specified by:
interceptin interfaceokhttp3.Interceptor- Throws:
IOException
-
logLevel
public LogLevel logLevel()
- Returns:
- the current logging level.
-
withLogLevel
public LoggingInterceptor withLogLevel(LogLevel logLevel)
Sets the current logging level.- Parameters:
logLevel- the new logging level- Returns:
- the interceptor
-
-