From 77289b780e931f6672b67046789c5e1d8e930f38 Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Wed, 18 Sep 2019 17:25:30 +0200 Subject: [PATCH] fix: give user more explicit control over color Why: * Windows is a pain when it comes to guessing color capabilities. Its many terminals has too many variances for our guesses to be always right. This change addreses the need by: * Make quarkus.log.console.color optional allowing users to force on/off and when left unset quarkus will take a best guess. --- .../java/io/quarkus/runtime/logging/ConsoleConfig.java | 8 +++++--- .../io/quarkus/runtime/logging/LoggingSetupRecorder.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java index b9abbfaf288e12..dd19a6c0db000a 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java @@ -1,5 +1,6 @@ package io.quarkus.runtime.logging; +import java.util.Optional; import java.util.logging.Level; import io.quarkus.runtime.annotations.ConfigGroup; @@ -29,10 +30,11 @@ public class ConsoleConfig { Level level; /** - * If the console logging should be in color + * If the console logging should be in color. If undefined quarkus takes + * best guess based on operating system and environment. */ - @ConfigItem(defaultValue = "true") - boolean color; + @ConfigItem() + Optional color; /** * Specify how much the colors should be darkened diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java index 4d6fee44f73035..e613c0aba54479 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java @@ -122,7 +122,7 @@ private boolean hasColorSupport() { private ErrorManager configureConsoleHandler(ConsoleConfig config, ErrorManager errorManager, List filterElements, ArrayList handlers) { final PatternFormatter formatter; - if (config.color && hasColorSupport()) { + if (config.color.orElse(hasColorSupport())) { formatter = new ColorPatternFormatter(config.darken, config.format); } else { formatter = new PatternFormatter(config.format);