Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
feat: separate logger to stdout & stderr (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgE790 authored Jul 3, 2022
1 parent 3a51ce7 commit 0ddc2b5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/kotlin/app/revanced/cli/logging/impl/DefaultCliLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 0ddc2b5

Please sign in to comment.