Skip to content

Commit

Permalink
Build log strings in suppliers
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Oct 27, 2024
1 parent f62e952 commit 35b85b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/1_patcher_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ 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

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.
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/app/revanced/patcher/util/ClassMerger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() })
Expand All @@ -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() })
Expand All @@ -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()
}
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 35b85b2

Please sign in to comment.