From b5d44289783bf8043c73416bdbeaeeac77a8ee97 Mon Sep 17 00:00:00 2001 From: xiaojinzi Date: Wed, 13 Oct 2021 15:27:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=97=A5=E5=BF=97=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xiaojinzi/support/demo/App.kt | 5 +- .../com/xiaojinzi/support/util/LogSupport.kt | 46 ++++++++++++++----- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/xiaojinzi/support/demo/App.kt b/app/src/main/java/com/xiaojinzi/support/demo/App.kt index 7307344..bfbd9cf 100644 --- a/app/src/main/java/com/xiaojinzi/support/demo/App.kt +++ b/app/src/main/java/com/xiaojinzi/support/demo/App.kt @@ -4,9 +4,10 @@ import android.app.Application import androidx.multidex.MultiDex import com.xiaojinzi.component.Component import com.xiaojinzi.component.Config +import com.xiaojinzi.support.ktx.newUUid import com.xiaojinzi.support.util.LogSupport -class App: Application() { +class App : Application() { override fun onCreate() { super.onCreate() @@ -23,7 +24,7 @@ class App: Application() { .build() ) - LogSupport.e("天呐") + LogSupport.e(content = "天呐", keywords = arrayOf("我的", "你的")) } diff --git a/lib-ktx/src/main/java/com/xiaojinzi/support/util/LogSupport.kt b/lib-ktx/src/main/java/com/xiaojinzi/support/util/LogSupport.kt index 13be41f..3f45232 100644 --- a/lib-ktx/src/main/java/com/xiaojinzi/support/util/LogSupport.kt +++ b/lib-ktx/src/main/java/com/xiaojinzi/support/util/LogSupport.kt @@ -1,7 +1,6 @@ package com.xiaojinzi.support.util import android.util.Log -import java.lang.Exception /** * 日志的帮助类 @@ -19,28 +18,53 @@ object LogSupport { } @JvmOverloads - fun v(content: String, tag: String = defaultTag) { - Log.v(tag, content) + fun v(content: String, tag: String = defaultTag, vararg keywords: String) { + val keywordStr = if (keywords.isNullOrEmpty()) { + "" + } else { + "[${keywords.joinToString()}]" + } + Log.v(tag, "$keywordStr $content") } @JvmOverloads - fun d(content: String, tag: String = defaultTag) { - Log.d(tag, content) + fun d(content: String, tag: String = defaultTag, vararg keywords: String) { + val keywordStr = if (keywords.isNullOrEmpty()) { + "" + } else { + "[${keywords.joinToString()}]" + } + Log.d(tag, "$keywordStr $content") } @JvmOverloads - fun i(content: String, tag: String = defaultTag) { - Log.i(tag, content) + fun i(content: String, tag: String = defaultTag, vararg keywords: String) { + val keywordStr = if (keywords.isNullOrEmpty()) { + "" + } else { + "[${keywords.joinToString()}]" + } + Log.i(tag, "$keywordStr $content") } @JvmOverloads - fun e(content: String, tag: String = defaultTag) { - Log.e(tag, content) + fun e(content: String, tag: String = defaultTag, vararg keywords: String) { + val keywordStr = if (keywords.isNullOrEmpty()) { + "" + } else { + "[${keywords.joinToString()}]" + } + Log.e(tag, "$keywordStr $content") } @JvmOverloads - fun w(content: String, tag: String = defaultTag) { - Log.w(tag, content) + fun w(content: String, tag: String = defaultTag, vararg keywords: String) { + val keywordStr = if (keywords.isNullOrEmpty()) { + "" + } else { + "[${keywords.joinToString()}]" + } + Log.w(tag, "$keywordStr $content") } } \ No newline at end of file