package com.doverfuelingsolutions.issp.api.basic

import com.doverfuelingsolutions.issp.utils.log.DFSLog
import okhttp3.Interceptor
import okhttp3.Response

class LoggingInterceptor : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val response = chain.proceed(request)
        DFSLog.v("==========>>>>>>>>>> request <<<<<<<<<<==========")
        val body = response.body()
        val stringBody = if (body == null) "null" else response.peekBody(Long.MAX_VALUE).string()
        DFSLog.v("${request.method()} ${request.url()}", response.code(), stringBody)
        return response
    }
}