You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2020/11/26 14:07:04 UTC

[logging-log4j2] 01/05: Simplify if/else.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 6a4692d84194ba99c8d920d664b8f01eae54b878
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 22 14:26:00 2020 -0500

    Simplify if/else.
---
 .../java/org/apache/logging/log4j/status/StatusLogger.java   | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java b/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
index 3de75f6..319f97c 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
@@ -269,17 +269,13 @@ public final class StatusLogger extends AbstractLogger {
             msgLock.unlock();
         }
         // LOG4J2-1813 if system property "log4j2.debug" is defined, all status logging is enabled
-        if (isDebugPropertyEnabled()) {
+        if (isDebugPropertyEnabled() || (listeners.size() <= 0)) {
             logger.logMessage(fqcn, level, marker, msg, t);
         } else {
-            if (listeners.size() > 0) {
-                for (final StatusListener listener : listeners) {
-                    if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
-                        listener.log(data);
-                    }
+            for (final StatusListener listener : listeners) {
+                if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
+                    listener.log(data);
                 }
-            } else {
-                logger.logMessage(fqcn, level, marker, msg, t);
             }
         }
     }