From 0ddc2b54b739dae3e8ccc983bab73fc84e72be0a Mon Sep 17 00:00:00 2001 From: EdgE790 Date: Sun, 3 Jul 2022 17:18:13 +0300 Subject: [PATCH] feat: separate logger to stdout & stderr (#63) --- .../cli/logging/impl/DefaultCliLogger.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/app/revanced/cli/logging/impl/DefaultCliLogger.kt b/src/main/kotlin/app/revanced/cli/logging/impl/DefaultCliLogger.kt index 395922b..a433c4e 100644 --- a/src/main/kotlin/app/revanced/cli/logging/impl/DefaultCliLogger.kt +++ b/src/main/kotlin/app/revanced/cli/logging/impl/DefaultCliLogger.kt @@ -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) -} \ No newline at end of file + override fun warn(msg: String) = errorLogger.warning(msg) +}