package com.example.base.utils

import com.example.base.BuildConfig
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy


/**
 *
 * 描述: 日志打印输出
 *
 */
object L {

    private const val mTag = "Material"

    init {
        val formatStrategy = PrettyFormatStrategy.newBuilder()
            .showThreadInfo(false)  // (Optional) Whether to show thread info or not. Default true
            .methodCount(0)         // (Optional) How many method line to show. Default 2
            .methodOffset(7)        // (Optional) Hides internal method calls up to offset. Default 5
            .tag(mTag)   // (Optional) Global tag for every log. Default PRETTY_LOGGER
            .build()
        Logger.addLogAdapter(object : AndroidLogAdapter(formatStrategy) {
            override fun isLoggable(priority: Int, tag: String?): Boolean {
                return BuildConfig.DEBUG
            }
        })

    }

    fun i(message: String?, vararg args: Any?) {
        Logger.i(message ?: "", args)
    }

    fun d(any: Any?) {
        Logger.d(any)
    }

    fun e(message: String?, vararg args: Any?) {
        Logger.e(message ?: "", args)
    }

    fun json(json: String?) {
        Logger.json(json)
    }
}