fix: Filter logs correctly

BREAKING CHANGE: This changes the log handler signature
This commit is contained in:
oSumAtrIX 2023-09-19 15:50:44 +02:00
parent e3851d58c8
commit 43fc20d90e
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 10 additions and 4 deletions

View File

@ -69,7 +69,7 @@ public final class app/revanced/lib/adb/AdbManager$UserAdbManager : app/revanced
public final class app/revanced/lib/logging/Logger { public final class app/revanced/lib/logging/Logger {
public static final field INSTANCE Lapp/revanced/lib/logging/Logger; public static final field INSTANCE Lapp/revanced/lib/logging/Logger;
public final fun addHandler (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;)V public final fun addHandler (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;)V
public final fun removeAllHandlers ()V public final fun removeAllHandlers ()V
public final fun setDefault ()V public final fun setDefault ()V
public final fun setFormat (Ljava/lang/String;)V public final fun setFormat (Ljava/lang/String;)V

View File

@ -38,11 +38,15 @@ object Logger {
* @param closeHandler The handler for closing the log. * @param closeHandler The handler for closing the log.
*/ */
fun addHandler( fun addHandler(
publishHandler: (log: String, level: Level) -> Unit, publishHandler: (log: String, level: Level, loggerName: String?) -> Unit,
flushHandler: () -> Unit, flushHandler: () -> Unit,
closeHandler: () -> Unit closeHandler: () -> Unit
) = object : Handler() { ) = object : Handler() {
override fun publish(record: LogRecord) = publishHandler(formatter.format(record), record.level) override fun publish(record: LogRecord) = publishHandler(
formatter.format(record),
record.level,
record.loggerName
)
override fun flush() = flushHandler() override fun flush() = flushHandler()
@ -59,7 +63,9 @@ object Logger {
setFormat() setFormat()
removeAllHandlers() removeAllHandlers()
val publishHandler = { log: String, level: Level -> val publishHandler = handler@{ log: String, level: Level, loggerName: String? ->
if (loggerName?.startsWith("app.revanced") != true) return@handler
log.toByteArray().let { log.toByteArray().let {
if (level.intValue() > Level.INFO.intValue()) if (level.intValue() > Level.INFO.intValue())
System.err.write(it) System.err.write(it)