From 6c4c1924ee9ae75af3449749a6a82b7ae5572129 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 22 Jun 2022 14:17:13 +0200 Subject: [PATCH] feat: migrate logger to `slf4j` --- build.gradle.kts | 1 + src/main/kotlin/app/revanced/cli/command/MainCommand.kt | 7 +++---- src/main/kotlin/app/revanced/utils/patcher/Patcher.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1795aee1..014fb83c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { implementation(kotlin("reflect")) implementation("app.revanced:revanced-patcher:1.6.0") + implementation("org.slf4j:slf4j-api:1.7.36") implementation("info.picocli:picocli:4.6.3") implementation("com.android.tools.build:apksig:7.2.1") implementation("com.github.revanced:jadb:master-SNAPSHOT") // updated fork diff --git a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt index 9700b09c..5853abe1 100644 --- a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt +++ b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt @@ -8,10 +8,11 @@ import app.revanced.patcher.extensions.PatchExtensions.description import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.util.patch.implementation.JarPatchBundle import app.revanced.utils.adb.Adb +import org.slf4j.Logger +import org.slf4j.LoggerFactory import picocli.CommandLine.* import java.io.File import java.nio.file.Files -import java.util.logging.Logger import kotlin.io.path.Path import kotlin.io.path.name @@ -19,7 +20,7 @@ import kotlin.io.path.name name = "ReVanced-CLI", version = ["1.0.0"], mixinStandardHelpOptions = true ) internal object MainCommand : Runnable { - val logger: Logger = Logger.getLogger(MainCommand.javaClass.name) + val logger: Logger = LoggerFactory.getLogger(MainCommand::class.java) @ArgGroup(exclusive = false, multiplicity = "1") lateinit var args: Args @@ -85,8 +86,6 @@ internal object MainCommand : Runnable { } override fun run() { - System.setProperty("java.util.logging.SimpleFormatter.format", "%4\$s: %5\$s %n") - if (args.lArgs?.listOnly == true) { for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) { logger.info("${patch.patchName}: ${patch.description}") diff --git a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt index f286dcad..3944e162 100644 --- a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt @@ -35,7 +35,7 @@ fun Patcher.addPatchesFiltered( return@patch } - if (compatiblePackages == null) logger.warning("$prefix: Missing compatibility annotation. Continuing.") + if (compatiblePackages == null) logger.warn("$prefix: Missing compatibility annotation. Continuing.") else { if (!compatiblePackages.any { it.name == packageName }) { logger.info("$prefix: Incompatible package") @@ -63,7 +63,7 @@ fun Patcher.applyPatchesVerbose() { return@forEach } - logger.severe("Error: $patch") + logger.error("Error: $patch") result.exceptionOrNull()!!.printStackTrace() }