You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/06/15 21:05:20 UTC

[GitHub] [logging-log4j2] PashaTurok commented on a diff in pull request #933: LOG4J2-3538 Added support for 24 colors in highlighting

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


##########
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:
   @ppkarwasz Please, check. 



-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org