Skip to content

Commit

Permalink
feat: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jun 23, 2022
1 parent 78663cd commit c20dfe1
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/main/kotlin/app/revanced/patcher/Patcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Patcher(private val options: PatcherOptions) {
val packageMetadata = PackageMetadata()

if (options.patchResources) {
logger.info("Decoding resources using Androlib, this may take a long time...")
logger.info("Decoding resources")

// decode resources to cache directory
androlib.decodeManifestWithResources(extInputFile, outDir, resourceTable)
Expand All @@ -78,7 +78,7 @@ class Patcher(private val options: PatcherOptions) {
}

} else {
logger.info("Decoding AndroidManifest.xml manually because resource patching is disabled")
logger.info("Only decoding AndroidManifest.xml because resource patching is disabled")

// create decoder for the resource table
val decoder = ResAttrDecoder()
Expand All @@ -102,7 +102,7 @@ class Patcher(private val options: PatcherOptions) {
packageMetadata.metaInfo.versionInfo = resourceTable.versionInfo
packageMetadata.metaInfo.sdkInfo = resourceTable.sdkInfo

logger.info("Reading input as dex file")
logger.info("Reading dex files")

// read dex files
val dexFile = MultiDexIO.readDexFile(true, options.inputFile, NAMER, null, null)
Expand Down Expand Up @@ -164,7 +164,6 @@ class Patcher(private val options: PatcherOptions) {
var resourceFile: File? = null

if (options.patchResources) {
logger.info("Patching resources")
val cacheDirectory = ExtFile(options.resourceCacheDirectory)

val androlibResources = AndrolibResources().also { resources ->
Expand Down Expand Up @@ -197,7 +196,7 @@ class Patcher(private val options: PatcherOptions) {
)
}.toTypedArray()

logger.trace("Packaging using aapt")
logger.info("Compiling resources")
androlibResources.aaptPackage(
aaptFile, manifestFile, resDirectory, null, null, includedFiles
)
Expand Down Expand Up @@ -251,8 +250,6 @@ class Patcher(private val options: PatcherOptions) {
): PatchResult {
val patchName = patch.patchName

logger.trace("Applying patch $patchName")

// if the patch has already applied silently skip it
if (appliedPatches.contains(patchName)) {
logger.trace("Skipping patch $patchName because it has already been applied")
Expand Down Expand Up @@ -317,7 +314,7 @@ class Patcher(private val options: PatcherOptions) {
Result.failure(patchResult.error()!!)
}

yield(patch.name to result)
yield(patch.patchName to result)
if (stopOnError && patchResult.isError()) break
}
}
Expand Down

0 comments on commit c20dfe1

Please sign in to comment.