feat: separate logger to stdout & stderr (#63)

This commit is contained in:
EdgE790 2022-07-03 17:18:13 +03:00 committed by GitHub
parent 3a51ce71a5
commit 0ddc2b54b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,18 +3,26 @@ package app.revanced.cli.logging.impl
import app.revanced.cli.command.MainCommand
import app.revanced.cli.logging.CliLogger
import java.util.logging.Logger
import java.util.logging.SimpleFormatter
import java.util.logging.StreamHandler
internal class DefaultCliLogger(
private val logger: Logger = Logger.getLogger(MainCommand::javaClass.name)
private val logger: Logger = Logger.getLogger(MainCommand::javaClass.name),
private val errorLogger: Logger = Logger.getLogger(MainCommand::javaClass.name + "Err")
) : CliLogger {
init {
logger.useParentHandlers = false
logger.addHandler(StreamHandler(System.out, SimpleFormatter()))
}
companion object {
init {
System.setProperty("java.util.logging.SimpleFormatter.format", "%4\$s: %5\$s %n")
}
}
override fun error(msg: String) = logger.severe(msg)
override fun error(msg: String) = errorLogger.severe(msg)
override fun info(msg: String) = logger.info(msg)
override fun trace(msg: String) = logger.finest(msg)
override fun warn(msg: String) = logger.warning(msg)
}
override fun warn(msg: String) = errorLogger.warning(msg)
}