LOG4J2-435 make conditions print more informative status messages during
file tree walk

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4fe09d24
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4fe09d24
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4fe09d24

Branch: refs/heads/LOG4J-1181
Commit: 4fe09d24ccc7d7a3b6ab1ccb0d6964eba9d5405c
Parents: 6dd574c
Author: rpopma <[email protected]>
Authored: Sun Nov 29 13:49:58 2015 +0900
Committer: rpopma <[email protected]>
Committed: Sun Nov 29 13:49:58 2015 +0900

----------------------------------------------------------------------
 .../appender/rolling/action/IfAccumulatedFileCount.java   |  8 +++++---
 .../appender/rolling/action/IfAccumulatedFileSize.java    |  7 ++++---
 .../log4j/core/appender/rolling/action/IfFileName.java    |  5 +++--
 .../core/appender/rolling/action/IfLastModified.java      | 10 +++++++---
 4 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4fe09d24/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java
index 6cdcc84..ed56321 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java
@@ -51,7 +51,7 @@ public final class IfAccumulatedFileCount implements 
PathCondition {
     public int getThresholdCount() {
         return threshold;
     }
-    
+
     public List<PathCondition> getNestedConditions() {
         return Collections.unmodifiableList(Arrays.asList(nestedConditions));
     }
@@ -66,7 +66,9 @@ public final class IfAccumulatedFileCount implements 
PathCondition {
     public boolean accept(final Path basePath, final Path relativePath, final 
BasicFileAttributes attrs) {
         final boolean result = ++count > threshold;
         final String match = result ? ">" : "<=";
-        LOGGER.trace("IfAccumulatedFileCount: {} count '{}' {} threshold 
'{}'", relativePath, count, match, threshold);
+        final String accept = result ? "ACCEPT" : "REJECT";
+        LOGGER.trace("IfAccumulatedFileCount {}: {} count '{}' {} threshold 
'{}'", accept, relativePath, count, match,
+                threshold);
         if (result) {
             return IfAll.accept(nestedConditions, basePath, relativePath, 
attrs);
         }
@@ -96,7 +98,7 @@ public final class IfAccumulatedFileCount implements 
PathCondition {
             @PluginAttribute(value = "exceeds", defaultInt = 
Integer.MAX_VALUE) final int threshold,
             @PluginElement("PathConditions") final PathCondition... 
nestedConditions) {
             // @formatter:on
-        
+
         if (threshold == Integer.MAX_VALUE) {
             LOGGER.error("IfAccumulatedFileCount invalid or missing threshold 
value.");
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4fe09d24/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java
index e7a6bd0..46714ca 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java
@@ -52,7 +52,7 @@ public final class IfAccumulatedFileSize implements 
PathCondition {
     public long getThresholdBytes() {
         return thresholdBytes;
     }
-    
+
     public List<PathCondition> getNestedConditions() {
         return Collections.unmodifiableList(Arrays.asList(nestedConditions));
     }
@@ -68,7 +68,8 @@ public final class IfAccumulatedFileSize implements 
PathCondition {
         accumulatedSize += attrs.size();
         final boolean result = accumulatedSize > thresholdBytes;
         final String match = result ? ">" : "<=";
-        LOGGER.trace("IfAccumulatedFileSize: {} accumulated size '{}' {} 
thresholdBytes '{}'", relativePath,
+        final String accept = result ? "ACCEPT" : "REJECT";
+        LOGGER.trace("IfAccumulatedFileSize {}: {} accumulated size '{}' {} 
thresholdBytes '{}'", accept, relativePath,
                 accumulatedSize, match, thresholdBytes);
         if (result) {
             return IfAll.accept(nestedConditions, basePath, relativePath, 
attrs);
@@ -99,7 +100,7 @@ public final class IfAccumulatedFileSize implements 
PathCondition {
             @PluginAttribute("exceeds") final String size,
             @PluginElement("PathConditions") final PathCondition... 
nestedConditions) {
             // @formatter:on
-        
+
         if (size == null) {
             LOGGER.error("IfAccumulatedFileSize missing mandatory size 
threshold.");
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4fe09d24/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java
index ca67132..c1260f2 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java
@@ -85,7 +85,7 @@ public final class IfFileName implements PathCondition {
     public String getSyntaxAndPattern() {
         return syntaxAndPattern;
     }
-    
+
     public List<PathCondition> getNestedConditions() {
         return Collections.unmodifiableList(Arrays.asList(nestedConditions));
     }
@@ -101,7 +101,8 @@ public final class IfFileName implements PathCondition {
         final boolean result = pathMatcher.matches(relativePath);
 
         final String match = result ? "matches" : "does not match";
-        LOGGER.trace("IfFileName: '{}' {} relative path '{}'", 
syntaxAndPattern, match, relativePath);
+        final String accept = result ? "ACCEPT" : "REJECT";
+        LOGGER.trace("IfFileName {}: '{}' {} relative path '{}'", accept, 
syntaxAndPattern, match, relativePath);
         if (result) {
             return IfAll.accept(nestedConditions, basePath, relativePath, 
attrs);
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4fe09d24/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
index a67dba9..17a3861 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java
@@ -53,14 +53,16 @@ public final class IfLastModified implements PathCondition {
     public Duration getAge() {
         return age;
     }
-    
+
     public List<PathCondition> getNestedConditions() {
         return Collections.unmodifiableList(Arrays.asList(nestedConditions));
     }
 
     /*
      * (non-Javadoc)
-     * @see 
org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path,
 java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes)
+     * 
+     * @see 
org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path,
+     * java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes)
      */
     @Override
     public boolean accept(final Path basePath, final Path relativePath, final 
BasicFileAttributes attrs) {
@@ -69,7 +71,8 @@ public final class IfLastModified implements PathCondition {
         final long ageMillis = CLOCK.currentTimeMillis() - millis;
         final boolean result = ageMillis >= age.toMillis();
         final String match = result ? ">=" : "<";
-        LOGGER.trace("IfLastModified: {} ageMillis '{}' {} '{}'", 
relativePath, ageMillis, match, age);
+        final String accept = result ? "ACCEPT" : "REJECT";
+        LOGGER.trace("IfLastModified {}: {} ageMillis '{}' {} '{}'", accept, 
relativePath, ageMillis, match, age);
         if (result) {
             return IfAll.accept(nestedConditions, basePath, relativePath, 
attrs);
         }
@@ -78,6 +81,7 @@ public final class IfLastModified implements PathCondition {
 
     /*
      * (non-Javadoc)
+     * 
      * @see 
org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk()
      */
     @Override

Reply via email to