package com.composition.android.lib.ad.util

import android.util.Log
import com.composition.android.lib.ad.AdManager
import com.composition.android.lib.ad.bean.AdUnitBean
import com.composition.android.lib.ad.interfaces.IAdFormatRequest


fun adLog(tag: String = AdManager.TAG, msg: String?) {
    if (AdManager.instance.logEnable) {
        msg?.let {
            Log.i(tag, msg)
        }
    }
}


fun adLogE(tag: String, msg: String?) {
    if (AdManager.instance.logEnable) {
        msg?.let {
            Log.e(tag, msg)
        }
    }
}


fun IAdFormatRequest.printAdFailInfo(code: Int, msg: String?) {
    adLog(
        AdManager.TAG,
        "-------------------------------------------------------------------"
    )

    adLog(AdManager.TAG, "广告加载失败")
    adLog(AdManager.TAG, "Code:${code}")
    adLog(AdManager.TAG, "错误信息:${msg}")

    adLog(
        AdManager.TAG,
        "-------------------------------------------------------------------"
    )
}

fun IAdFormatRequest.printAdInfo(adBean: AdUnitBean) {
    adLog(
        AdManager.TAG,
        "-------------------------------------------------------------------"
    )

    adLog(AdManager.TAG, "广告加载成功")
    adLog(AdManager.TAG, "广告商:${adBean.advertisersName}")
    adLog(AdManager.TAG, "广告位:${adBean.adSlotName}")
    adLog(AdManager.TAG, "广告ID:${adBean.adUnitId}")
    adLog(AdManager.TAG, "广告类型:${adBean.adType}")

    adLog(
        AdManager.TAG,
        "-------------------------------------------------------------------"
    )
}
