package com.common.commonlib.log

import android.util.Log

/**
 * Log工具类
 *
 * @author wangym
 * @since 2021/7/28
 */
object Logger {
    var commonTag = ""
    var needSecurity = false

    fun init(tag: String, security: Boolean) {
        commonTag = tag
        needSecurity = security
    }

    fun w(msg: Any?) {
        w(commonTag, msg.toString(), needSecurity)
    }

    fun d(msg: Any?) {
        d(commonTag, msg.toString(), needSecurity)
    }

    fun i(msg: Any?) {
        i(commonTag, msg.toString(), needSecurity)
    }

    fun e(msg: Any?) {
        e(commonTag, msg.toString(), needSecurity)
    }

    fun w(msg: Any?, needSecurity: Boolean) {
        w(commonTag, msg.toString(), needSecurity)
    }

    fun d(msg: Any?, needSecurity: Boolean) {
        d(commonTag, msg.toString(), needSecurity)
    }

    fun i(msg: Any?, needSecurity: Boolean) {
        i(commonTag, msg.toString(), needSecurity)
    }

    fun e(msg: Any?, needSecurity: Boolean) {
        e(commonTag, msg.toString(), needSecurity)
    }

    fun w(tag: String, msg: Any?) {
        w(tag, msg.toString(), needSecurity)
    }

    fun d(tag: String, msg: Any?) {
        d(tag, msg.toString(), needSecurity)
    }

    fun i(tag: String, msg: Any?) {
        i(tag, msg.toString(), needSecurity)
    }

    fun e(tag: String, msg: Any?) {
        e(tag, msg.toString(), needSecurity)
    }

    fun w(tag: String, msg: Any?, needSecurity: Boolean) {
        Log.w(
            tag, if (needSecurity)
                LogSecureHelper.cast2Star(msg.toString())
            else
                msg.toString()
        )
    }

    fun d(tag: String, msg: Any?, needSecurity: Boolean) {
        Log.d(
            tag, if (needSecurity)
                LogSecureHelper.cast2Star(msg.toString())
            else
                msg.toString()
        )
    }

    fun i(tag: String, msg: Any?, needSecurity: Boolean) {
        Log.i(
            tag, if (needSecurity)
                LogSecureHelper.cast2Star(msg.toString())
            else
                msg.toString()
        )
    }

    fun e(tag: String, msg: Any?, needSecurity: Boolean) {
        Log.e(
            tag, if (needSecurity)
                LogSecureHelper.cast2Star(msg.toString())
            else
                msg.toString()
        )
    }
}