ppkarwasz commented on code in PR #933:
URL: https://github.com/apache/logging-log4j2/pull/933#discussion_r897994239


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/AnsiEscape.java:
##########
@@ -320,12 +321,43 @@ public static String createSequence(final String... 
names) {
         boolean first = true;
         for (final String name : names) {
             try {
-                final AnsiEscape escape = 
EnglishEnums.valueOf(AnsiEscape.class, name.trim());
                 if (!first) {
                     sb.append(AnsiEscape.SEPARATOR.getCode());
                 }
                 first = false;
-                sb.append(escape.getCode());
+                String hexColor = null;
+                final String trimmedName = name.trim();
+                if (trimmedName.startsWith("#")) {
+                    sb.append("38");
+                    sb.append(SEPARATOR.getCode());
+                    sb.append("2");
+                    sb.append(SEPARATOR.getCode());
+                    hexColor = trimmedName;
+                } else if (trimmedName.startsWith("FG_#")) {
+                    sb.append("38");
+                    sb.append(SEPARATOR.getCode());
+                    sb.append("2");
+                    sb.append(SEPARATOR.getCode());
+                    hexColor = trimmedName.substring(3);
+                } else if (trimmedName.startsWith("BG_#")) {
+                    sb.append("48");
+                    sb.append(SEPARATOR.getCode());
+                    sb.append("2");
+                    sb.append(SEPARATOR.getCode());
+                    hexColor = trimmedName.substring(3);
+                }
+                if (hexColor != null) {
+                    Color color = Color.decode(hexColor);
+                    sb.append(color.getRed());
+                    sb.append(SEPARATOR.getCode());
+                    sb.append(color.getGreen());
+                    sb.append(SEPARATOR.getCode());
+                    sb.append(color.getBlue());
+                    //no separator at the end

Review Comment:
   In version 3.x `log4j-core` will use classes from the `java.base` module 
only. To ease the migration of this PR to the `master` branch, can you rewrite 
it without `java.awt.Color`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to