diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index e5795fbbf2..90feb0c62b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -60,6 +60,16 @@ public final class ColorConverter extends LogEventPatternConverter { ansiElements.put("blue", AnsiColor.BLUE); ansiElements.put("magenta", AnsiColor.MAGENTA); ansiElements.put("cyan", AnsiColor.CYAN); + ansiElements.put("white", AnsiColor.WHITE); + ansiElements.put("black", AnsiColor.BLACK); + ansiElements.put("bright_black", AnsiColor.BRIGHT_BLACK); + ansiElements.put("bright_red", AnsiColor.BRIGHT_RED); + ansiElements.put("bright_green", AnsiColor.BRIGHT_GREEN); + ansiElements.put("bright_yellow", AnsiColor.BRIGHT_YELLOW); + ansiElements.put("bright_blue", AnsiColor.BRIGHT_BLUE); + ansiElements.put("bright_magenta", AnsiColor.BRIGHT_MAGENTA); + ansiElements.put("bright_cyan", AnsiColor.BRIGHT_CYAN); + ansiElements.put("bright_white", AnsiColor.BRIGHT_WHITE); ELEMENTS = Collections.unmodifiableMap(ansiElements); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java index 8011e0c230..ac650b9979 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java @@ -50,6 +50,16 @@ public class ColorConverter extends CompositeConverter { ansiElements.put("blue", AnsiColor.BLUE); ansiElements.put("magenta", AnsiColor.MAGENTA); ansiElements.put("cyan", AnsiColor.CYAN); + ansiElements.put("white", AnsiColor.WHITE); + ansiElements.put("black", AnsiColor.BLACK); + ansiElements.put("bright_black", AnsiColor.BRIGHT_BLACK); + ansiElements.put("bright_red", AnsiColor.BRIGHT_RED); + ansiElements.put("bright_green", AnsiColor.BRIGHT_GREEN); + ansiElements.put("bright_yellow", AnsiColor.BRIGHT_YELLOW); + ansiElements.put("bright_blue", AnsiColor.BRIGHT_BLUE); + ansiElements.put("bright_magenta", AnsiColor.BRIGHT_MAGENTA); + ansiElements.put("bright_cyan", AnsiColor.BRIGHT_CYAN); + ansiElements.put("bright_white", AnsiColor.BRIGHT_WHITE); ELEMENTS = Collections.unmodifiableMap(ansiElements); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ColorConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ColorConverterTests.java index 84da00eeb0..d1a8cdd787 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ColorConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ColorConverterTests.java @@ -106,6 +106,76 @@ class ColorConverterTests { assertThat(output).hasToString("\033[36min\033[0;39m"); } + @Test + void white() { + StringBuilder output = new StringBuilder(); + newConverter("white").format(this.event, output); + assertThat(output).hasToString("\033[37min\033[0;39m"); + } + + @Test + void black() { + StringBuilder output = new StringBuilder(); + newConverter("black").format(this.event, output); + assertThat(output).hasToString("\033[30min\033[0;39m"); + } + + @Test + void brightBlack() { + StringBuilder output = new StringBuilder(); + newConverter("bright_black").format(this.event, output); + assertThat(output).hasToString("\033[90min\033[0;39m"); + } + + @Test + void brightRed() { + StringBuilder output = new StringBuilder(); + newConverter("bright_red").format(this.event, output); + assertThat(output).hasToString("\033[91min\033[0;39m"); + } + + @Test + void brightGreen() { + StringBuilder output = new StringBuilder(); + newConverter("bright_green").format(this.event, output); + assertThat(output).hasToString("\033[92min\033[0;39m"); + } + + @Test + void brightYellow() { + StringBuilder output = new StringBuilder(); + newConverter("bright_yellow").format(this.event, output); + assertThat(output).hasToString("\033[93min\033[0;39m"); + } + + @Test + void brightBlue() { + StringBuilder output = new StringBuilder(); + newConverter("bright_blue").format(this.event, output); + assertThat(output).hasToString("\033[94min\033[0;39m"); + } + + @Test + void brightMagenta() { + StringBuilder output = new StringBuilder(); + newConverter("bright_magenta").format(this.event, output); + assertThat(output).hasToString("\033[95min\033[0;39m"); + } + + @Test + void brightCyan() { + StringBuilder output = new StringBuilder(); + newConverter("bright_cyan").format(this.event, output); + assertThat(output).hasToString("\033[96min\033[0;39m"); + } + + @Test + void brightWhite() { + StringBuilder output = new StringBuilder(); + newConverter("bright_white").format(this.event, output); + assertThat(output).hasToString("\033[97min\033[0;39m"); + } + @Test void highlightFatal() { this.event.setLevel(Level.FATAL); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ColorConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ColorConverterTests.java index f4e1abb468..94c0391fe7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ColorConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ColorConverterTests.java @@ -100,6 +100,76 @@ class ColorConverterTests { assertThat(out).isEqualTo("\033[36min\033[0;39m"); } + @Test + void white() { + this.converter.setOptionList(Collections.singletonList("white")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[37min\033[0;39m"); + } + + @Test + void black() { + this.converter.setOptionList(Collections.singletonList("black")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[30min\033[0;39m"); + } + + @Test + void brightBlack() { + this.converter.setOptionList(Collections.singletonList("bright_black")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[90min\033[0;39m"); + } + + @Test + void brightRed() { + this.converter.setOptionList(Collections.singletonList("bright_red")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[91min\033[0;39m"); + } + + @Test + void brightGreen() { + this.converter.setOptionList(Collections.singletonList("bright_green")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[92min\033[0;39m"); + } + + @Test + void brightYellow() { + this.converter.setOptionList(Collections.singletonList("bright_yellow")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[93min\033[0;39m"); + } + + @Test + void brightBlue() { + this.converter.setOptionList(Collections.singletonList("bright_blue")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[94min\033[0;39m"); + } + + @Test + void brightMagenta() { + this.converter.setOptionList(Collections.singletonList("bright_magenta")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[95min\033[0;39m"); + } + + @Test + void brightCyan() { + this.converter.setOptionList(Collections.singletonList("bright_cyan")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[96min\033[0;39m"); + } + + @Test + void brightWhite() { + this.converter.setOptionList(Collections.singletonList("bright_white")); + String out = this.converter.transform(this.event, this.in); + assertThat(out).isEqualTo("\033[97min\033[0;39m"); + } + @Test void highlightError() { this.event.setLevel(Level.ERROR);