mirror of
https://github.com/HighCapable/YukiReflection.git
synced 2025-09-06 18:55:32 +08:00
refactor: rename YukiLog to YLog
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
package com.highcapable.yukireflection.finder.base
|
package com.highcapable.yukireflection.finder.base
|
||||||
|
|
||||||
import com.highcapable.yukireflection.YukiReflection
|
import com.highcapable.yukireflection.YukiReflection
|
||||||
import com.highcapable.yukireflection.utils.debug.YukiLog
|
import com.highcapable.yukireflection.utils.debug.YLog
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 这是 [Class] 查找类功能的基本类实现
|
* 这是 [Class] 查找类功能的基本类实现
|
||||||
@@ -62,7 +62,7 @@ abstract class ClassBaseFinder internal constructor(internal open val loaderSet:
|
|||||||
* @param msg 消息内容
|
* @param msg 消息内容
|
||||||
*/
|
*/
|
||||||
internal fun debugMsg(msg: String) {
|
internal fun debugMsg(msg: String) {
|
||||||
if (YukiReflection.Configs.isDebug) YukiLog.debug(msg)
|
if (YukiReflection.Configs.isDebug) YLog.debug(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +73,7 @@ abstract class ClassBaseFinder internal constructor(internal open val loaderSet:
|
|||||||
if (isIgnoreErrorLogs) return
|
if (isIgnoreErrorLogs) return
|
||||||
/** 判断是否为 [LOADERSET_IS_NULL] */
|
/** 判断是否为 [LOADERSET_IS_NULL] */
|
||||||
if (e?.message == LOADERSET_IS_NULL) return
|
if (e?.message == LOADERSET_IS_NULL) return
|
||||||
YukiLog.error(msg = "NoClassDefFound happend in [$loaderSet]", e = e)
|
YLog.error(msg = "NoClassDefFound happend in [$loaderSet]", e = e)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun failure(throwable: Throwable?) = error("DexClassFinder does not contain this usage")
|
override fun failure(throwable: Throwable?) = error("DexClassFinder does not contain this usage")
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
package com.highcapable.yukireflection.finder.base
|
package com.highcapable.yukireflection.finder.base
|
||||||
|
|
||||||
import com.highcapable.yukireflection.YukiReflection
|
import com.highcapable.yukireflection.YukiReflection
|
||||||
import com.highcapable.yukireflection.utils.debug.YukiLog
|
import com.highcapable.yukireflection.utils.debug.YLog
|
||||||
import com.highcapable.yukireflection.utils.factory.await
|
import com.highcapable.yukireflection.utils.factory.await
|
||||||
import java.lang.reflect.Constructor
|
import java.lang.reflect.Constructor
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
@@ -92,7 +92,7 @@ abstract class MemberBaseFinder internal constructor(private val tag: String, in
|
|||||||
* @param msg 消息内容
|
* @param msg 消息内容
|
||||||
*/
|
*/
|
||||||
internal fun debugMsg(msg: String) {
|
internal fun debugMsg(msg: String) {
|
||||||
if (YukiReflection.Configs.isDebug) YukiLog.debug(msg)
|
if (YukiReflection.Configs.isDebug) YLog.debug(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,8 +108,8 @@ abstract class MemberBaseFinder internal constructor(private val tag: String, in
|
|||||||
await {
|
await {
|
||||||
if (isIgnoreErrorLogs) return@await
|
if (isIgnoreErrorLogs) return@await
|
||||||
if (isAlwaysMode.not() && isUsingRemedyPlan) return@await
|
if (isAlwaysMode.not() && isUsingRemedyPlan) return@await
|
||||||
YukiLog.error(msg = "NoSuch$tag happend in [$classSet] $msg".trim(), e = e)
|
YLog.error(msg = "NoSuch$tag happend in [$classSet] $msg".trim(), e = e)
|
||||||
es.forEachIndexed { index, e -> YukiLog.error(msg = "Throwable [${index + 1}]", e = e) }
|
es.forEachIndexed { index, e -> YLog.error(msg = "Throwable [${index + 1}]", e = e) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -47,7 +47,7 @@ import com.highcapable.yukireflection.finder.classes.rules.result.MemberRulesRes
|
|||||||
import com.highcapable.yukireflection.finder.tools.ReflectionTool
|
import com.highcapable.yukireflection.finder.tools.ReflectionTool
|
||||||
import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
||||||
import com.highcapable.yukireflection.finder.type.factory.NameConditions
|
import com.highcapable.yukireflection.finder.type.factory.NameConditions
|
||||||
import com.highcapable.yukireflection.utils.debug.YukiLog
|
import com.highcapable.yukireflection.utils.debug.YLog
|
||||||
import com.highcapable.yukireflection.utils.factory.await
|
import com.highcapable.yukireflection.utils.factory.await
|
||||||
import com.highcapable.yukireflection.utils.factory.runBlocking
|
import com.highcapable.yukireflection.utils.factory.runBlocking
|
||||||
import dalvik.system.BaseDexClassLoader
|
import dalvik.system.BaseDexClassLoader
|
||||||
@@ -91,7 +91,7 @@ class DexClassFinder internal constructor(
|
|||||||
?.let { "${CACHE_FILE_NAME}_${versionName ?: it.versionName}_${versionCode ?: runCatching { it.longVersionCode }.getOrNull() ?: it.versionCode}" }
|
?.let { "${CACHE_FILE_NAME}_${versionName ?: it.versionName}_${versionCode ?: runCatching { it.longVersionCode }.getOrNull() ?: it.versionCode}" }
|
||||||
?: "${CACHE_FILE_NAME}_unknown",
|
?: "${CACHE_FILE_NAME}_unknown",
|
||||||
Context.MODE_PRIVATE)
|
Context.MODE_PRIVATE)
|
||||||
}.onFailure { YukiLog.warn(msg = "Failed to read app's SharedPreferences when using DexClassFinder", e = it) }.getOrNull()
|
}.onFailure { YLog.warn(msg = "Failed to read app's SharedPreferences when using DexClassFinder", e = it) }.getOrNull()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除当前 [DexClassFinder] 的 [Class] 缓存
|
* 清除当前 [DexClassFinder] 的 [Class] 缓存
|
||||||
@@ -102,7 +102,7 @@ class DexClassFinder internal constructor(
|
|||||||
* @param versionCode 版本号 - 默认空
|
* @param versionCode 版本号 - 默认空
|
||||||
*/
|
*/
|
||||||
fun clearCache(context: Context, versionName: String? = null, versionCode: Long? = null) =
|
fun clearCache(context: Context, versionName: String? = null, versionCode: Long? = null) =
|
||||||
context.currentSp(versionName, versionCode)?.edit()?.clear()?.apply() ?: YukiLog.warn(msg = "Failed to clear DexClassFinder's cache")
|
context.currentSp(versionName, versionCode)?.edit()?.clear()?.apply() ?: YLog.warn(msg = "Failed to clear DexClassFinder's cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
override var rulesData = ClassRulesData()
|
override var rulesData = ClassRulesData()
|
||||||
@@ -451,7 +451,7 @@ class DexClassFinder internal constructor(
|
|||||||
takeIf { it.isNotEmpty() }?.forEach { names.add(it.name) }
|
takeIf { it.isNotEmpty() }?.forEach { names.add(it.name) }
|
||||||
context?.also {
|
context?.also {
|
||||||
if (it.packageName == "android") error("Cannot create classes cache for \"android\", please remove \"name\" param")
|
if (it.packageName == "android") error("Cannot create classes cache for \"android\", please remove \"name\" param")
|
||||||
it.currentSp()?.edit()?.apply { putStringSet(name, names) }?.apply() ?: YukiLog.warn(msg = "Failed to use caching in DexClassFinder")
|
it.currentSp()?.edit()?.apply { putStringSet(name, names) }?.apply() ?: YLog.warn(msg = "Failed to use caching in DexClassFinder")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
|||||||
import com.highcapable.yukireflection.finder.type.factory.ObjectsConditions
|
import com.highcapable.yukireflection.finder.type.factory.ObjectsConditions
|
||||||
import com.highcapable.yukireflection.type.defined.UndefinedType
|
import com.highcapable.yukireflection.type.defined.UndefinedType
|
||||||
import com.highcapable.yukireflection.type.defined.VagueType
|
import com.highcapable.yukireflection.type.defined.VagueType
|
||||||
import com.highcapable.yukireflection.utils.debug.YukiLog
|
import com.highcapable.yukireflection.utils.debug.YLog
|
||||||
import com.highcapable.yukireflection.utils.factory.runBlocking
|
import com.highcapable.yukireflection.utils.factory.runBlocking
|
||||||
import java.lang.reflect.Constructor
|
import java.lang.reflect.Constructor
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ class ConstructorFinder internal constructor(override val classSet: Class<*>? =
|
|||||||
if (isFindSuccess) return
|
if (isFindSuccess) return
|
||||||
errorMsg(msg = "RemedyPlan failed after ${remedyPlans.size} attempts", es = errors, isAlwaysMode = true)
|
errorMsg(msg = "RemedyPlan failed after ${remedyPlans.size} attempts", es = errors, isAlwaysMode = true)
|
||||||
remedyPlans.clear()
|
remedyPlans.clear()
|
||||||
} else YukiLog.warn(msg = "RemedyPlan is empty, forgot it?")
|
} else YLog.warn(msg = "RemedyPlan is empty, forgot it?")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -42,7 +42,7 @@ import com.highcapable.yukireflection.finder.type.factory.FieldConditions
|
|||||||
import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
||||||
import com.highcapable.yukireflection.finder.type.factory.NameConditions
|
import com.highcapable.yukireflection.finder.type.factory.NameConditions
|
||||||
import com.highcapable.yukireflection.finder.type.factory.ObjectConditions
|
import com.highcapable.yukireflection.finder.type.factory.ObjectConditions
|
||||||
import com.highcapable.yukireflection.utils.debug.YukiLog
|
import com.highcapable.yukireflection.utils.debug.YLog
|
||||||
import com.highcapable.yukireflection.utils.factory.runBlocking
|
import com.highcapable.yukireflection.utils.factory.runBlocking
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ class FieldFinder internal constructor(override val classSet: Class<*>? = null)
|
|||||||
if (isFindSuccess) return
|
if (isFindSuccess) return
|
||||||
errorMsg(msg = "RemedyPlan failed after ${remedyPlans.size} attempts", es = errors, isAlwaysMode = true)
|
errorMsg(msg = "RemedyPlan failed after ${remedyPlans.size} attempts", es = errors, isAlwaysMode = true)
|
||||||
remedyPlans.clear()
|
remedyPlans.clear()
|
||||||
} else YukiLog.warn(msg = "RemedyPlan is empty, forgot it?")
|
} else YLog.warn(msg = "RemedyPlan is empty, forgot it?")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -44,7 +44,7 @@ import com.highcapable.yukireflection.finder.type.factory.ObjectConditions
|
|||||||
import com.highcapable.yukireflection.finder.type.factory.ObjectsConditions
|
import com.highcapable.yukireflection.finder.type.factory.ObjectsConditions
|
||||||
import com.highcapable.yukireflection.type.defined.UndefinedType
|
import com.highcapable.yukireflection.type.defined.UndefinedType
|
||||||
import com.highcapable.yukireflection.type.defined.VagueType
|
import com.highcapable.yukireflection.type.defined.VagueType
|
||||||
import com.highcapable.yukireflection.utils.debug.YukiLog
|
import com.highcapable.yukireflection.utils.debug.YLog
|
||||||
import com.highcapable.yukireflection.utils.factory.runBlocking
|
import com.highcapable.yukireflection.utils.factory.runBlocking
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ class MethodFinder internal constructor(override val classSet: Class<*>? = null)
|
|||||||
if (isFindSuccess) return
|
if (isFindSuccess) return
|
||||||
errorMsg(msg = "RemedyPlan failed after ${remedyPlans.size} attempts", es = errors, isAlwaysMode = true)
|
errorMsg(msg = "RemedyPlan failed after ${remedyPlans.size} attempts", es = errors, isAlwaysMode = true)
|
||||||
remedyPlans.clear()
|
remedyPlans.clear()
|
||||||
} else YukiLog.warn(msg = "RemedyPlan is empty, forgot it?")
|
} else YLog.warn(msg = "RemedyPlan is empty, forgot it?")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -49,7 +49,7 @@ import com.highcapable.yukireflection.type.java.DalvikBaseDexClassLoader
|
|||||||
import com.highcapable.yukireflection.type.java.NoClassDefFoundErrorClass
|
import com.highcapable.yukireflection.type.java.NoClassDefFoundErrorClass
|
||||||
import com.highcapable.yukireflection.type.java.NoSuchFieldErrorClass
|
import com.highcapable.yukireflection.type.java.NoSuchFieldErrorClass
|
||||||
import com.highcapable.yukireflection.type.java.NoSuchMethodErrorClass
|
import com.highcapable.yukireflection.type.java.NoSuchMethodErrorClass
|
||||||
import com.highcapable.yukireflection.utils.debug.YukiLog
|
import com.highcapable.yukireflection.utils.debug.YLog
|
||||||
import com.highcapable.yukireflection.utils.factory.conditions
|
import com.highcapable.yukireflection.utils.factory.conditions
|
||||||
import com.highcapable.yukireflection.utils.factory.findLastIndex
|
import com.highcapable.yukireflection.utils.factory.findLastIndex
|
||||||
import com.highcapable.yukireflection.utils.factory.lastIndex
|
import com.highcapable.yukireflection.utils.factory.lastIndex
|
||||||
@@ -202,7 +202,7 @@ internal object ReflectionTool {
|
|||||||
fun MemberRulesData.exists(vararg type: Any?): Boolean {
|
fun MemberRulesData.exists(vararg type: Any?): Boolean {
|
||||||
if (type.isEmpty()) return true
|
if (type.isEmpty()) return true
|
||||||
for (i in type.indices) if (type[i] == UndefinedType) {
|
for (i in type.indices) if (type[i] == UndefinedType) {
|
||||||
YukiLog.warn(msg = "$objectName type[$i] mistake, it will be ignored in current conditions")
|
YLog.warn(msg = "$objectName type[$i] mistake, it will be ignored in current conditions")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -666,7 +666,7 @@ internal object ReflectionTool {
|
|||||||
addAll(declaredConstructors.toList())
|
addAll(declaredConstructors.toList())
|
||||||
}.asSequence()
|
}.asSequence()
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
YukiLog.warn(msg = "Failed to get the declared Members in [$this] because got an exception", e = it)
|
YLog.warn(msg = "Failed to get the declared Members in [$this] because got an exception", e = it)
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -675,7 +675,7 @@ internal object ReflectionTool {
|
|||||||
*/
|
*/
|
||||||
private val Class<*>.existFields
|
private val Class<*>.existFields
|
||||||
get() = runCatching { declaredFields.asSequence() }.onFailure {
|
get() = runCatching { declaredFields.asSequence() }.onFailure {
|
||||||
YukiLog.warn(msg = "Failed to get the declared Fields in [$this] because got an exception", e = it)
|
YLog.warn(msg = "Failed to get the declared Fields in [$this] because got an exception", e = it)
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -684,7 +684,7 @@ internal object ReflectionTool {
|
|||||||
*/
|
*/
|
||||||
private val Class<*>.existMethods
|
private val Class<*>.existMethods
|
||||||
get() = runCatching { declaredMethods.asSequence() }.onFailure {
|
get() = runCatching { declaredMethods.asSequence() }.onFailure {
|
||||||
YukiLog.warn(msg = "Failed to get the declared Methods in [$this] because got an exception", e = it)
|
YLog.warn(msg = "Failed to get the declared Methods in [$this] because got an exception", e = it)
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -693,7 +693,7 @@ internal object ReflectionTool {
|
|||||||
*/
|
*/
|
||||||
private val Class<*>.existConstructors
|
private val Class<*>.existConstructors
|
||||||
get() = runCatching { declaredConstructors.asSequence() }.onFailure {
|
get() = runCatching { declaredConstructors.asSequence() }.onFailure {
|
||||||
YukiLog.warn(msg = "Failed to get the declared Constructors in [$this] because got an exception", e = it)
|
YLog.warn(msg = "Failed to get the declared Constructors in [$this] because got an exception", e = it)
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -37,7 +37,7 @@ import com.highcapable.yukireflection.utils.factory.dumpToString
|
|||||||
/**
|
/**
|
||||||
* 全局 Log 管理类
|
* 全局 Log 管理类
|
||||||
*/
|
*/
|
||||||
internal object YukiLog {
|
internal object YLog {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否启用
|
* 是否启用
|
Reference in New Issue
Block a user