diff --git a/yukireflection-core/src/main/java/com/highcapable/yukireflection/finder/classes/DexClassFinder.kt b/yukireflection-core/src/main/java/com/highcapable/yukireflection/finder/classes/DexClassFinder.kt index 2211a15..6bdad22 100644 --- a/yukireflection-core/src/main/java/com/highcapable/yukireflection/finder/classes/DexClassFinder.kt +++ b/yukireflection-core/src/main/java/com/highcapable/yukireflection/finder/classes/DexClassFinder.kt @@ -51,7 +51,6 @@ import com.highcapable.yukireflection.finder.type.factory.NameConditions import com.highcapable.yukireflection.utils.debug.YukiLog import com.highcapable.yukireflection.utils.factory.await import com.highcapable.yukireflection.utils.factory.runBlocking -import com.highcapable.yukireflection.utils.factory.toStackTrace import dalvik.system.BaseDexClassLoader import java.lang.reflect.Constructor import java.lang.reflect.Field @@ -93,7 +92,7 @@ class DexClassFinder @PublishedApi internal constructor( ?.let { "${CACHE_FILE_NAME}_${versionName ?: it.versionName}_${versionCode ?: runCatching { it.longVersionCode }.getOrNull() ?: it.versionCode}" } ?: "${CACHE_FILE_NAME}_unknown", Context.MODE_PRIVATE) - }.onFailure { YukiLog.warn(msg = "Failed to read app's SharedPreferences when using DexClassFinder\n${it.toStackTrace()}") }.getOrNull() + }.onFailure { YukiLog.warn(msg = "Failed to read app's SharedPreferences when using DexClassFinder", e = it) }.getOrNull() /** * 清除当前 [DexClassFinder] 的 [Class] 缓存 diff --git a/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/debug/YukiLog.kt b/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/debug/YukiLog.kt index 4596f28..7b4343c 100644 --- a/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/debug/YukiLog.kt +++ b/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/debug/YukiLog.kt @@ -30,7 +30,7 @@ package com.highcapable.yukireflection.utils.debug import android.util.Log import com.highcapable.yukireflection.YukiReflection import com.highcapable.yukireflection.factory.hasClass -import com.highcapable.yukireflection.utils.factory.toStackTrace +import com.highcapable.yukireflection.utils.factory.dumpToString /** * 全局 Log 管理类 @@ -112,6 +112,6 @@ internal object YukiLog { */ fun innerLog(msg: String) = if (color.isBlank()) println(msg) else println("\u001B[${color}m$msg\u001B[0m") innerLog(msg) - e?.also { innerLog(it.toStackTrace()) } + e?.also { innerLog(it.dumpToString()) } } } \ No newline at end of file diff --git a/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/factory/ThrowableFactory.kt b/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/factory/ThrowableFactory.kt index 07fcfa5..211d4bb 100644 --- a/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/factory/ThrowableFactory.kt +++ b/yukireflection-core/src/main/java/com/highcapable/yukireflection/utils/factory/ThrowableFactory.kt @@ -33,7 +33,7 @@ import java.io.ByteArrayOutputStream import java.io.PrintStream /** - * 获取完整的异常堆栈内容 + * 写出异常堆栈到字符串 * @return [String] */ -internal fun Throwable.toStackTrace() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString() \ No newline at end of file +internal fun Throwable.dumpToString() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString() \ No newline at end of file