Author: fanningpj
Date: Sun Nov 24 19:19:52 2024
New Revision: 1922053

URL: http://svn.apache.org/viewvc?rev=1922053&view=rev
Log:
XmlBeansLogManager

Modified:
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/logging/XmlBeansLogManager.java

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/logging/XmlBeansLogManager.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/logging/XmlBeansLogManager.java?rev=1922053&r1=1922052&r2=1922053&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/logging/XmlBeansLogManager.java
 (original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/logging/XmlBeansLogManager.java
 Sun Nov 24 19:19:52 2024
@@ -36,12 +36,10 @@ public final class XmlBeansLogManager {
     }
 
     public static Logger getLogger(Class<?> clz) {
-        final long time = System.currentTimeMillis();
         try {
             final Logger logger = LogManager.getLogger(clz);
             if (logger == null) {
-                if (time > LAST_TIME + SLEEP_TIME) {
-                    LAST_TIME = time;
+                if (shouldLog()) {
                     System.err.println("[XmlBeansLogManager] Log4J returned 
null logger. Falling back to No-Op logger.");
                 }
                 return NoOpLogger.INSTANCE;
@@ -49,8 +47,7 @@ public final class XmlBeansLogManager {
             return logger;
         } catch (Throwable t) {
             if (!ExceptionUtil.isFatal(t)) {
-                if (time > LAST_TIME + SLEEP_TIME) {
-                    LAST_TIME = time;
+                if (shouldLog()) {
                     System.err.println("[XmlBeansLogManager] Issue loading 
Log4J. Falling back to No-Op logger.");
                     t.printStackTrace();
                 }
@@ -59,4 +56,13 @@ public final class XmlBeansLogManager {
         }
     }
 
+    private static synchronized boolean shouldLog() {
+        final long time = System.currentTimeMillis();
+        if (time > LAST_TIME + SLEEP_TIME) {
+            LAST_TIME = time;
+            return true;
+        }
+        return false;
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to