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/10/14 16:02:52 UTC

[GitHub] [logging-log4j2] ppkarwasz commented on a diff in pull request #1107: LOG4J2-3584 Make StatusConsoleListener use SimpleLogger internally.

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


##########
log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java:
##########
@@ -75,14 +75,23 @@ public final class StatusLogger extends AbstractLogger {
 
     private static final String NOT_AVAIL = "?";
 
-    private static final PropertiesUtil PROPS = new PropertiesUtil("log4j2.StatusLogger.properties");
+    static final PropertiesUtil PROPS = new PropertiesUtil("log4j2.StatusLogger.properties");
 
     private static final int MAX_ENTRIES = PROPS.getIntegerProperty(MAX_STATUS_ENTRIES, 200);
 
     private static final String DEFAULT_STATUS_LEVEL = PROPS.getStringProperty(DEFAULT_STATUS_LISTENER_LEVEL);
 
+    static final String DATE_FORMAT = PROPS.getStringProperty(STATUS_DATE_FORMAT);
+
+    static final boolean DATE_FORMAT_PROVIDED = Strings.isNotBlank(DATE_FORMAT);
+
+    static final boolean DEBUG_ENABLED = PropertiesUtil
+            .getProperties()
+            .getBooleanProperty(Constants.LOG4J2_DEBUG, false, true);

Review Comment:
   Can we put these into a `createSimpleLogger()` factory method? It would certainly ease up testing.



##########
log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java:
##########
@@ -52,6 +59,17 @@ public StatusConsoleListener(final Level level, final PrintStream stream) {
         }
         this.level = level;
         this.stream = stream;
+        this.logger = new SimpleLogger(
+                "StatusConsoleListener",
+                level,
+                false,
+                true,
+                StatusLogger.DATE_FORMAT_PROVIDED,
+                false,
+                StatusLogger.DATE_FORMAT,
+                ParameterizedNoReferenceMessageFactory.INSTANCE,
+                StatusLogger.PROPS,
+                stream);

Review Comment:
   We could refactor this call of the `SimpleLogger` constructor and the one in `StatusLogger` into a common factory method.



-- 
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