package ru.fincode.tsudesk.core.network.interceptor

import android.util.Log
import okhttp3.Call
import okhttp3.EventListener
import ru.fincode.tsudesk.core.common.log.logD
import java.io.IOException
import java.net.InetAddress


class NetEventLogger : EventListener() {
    override fun dnsStart(call: Call, domainName: String) {
        logD("dnsStart: $domainName")
    }

    override fun dnsEnd(call: Call, domainName: String, inetAddressList: List<InetAddress>) {
        logD("dnsEnd: $domainName -> $inetAddressList")
    }

    override fun connectStart(
        call: Call,
        inetSocketAddress: java.net.InetSocketAddress,
        proxy: java.net.Proxy
    ) {
        logD("connectStart: $inetSocketAddress proxy=$proxy")
    }

    override fun secureConnectStart(call: Call) {
        logD("tlsStart")
    }

    override fun secureConnectEnd(call: Call, handshake: okhttp3.Handshake?) {
        logD("tlsEnd: $handshake")
    }

    override fun requestHeadersStart(call: Call) {
        logD("reqHeadersStart")
    }

    override fun responseHeadersStart(call: Call) {
        logD("respHeadersStart")
    }

    override fun callFailed(call: Call, ioe: IOException) {
        logD("callFailed", ioe)
    }

    override fun callEnd(call: Call) {
        logD("callEnd")
    }
}
