logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1434589 - in /logging/log4j/log4j2/trunk: api/src/main/java/org/apache/logging/log4j/status/ api/src/main/java/org/apache/logging/log4j/util/ core/src/main/java/org/apache/logging/log4j/core/helpers/
Date Thu, 17 Jan 2013 08:45:38 GMT
Author: rgoers
Date: Thu Jan 17 08:45:37 2013
New Revision: 1434589

URL: http://svn.apache.org/viewvc?rev=1434589&view=rev
Log:
LOG4J2-150 - Convert Integer.getInteger and Long.getLong to use PropertiesUtil.

Modified:
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java?rev=1434589&r1=1434588&r2=1434589&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java
Thu Jan 17 08:45:37 2013
@@ -45,7 +45,9 @@ public final class StatusLogger extends 
 
     private static final String NOT_AVAIL = "?";
 
-    private static final int MAX_ENTRIES = Integer.getInteger(MAX_STATUS_ENTRIES, 200);
+    private 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 FQCN = AbstractLogger.class.getName();
 
@@ -60,7 +62,6 @@ public final class StatusLogger extends 
     private final ReentrantLock msgLock = new ReentrantLock();
 
     private StatusLogger() {
-        final PropertiesUtil props = new PropertiesUtil("log4j2.StatusLogger.properties");
         this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false, true, false, false,
"", null, props, System.err);
     }
 

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java?rev=1434589&r1=1434588&r2=1434589&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
Thu Jan 17 08:45:37 2013
@@ -71,6 +71,48 @@ public class PropertiesUtil {
         return (prop == null) ? props.getProperty(name) : prop;
     }
 
+
+    public int getIntegerProperty(final String name, final int defaultValue) {
+        String prop = null;
+        try {
+            prop = System.getProperty(name);
+        } catch (final SecurityException e) {
+            // Ignore
+        }
+        if (prop == null) {
+            prop = props.getProperty(name);
+        }
+        if (prop != null) {
+            try {
+                return Integer.parseInt(prop);
+            } catch (Exception ex) {
+                return defaultValue;
+            }
+        }
+        return defaultValue;
+    }
+
+
+    public long getLongProperty(final String name, final long defaultValue) {
+        String prop = null;
+        try {
+            prop = System.getProperty(name);
+        } catch (final SecurityException e) {
+            // Ignore
+        }
+        if (prop == null) {
+            prop = props.getProperty(name);
+        }
+        if (prop != null) {
+            try {
+                return Long.parseLong(prop);
+            } catch (Exception ex) {
+                return defaultValue;
+            }
+        }
+        return defaultValue;
+    }
+
     public String getStringProperty(final String name, final String defaultValue) {
         final String prop = getStringProperty(name);
         return (prop == null) ? defaultValue : prop;

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java?rev=1434589&r1=1434588&r2=1434589&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
Thu Jan 17 08:45:37 2013
@@ -51,7 +51,7 @@ public final class UUIDUtil {
 
     private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
 
-    private static long uuidSequence = Long.getLong(UUID_SEQUENCE, 0);
+    private static long uuidSequence = PropertiesUtil.getProperties().getLongProperty(UUID_SEQUENCE,
0);
 
     private static long least;
 



Mime
View raw message