package com.mime.dualscreenview.common

import android.util.Log
import com.mime.dualscreenview.BuildConfig
import java.lang.Exception


object Blog {
    val DEFAULT_TAG = "MyEBook_TAG"
    enum class BLogType {
        D,I,E
    }

    fun LOGD(tag : String = DEFAULT_TAG, log: String){
        LOG(BLogType.D,tag,log)
    }

    fun LOGI(tag : String = DEFAULT_TAG, log: String){
        LOG(BLogType.I,tag,log)
    }

    fun LOGE(tag : String = DEFAULT_TAG, log: Throwable){
        LOG(BLogType.E,tag,log.toString())
    }

    fun LOGE(tag : String = DEFAULT_TAG, log: Exception){
        LOG(BLogType.E,tag,log.toString())
    }

    fun LOGE(tag : String = DEFAULT_TAG, log: String){
        LOG(BLogType.E,tag,log)
    }

    fun LOGE(log: String){
        LOG(BLogType.E,DEFAULT_TAG,log)
    }

    private fun LOG(type : BLogType, tag : String, log : String) {
        if (BuildConfig.DEBUG || BuildConfig.BUILD_TYPE.contains("debug")) {
            when(type) {
                BLogType.D -> {
                    Log.d(tag,log)
                }
                BLogType.I -> {
                    Log.i(tag,log)
                }
                BLogType.E -> {
                    Log.e(tag,log)
                }
                else -> {}
            }
        }
    }
}