style: rename toStackTrack to dumpToString

This commit is contained in:
2023-09-26 02:33:56 +08:00
parent f1500f0733
commit e456636644
3 changed files with 5 additions and 6 deletions

View File

@@ -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] 缓存

View File

@@ -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()) }
}
}

View File

@@ -33,7 +33,7 @@ import java.io.ByteArrayOutputStream
import java.io.PrintStream
/**
* 获取完整的异常堆栈内容
* 写出异常堆栈到字符串
* @return [String]
*/
internal fun Throwable.toStackTrace() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString()
internal fun Throwable.dumpToString() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString()