From 35b85b2c2957673a64bcc0526a6a1b5a7fb51005 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 27 Oct 2024 15:59:52 +0100 Subject: [PATCH] Build log strings in suppliers --- docs/1_patcher_intro.md | 4 ++-- .../app/revanced/patcher/patch/BytecodePatchContext.kt | 6 +++--- .../kotlin/app/revanced/patcher/util/ClassMerger.kt | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/1_patcher_intro.md b/docs/1_patcher_intro.md index 8664236c..e3f6872b 100644 --- a/docs/1_patcher_intro.md +++ b/docs/1_patcher_intro.md @@ -89,9 +89,9 @@ val patcherResult = Patcher(PatcherConfig(apkFile = File("some.apk"))).use { pat runBlocking { patcher().collect { patchResult -> if (patchResult.exception != null) - logger.info("\"${patchResult.patch}\" failed:\n${patchResult.exception}") + logger.info { "\"${patchResult.patch}\" failed:\n${patchResult.exception}" } else - logger.info("\"${patchResult.patch}\" succeeded") + logger.info { "\"${patchResult.patch}\" succeeded" } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/BytecodePatchContext.kt b/src/main/kotlin/app/revanced/patcher/patch/BytecodePatchContext.kt index 4482aa2f..a758cf77 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/BytecodePatchContext.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/BytecodePatchContext.kt @@ -97,7 +97,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi bytecodePatch.extensionInputStream?.get()?.use { extensionStream -> RawDexIO.readRawDexFile(extensionStream, 0, null).classes.forEach { classDef -> val existingClass = lookupMaps.classesByType[classDef.type] ?: run { - logger.fine("Adding class \"$classDef\"") + logger.fine { "Adding class \"$classDef\"" } classes += classDef lookupMaps.classesByType[classDef.type] = classDef @@ -105,7 +105,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi return@forEach } - logger.fine("Class \"$classDef\" exists already. Adding missing methods and fields.") + logger.fine { "Class \"$classDef\" exists already. Adding missing methods and fields." } existingClass.merge(classDef, this@BytecodePatchContext).let { mergedClass -> // If the class was merged, replace the original class with the merged class. @@ -178,7 +178,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi override fun getOpcodes() = this@BytecodePatchContext.opcodes }, DexIO.DEFAULT_MAX_DEX_POOL_SIZE, - ) { _, entryName, _ -> logger.info("Compiled $entryName") } + ) { _, entryName, _ -> logger.info { "Compiled $entryName" } } }.listFiles(FileFilter { it.isFile })!!.map { PatcherResult.PatchedDexFile(it.name, it.inputStream()) }.toSet() diff --git a/src/main/kotlin/app/revanced/patcher/util/ClassMerger.kt b/src/main/kotlin/app/revanced/patcher/util/ClassMerger.kt index 9850a4e1..d9a3a218 100644 --- a/src/main/kotlin/app/revanced/patcher/util/ClassMerger.kt +++ b/src/main/kotlin/app/revanced/patcher/util/ClassMerger.kt @@ -60,7 +60,7 @@ internal object ClassMerger { if (missingMethods.isEmpty()) return this - logger.fine("Found ${missingMethods.size} missing methods") + logger.fine { "Found ${missingMethods.size} missing methods" } return asMutableClass().apply { methods.addAll(missingMethods.map { it.toMutable() }) @@ -80,7 +80,7 @@ internal object ClassMerger { if (missingFields.isEmpty()) return this - logger.fine("Found ${missingFields.size} missing fields") + logger.fine { "Found ${missingFields.size} missing fields" } return asMutableClass().apply { fields.addAll(missingFields.map { it.toMutable() }) @@ -100,7 +100,7 @@ internal object ClassMerger { context.traverseClassHierarchy(this) { if (accessFlags.isPublic()) return@traverseClassHierarchy - logger.fine("Publicizing ${this.type}") + logger.fine { "Publicizing ${this.type}" } accessFlags = accessFlags.toPublic() } @@ -124,7 +124,7 @@ internal object ClassMerger { if (brokenFields.isEmpty()) return this - logger.fine("Found ${brokenFields.size} broken fields") + logger.fine { "Found ${brokenFields.size} broken fields" } /** * Make a field public. @@ -153,7 +153,7 @@ internal object ClassMerger { if (brokenMethods.isEmpty()) return this - logger.fine("Found ${brokenMethods.size} methods") + logger.fine { "Found ${brokenMethods.size} methods" } /** * Make a method public.