You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/03/22 12:55:59 UTC

[35/41] logging-log4j2 git commit: Sort methods.

Sort methods.

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

Branch: refs/heads/gelf-layout-gc-free
Commit: 72e2e1180b6df2bd1eccbe2935bfb8f747bf6786
Parents: 856607f
Author: ggregory <gg...@apache.org>
Authored: Fri Mar 18 16:22:54 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Mar 18 16:22:54 2016 -0700

----------------------------------------------------------------------
 .../rolling/DefaultRolloverStrategy.java        | 164 +++++++++----------
 1 file changed, 82 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/72e2e118/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
index 119ede0..c9de196 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
@@ -131,6 +131,15 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
             }
         };
 
+        static FileExtensions lookup(String fileExtension) {
+            for (FileExtensions ext : values()) {
+                if (ext.isExtensionFor(fileExtension)) {
+                    return ext;
+                }
+            }
+            return null;
+        }
+
         private final String extension;
 
         private FileExtensions(final String extension) {
@@ -138,6 +147,9 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
             this.extension = extension;
         }
 
+        abstract Action createCompressAction(String renameTo, String compressedName, boolean deleteSource,
+                int compressionLevel);
+
         String getExtension() {
             return extension;
         }
@@ -157,18 +169,6 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
         File target(String fileName) {
             return new File(fileName);
         }
-
-        abstract Action createCompressAction(String renameTo, String compressedName, boolean deleteSource,
-                int compressionLevel);
-
-        static FileExtensions lookup(String fileExtension) {
-            for (FileExtensions ext : values()) {
-                if (ext.isExtensionFor(fileExtension)) {
-                    return ext;
-                }
-            }
-            return null;
-        }
     };
 
     /**
@@ -180,41 +180,6 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
     private static final int DEFAULT_WINDOW_SIZE = 7;
 
     /**
-     * Index for oldest retained log file.
-     */
-    private final int maxIndex;
-
-    /**
-     * Index for most recent log file.
-     */
-    private final int minIndex;
-    private final boolean useMax;
-    private final StrSubstitutor subst;
-    private final int compressionLevel;
-    private final List<Action> customActions;
-    private final boolean stopCustomActionsOnError;
-
-    /**
-     * Constructs a new instance.
-     * 
-     * @param minIndex The minimum index.
-     * @param maxIndex The maximum index.
-     * @param customActions custom actions to perform asynchronously after rollover
-     * @param stopCustomActionsOnError whether to stop executing asynchronous actions if an error occurs
-     */
-    protected DefaultRolloverStrategy(final int minIndex, final int maxIndex, final boolean useMax,
-            final int compressionLevel, final StrSubstitutor subst, final Action[] customActions,
-            final boolean stopCustomActionsOnError) {
-        this.minIndex = minIndex;
-        this.maxIndex = maxIndex;
-        this.useMax = useMax;
-        this.compressionLevel = compressionLevel;
-        this.subst = subst;
-        this.stopCustomActionsOnError = stopCustomActionsOnError;
-        this.customActions = customActions == null ? Collections.<Action> emptyList() : Arrays.asList(customActions);
-    }
-
-    /**
      * Create the DefaultRolloverStrategy.
      * 
      * @param max The maximum number of files to keep.
@@ -261,10 +226,49 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
                 customActions, stopCustomActionsOnError);
     }
 
+    /**
+     * Index for oldest retained log file.
+     */
+    private final int maxIndex;
+    /**
+     * Index for most recent log file.
+     */
+    private final int minIndex;
+    private final boolean useMax;
+    private final StrSubstitutor subst;
+    private final int compressionLevel;
+    private final List<Action> customActions;
+
+    private final boolean stopCustomActionsOnError;
+
+    /**
+     * Constructs a new instance.
+     * 
+     * @param minIndex The minimum index.
+     * @param maxIndex The maximum index.
+     * @param customActions custom actions to perform asynchronously after rollover
+     * @param stopCustomActionsOnError whether to stop executing asynchronous actions if an error occurs
+     */
+    protected DefaultRolloverStrategy(final int minIndex, final int maxIndex, final boolean useMax,
+            final int compressionLevel, final StrSubstitutor subst, final Action[] customActions,
+            final boolean stopCustomActionsOnError) {
+        this.minIndex = minIndex;
+        this.maxIndex = maxIndex;
+        this.useMax = useMax;
+        this.compressionLevel = compressionLevel;
+        this.subst = subst;
+        this.stopCustomActionsOnError = stopCustomActionsOnError;
+        this.customActions = customActions == null ? Collections.<Action> emptyList() : Arrays.asList(customActions);
+    }
+
     public int getCompressionLevel() {
         return this.compressionLevel;
     }
 
+    public List<Action> getCustomActions() {
+        return customActions;
+    }
+
     public int getMaxIndex() {
         return this.maxIndex;
     }
@@ -273,6 +277,31 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
         return this.minIndex;
     }
 
+    public StrSubstitutor getSubst() {
+        return subst;
+    }
+
+    public boolean isStopCustomActionsOnError() {
+        return stopCustomActionsOnError;
+    }
+
+    public boolean isUseMax() {
+        return useMax;
+    }
+
+    private Action merge(final Action compressAction, final List<Action> custom, final boolean stopOnError) {
+        if (custom.isEmpty()) {
+            return compressAction;
+        }
+        if (compressAction == null) {
+            return new CompositeAction(custom, stopOnError);
+        }
+        final List<Action> all = new ArrayList<>();
+        all.add(compressAction);
+        all.addAll(custom);
+        return new CompositeAction(all, stopOnError);
+    }
+
     private int purge(final int lowIndex, final int highIndex, final RollingFileManager manager) {
         return useMax ? purgeAscending(lowIndex, highIndex, manager) : purgeDescending(lowIndex, highIndex, manager);
     }
@@ -479,15 +508,6 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
         return lowIndex;
     }
 
-    private int suffixLength(final String lowFilename) {
-        for (FileExtensions extension : FileExtensions.values()) {
-            if (extension.isExtensionFor(lowFilename)) {
-                return extension.length();
-            }
-        }
-        return 0;
-    }
-
     /**
      * Perform the rollover.
      * 
@@ -531,17 +551,13 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
         return new RolloverDescriptionImpl(currentFileName, false, renameAction, asyncAction);
     }
 
-    private Action merge(final Action compressAction, final List<Action> custom, final boolean stopOnError) {
-        if (custom.isEmpty()) {
-            return compressAction;
-        }
-        if (compressAction == null) {
-            return new CompositeAction(custom, stopOnError);
+    private int suffixLength(final String lowFilename) {
+        for (FileExtensions extension : FileExtensions.values()) {
+            if (extension.isExtensionFor(lowFilename)) {
+                return extension.length();
+            }
         }
-        final List<Action> all = new ArrayList<>();
-        all.add(compressAction);
-        all.addAll(custom);
-        return new CompositeAction(all, stopOnError);
+        return 0;
     }
 
     @Override
@@ -549,20 +565,4 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
         return "DefaultRolloverStrategy(min=" + minIndex + ", max=" + maxIndex + ')';
     }
 
-    public boolean isUseMax() {
-        return useMax;
-    }
-
-    public StrSubstitutor getSubst() {
-        return subst;
-    }
-
-    public List<Action> getCustomActions() {
-        return customActions;
-    }
-
-    public boolean isStopCustomActionsOnError() {
-        return stopCustomActionsOnError;
-    }
-
 }