package com.duben.microtribe.utils

import com.bytedance.sdk.openadsdk.mediation.manager.MediationBaseManager

class GromorePrintUtil {
    
    companion object {
        private val TAG = GromorePrintUtil::class.java.simpleName

        /**
         * 打印其他加载信息
         */
        fun printLoadInfo(adInfo: MediationBaseManager?) {
            LogUtil.d(TAG, "--------------------- printLoadInfo 11111111 ------------------------")

            adInfo?.let {
                val adLoadInfo = adInfo.adLoadInfo
                LogUtil.d(TAG, "--------------------- 广告加载信息 start ------------------------")
                LogUtil.d(TAG, "------ 广告加载信息 ")
                adLoadInfo.forEach { it ->
                    LogUtil.d(
                        TAG,
                        "代码位id = ${it.mediationRit} adnName = ${it.adnName} adType = ${it.adType}" +
                                " errCode = ${it.errCode} errMsg = ${it.errMsg}"
                    )
                }

                LogUtil.d(TAG, "------ 广告价格信息 ")
                val multiBiddingEcpm = adInfo.multiBiddingEcpm
                multiBiddingEcpm?.let {
                    it.forEach { item ->
                        LogUtil.d(
                            TAG,
                            "sdkName = ${item.sdkName} slotId = ${item.slotId} levelTag = ${item.levelTag}" +
                                    " ecpm = ${item.ecpm} reqBiddingType = ${item.reqBiddingType} errorMsg = ${item.errorMsg} requestId = ${item.requestId}"
                        )
                    }
                }

                LogUtil.d(TAG, "------ 最优广告价格信息 ")
                val bestEcpm = adInfo.bestEcpm
                bestEcpm?.let {
                    LogUtil.d(
                        TAG,
                        "sdkName = ${bestEcpm.sdkName} slotId = ${bestEcpm.slotId} levelTag = ${bestEcpm.levelTag}" +
                                " ecpm = ${bestEcpm.ecpm} reqBiddingType = ${bestEcpm.reqBiddingType} " +
                                "errorMsg = ${bestEcpm.errorMsg} requestId = ${bestEcpm.requestId}"
                    )
                }

                LogUtil.d(TAG, "------ 当前缓存池的全部信息 ")
                val cacheList = adInfo.cacheList
                cacheList?.let {
                    it.forEach { item ->
                        LogUtil.d(
                            TAG,
                            "sdkName = ${item.sdkName} slotId = ${item.slotId} levelTag = ${item.levelTag}" +
                                    " ecpm = ${item.ecpm} reqBiddingType = ${item.reqBiddingType} errorMsg = ${item.errorMsg} requestId = ${item.requestId}"
                        )
                    }
                }
                LogUtil.d(TAG, "--------------------- 广告加载信息 end ------------------------")
            }
            LogUtil.d(TAG, "--------------------- printLoadInfo 22222222 ------------------------")
        }

        /**
         * 打印展示
         */
        fun printShowInfo(adInfo: MediationBaseManager?) {
            adInfo?.let {
                LogUtil.d(TAG, "--------------------- 广告展示信息 start ------------------------")
                val showEcpm = adInfo.showEcpm
                if(showEcpm != null){
                    LogUtil.d(
                        TAG,
                        "sdkName = ${showEcpm.sdkName} slotId = ${showEcpm.slotId} levelTag = ${showEcpm.levelTag}" +
                                " ecpm = ${showEcpm.ecpm} reqBiddingType = ${showEcpm.reqBiddingType} " +
                                "errorMsg = ${showEcpm.errorMsg} requestId = ${showEcpm.requestId}"
                    )
                } else {
                    LogUtil.d(TAG, "showEcpm is null")
                }
                LogUtil.d(TAG, "--------------------- 广告加载信息 end ------------------------")
            }
        }
    }
}