mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
feat: migrate logger to slf4j
This commit is contained in:
parent
a123026f46
commit
8f66f9f606
3 changed files with 17 additions and 15 deletions
|
@ -25,6 +25,7 @@ dependencies {
|
|||
implementation("app.revanced:multidexlib2:2.5.2.r2")
|
||||
implementation("org.smali:smali:2.5.2")
|
||||
implementation("org.apktool:apktool-lib:2.6.5-SNAPSHOT")
|
||||
implementation("org.slf4j:slf4j-api:1.7.36")
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ import org.jf.dexlib2.Opcodes
|
|||
import org.jf.dexlib2.iface.ClassDef
|
||||
import org.jf.dexlib2.iface.DexFile
|
||||
import org.jf.dexlib2.writer.io.MemoryDataStore
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.util.logging.Logger
|
||||
|
||||
val NAMER = BasicDexFileNamer()
|
||||
|
||||
|
@ -43,7 +43,7 @@ val NAMER = BasicDexFileNamer()
|
|||
* @param options The options for the patcher.
|
||||
*/
|
||||
class Patcher(private val options: PatcherOptions) {
|
||||
private val logger: Logger = Logger.getLogger(::Patcher.name)
|
||||
private val logger = LoggerFactory.getLogger(Patcher::class.java)
|
||||
|
||||
val data: PatcherData
|
||||
private val opcodes: Opcodes
|
||||
|
@ -51,7 +51,7 @@ class Patcher(private val options: PatcherOptions) {
|
|||
init {
|
||||
val extInputFile = ExtFile(options.inputFile)
|
||||
val outDir = File(options.resourceCacheDirectory)
|
||||
if (outDir.exists()){
|
||||
if (outDir.exists()) {
|
||||
logger.info("Delete previous resource cache directory")
|
||||
|
||||
outDir.deleteRecursively()
|
||||
|
@ -80,7 +80,7 @@ class Patcher(private val options: PatcherOptions) {
|
|||
}
|
||||
|
||||
} else {
|
||||
logger.warning("Resource patching is disabled. Falling back to manually decode AndroidManifest.xml")
|
||||
logger.warn("Resource patching is disabled. Falling back to manually decode AndroidManifest.xml")
|
||||
|
||||
// create decoder for the resource table
|
||||
val decoder = ResAttrDecoder()
|
||||
|
@ -136,14 +136,14 @@ class Patcher(private val options: PatcherOptions) {
|
|||
}
|
||||
val (_, idx) = e
|
||||
if (allowedOverwrites.contains(type)) {
|
||||
logger.fine("Override $type")
|
||||
logger.trace("Override $type")
|
||||
data.bytecodeData.classes.internalClasses[idx] = classDef
|
||||
continue
|
||||
}
|
||||
logger.fine("Skip $type")
|
||||
logger.trace("Skip $type")
|
||||
continue
|
||||
}
|
||||
logger.finest("Add $type")
|
||||
logger.trace("Add $type")
|
||||
data.bytecodeData.classes.internalClasses.add(classDef)
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +250,8 @@ class Patcher(private val options: PatcherOptions) {
|
|||
val patchName = patch.patchName
|
||||
|
||||
// if the patch has already applied silently skip it
|
||||
if (appliedPatches.contains(patchName)){
|
||||
logger.fine("Skip $patchName because it already has been applied")
|
||||
if (appliedPatches.contains(patchName)) {
|
||||
logger.warn("Skip $patchName because it already has been applied")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ class Patcher(private val options: PatcherOptions) {
|
|||
data.bytecodeData
|
||||
}
|
||||
|
||||
logger.fine("Execute $patchName")
|
||||
logger.warn("Execute $patchName")
|
||||
|
||||
return try {
|
||||
patchInstance.execute(data)
|
||||
|
|
|
@ -12,7 +12,8 @@ import org.jf.dexlib2.iface.Method
|
|||
import org.jf.dexlib2.iface.instruction.Instruction
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||
import org.jf.dexlib2.iface.reference.StringReference
|
||||
import java.util.logging.Logger
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
internal class MethodSignatureResolver(
|
||||
private val classes: List<ClassDef>,
|
||||
|
@ -20,7 +21,7 @@ internal class MethodSignatureResolver(
|
|||
) {
|
||||
// These functions do not require the constructor values, so they can be static.
|
||||
companion object {
|
||||
private val LOGGER: Logger = Logger.getLogger(::MethodSignatureResolver.name)
|
||||
private val logger: Logger = LoggerFactory.getLogger(MethodSignatureResolver::class.java)
|
||||
|
||||
fun resolveFromProxy(
|
||||
classProxy: app.revanced.patcher.util.proxy.ClassProxy,
|
||||
|
@ -29,7 +30,7 @@ internal class MethodSignatureResolver(
|
|||
for (method in classProxy.immutableClass.methods) {
|
||||
val result = compareSignatureToMethod(signature, method) ?: continue
|
||||
|
||||
LOGGER.fine("${signature.name} match to ${method.definingClass}->${method.name}")
|
||||
logger.trace("${signature.name} match to ${method.definingClass}->${method.name}")
|
||||
|
||||
return SignatureResolverResult(
|
||||
classProxy,
|
||||
|
@ -149,12 +150,12 @@ internal class MethodSignatureResolver(
|
|||
fun resolve(patcherData: PatcherData) {
|
||||
for (signature in methodSignatures) {
|
||||
val signatureName = signature.name
|
||||
LOGGER.fine("Resolve $signatureName")
|
||||
logger.trace("Resolve $signatureName")
|
||||
for (classDef in classes) {
|
||||
for (method in classDef.methods) {
|
||||
val patternScanData = compareSignatureToMethod(signature, method) ?: continue
|
||||
|
||||
LOGGER.fine("$signatureName match to ${method.definingClass}->${method.name}")
|
||||
logger.trace("$signatureName match to ${method.definingClass}->${method.name}")
|
||||
|
||||
// create class proxy, in case a patch needs mutability
|
||||
val classProxy = patcherData.bytecodeData.proxy(classDef)
|
||||
|
|
Loading…
Reference in a new issue