mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-11-19 01:59:25 +01:00
feat: separate logger to stdout & stderr (#63)
This commit is contained in:
parent
3a51ce71a5
commit
0ddc2b54b7
@ -3,18 +3,26 @@ package app.revanced.cli.logging.impl
|
|||||||
import app.revanced.cli.command.MainCommand
|
import app.revanced.cli.command.MainCommand
|
||||||
import app.revanced.cli.logging.CliLogger
|
import app.revanced.cli.logging.CliLogger
|
||||||
import java.util.logging.Logger
|
import java.util.logging.Logger
|
||||||
|
import java.util.logging.SimpleFormatter
|
||||||
|
import java.util.logging.StreamHandler
|
||||||
|
|
||||||
internal class DefaultCliLogger(
|
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 {
|
) : CliLogger {
|
||||||
|
|
||||||
|
init {
|
||||||
|
logger.useParentHandlers = false
|
||||||
|
logger.addHandler(StreamHandler(System.out, SimpleFormatter()))
|
||||||
|
}
|
||||||
companion object {
|
companion object {
|
||||||
init {
|
init {
|
||||||
System.setProperty("java.util.logging.SimpleFormatter.format", "%4\$s: %5\$s %n")
|
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 info(msg: String) = logger.info(msg)
|
||||||
override fun trace(msg: String) = logger.finest(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)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user