Skip to content

Commit

Permalink
feat: Log warnings when compiling resources
Browse files Browse the repository at this point in the history
The logger in class `brut.util.OS` is responsible for logging the standard error output stream from invoking AAPT. Previously,only loggers with the name starting with `app.revanced` were shown.
  • Loading branch information
oSumAtrIX committed Nov 3, 2023
1 parent 6555fcd commit 1dc8e2e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/kotlin/app/revanced/library/logging/Logger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import java.util.logging.SimpleFormatter

@Suppress("MemberVisibilityCanBePrivate")
object Logger {
/**
* Rules for allowed loggers.
*/
private val allowedLoggersRules = arrayOf<String.() -> Boolean>(
{ startsWith("app.revanced") }, // ReVanced loggers.
{ this == "" } // Logs warnings when compiling resources (Logger in class brut.util.OS).
)

private val rootLogger = java.util.logging.Logger.getLogger("")

/**
Expand Down Expand Up @@ -64,7 +72,9 @@ object Logger {
removeAllHandlers()

val publishHandler = handler@{ log: String, level: Level, loggerName: String? ->
if (loggerName?.startsWith("app.revanced") != true) return@handler
loggerName?.let { name ->
if (allowedLoggersRules.none { it(name) }) return@handler
}

log.toByteArray().let {
if (level.intValue() > Level.WARNING.intValue())
Expand Down

0 comments on commit 1dc8e2e

Please sign in to comment.