Add our own log colored formatter
Change-Id: Ib2634ab2391c92c6335847e33067550cedae1848
diff --git a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
index b5be6ba..638cae0 100644
--- a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
+++ b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
@@ -15,7 +15,9 @@
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
+import java.util.logging.ConsoleHandler
import java.util.logging.Level
+import java.util.logging.LogManager
import java.util.logging.Logger
import java.util.stream.IntStream
import java.util.zip.ZipFile
@@ -24,6 +26,7 @@
import kotlin.math.min
import kotlin.system.exitProcess
+
@Command(
name = "KorapXml2Conllu",
mixinStandardHelpOptions = true,
@@ -115,6 +118,14 @@
var threads: Int = Runtime.getRuntime().availableProcessors() / 2
override fun call(): Int {
+ val handler = ConsoleHandler()
+ LogManager.getLogManager().reset()
+ handler.formatter = ColoredFormatter()
+
+ for (handler in LOGGER.handlers) {
+ LOGGER.removeHandler(handler)
+ }
+ LOGGER.addHandler(handler)
LOGGER.level = try {
Level.parse(logLevel.uppercase(Locale.getDefault()))
} catch (e: IllegalArgumentException) {