All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gocardless.http.LoggingInterceptor Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
package com.gocardless.http;

import com.google.common.base.Stopwatch;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingInterceptor implements Interceptor {
    private static final Logger LOGGER = LoggerFactory.getLogger(LoggingInterceptor.class);

    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Stopwatch stopwatch = Stopwatch.createStarted();
        Response response = chain.proceed(request);
        stopwatch.stop();
        LOGGER.info("API request [{}] [{}] returned [{}] (took [{}])", request.method(),
                request.url(), response.code(), stopwatch);
        return response;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy