ColorConverter Class — spring-boot Architecture
Architecture documentation for the ColorConverter class in ColorConverter.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java lines 42–88
public class ColorConverter extends CompositeConverter<ILoggingEvent> {
private static final Map<String, AnsiElement> ELEMENTS;
static {
Map<String, AnsiElement> ansiElements = new HashMap<>();
Arrays.stream(AnsiColor.values())
.filter((color) -> color != AnsiColor.DEFAULT)
.forEach((color) -> ansiElements.put(color.name().toLowerCase(Locale.ROOT), color));
ansiElements.put("faint", AnsiStyle.FAINT);
ELEMENTS = Collections.unmodifiableMap(ansiElements);
}
private static final Map<Integer, AnsiElement> LEVELS;
static {
Map<Integer, AnsiElement> ansiLevels = new HashMap<>();
ansiLevels.put(Level.ERROR_INTEGER, AnsiColor.RED);
ansiLevels.put(Level.WARN_INTEGER, AnsiColor.YELLOW);
LEVELS = Collections.unmodifiableMap(ansiLevels);
}
@Override
protected String transform(ILoggingEvent event, String in) {
AnsiElement color = ELEMENTS.get(getFirstOption());
if (color == null) {
// Assume highlighting
color = LEVELS.get(event.getLevel().toInteger());
color = (color != null) ? color : AnsiColor.GREEN;
}
return toAnsiString(in, color);
}
protected String toAnsiString(String in, AnsiElement element) {
return AnsiOutput.toString(element, in);
}
static String getName(AnsiElement element) {
return ELEMENTS.entrySet()
.stream()
.filter((entry) -> entry.getValue().equals(element))
.map(Map.Entry::getKey)
.findFirst()
.orElseThrow();
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free