package rasel.lunar.launcher.utils

import android.util.Log
import rasel.lunar.launcher.BuildConfig

object BLog {
    val DEFAULT_TAG = "Lunatic"
    enum class BLogType {
        D,I,E
    }
    fun w(tag : String = DEFAULT_TAG, log: String){
        LOG(BLogType.D,tag,log)
    }

    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 -> {}
            }
        }
    }
}