Class LogInterceptor
- java.lang.Object
-
- com.contentful.java.cda.interceptor.LogInterceptor
-
- All Implemented Interfaces:
okhttp3.Interceptor
public class LogInterceptor extends java.lang.Object implements okhttp3.InterceptorSimple interceptor to log a request and its response.
-
-
Constructor Summary
Constructors Constructor Description LogInterceptor(Logger logger)Creates a LogInterceptor, taking a logger to be logged to, once a request comes in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description okhttp3.Responseintercept(okhttp3.Interceptor.Chain chain)Log the incoming request.
-
-
-
Constructor Detail
-
LogInterceptor
public LogInterceptor(Logger logger)
Creates a LogInterceptor, taking a logger to be logged to, once a request comes in.- Parameters:
logger- a nonnull logger to be used.- Throws:
java.lang.IllegalArgumentException- if a null logger was given.
-
-
Method Detail
-
intercept
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws java.io.IOExceptionLog the incoming request.Once a request gets triggered in okhttp3, this interceptor gets called.
- Specified by:
interceptin interfaceokhttp3.Interceptor- Parameters:
chain- the chain of interceptor, provided by the okhttp3.- Returns:
- the response of the chain.
- Throws:
java.io.IOException- in case of failure down the line.
-
-