vy commented on code in PR #1503:
URL: https://github.com/apache/logging-log4j2/pull/1503#discussion_r1218569480


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/filter/LevelRangeFilter.java:
##########
@@ -29,47 +29,62 @@
 import org.apache.logging.log4j.util.PerformanceSensitive;
 
 /**
- * This filter returns the {@code onMatch} result if the level in the {@code 
LogEvent} is in the range of the configured
- * min and max levels, otherwise it returns {@code onMismatch} value . For 
example, if the filter is configured with
- * {@link Level#ERROR} and {@link Level#INFO} and the LogEvent contains {@link 
Level#WARN} then the onMatch value will
- * be returned since {@link Level#WARN WARN} events are in between {@link 
Level#ERROR ERROR} and {@link Level#INFO
- * INFO}.
+ * This filter returns the {@link #onMatch} result if the level of the {@link 
LogEvent} is in the range of the configured {@link #minLevel} and {@link 
#maxLevel} values, otherwise it returns the {@link #onMismatch} result.
+ * The default values for {@link #minLevel} and {@link #maxLevel} are set to 
{@link Level#OFF} and {@link Level#ALL}, respectively.
+ * The default values for {@link #onMatch} and {@link #onMismatch} are set to 
{@link Result#NEUTRAL} and {@link Result#DENY}, respectively.
  * <p>
- * The default Levels are both {@link Level#ERROR ERROR}.
+ * The levels get compared by their associated integral values; {@link 
Level#OFF} has an integral value of 0, {@link Level#FATAL} 100, {@link 
Level#ERROR} 200, and so on.
+ * For example, if the filter is configured with {@link #maxLevel} set to 
{@link Level#INFO}, the filter will return {@link #onMismatch} result for 
{@link LogEvent}s of level with higher integral values; {@link Level#DEBUG}, 
{@link Level#TRACE}, etc.
  * </p>
  */
 @Plugin(name = "LevelRangeFilter", category = Node.CATEGORY, elementType = 
Filter.ELEMENT_TYPE, printObject = true)
 @PerformanceSensitive("allocation")
 public final class LevelRangeFilter extends AbstractFilter {
 
     /**
-     * Creates a ThresholdFilter.
+     * The default minimum level threshold.
+     */
+    public static final Level DEFAULT_MIN_LEVEL = Level.OFF;
+
+    /**
+     * THe default maximum level threshold.
+     */
+    public static final Level DEFAULT_MAX_LEVEL = Level.ALL;
+
+    /**
+     * The default result on a match.
+     */
+    public static final Result DEFAULT_ON_MATCH = Result.NEUTRAL;
+
+    /**
+     * The default result on a mismatch.
+     */
+    public static final Result DEFAULT_ON_MISMATCH = Result.DENY;
+
+    /**
+     * Creates an instance with the provided properties.
      *
-     * @param minLevel
-     *            The minimum log Level.
-     * @param maxLevel
-     *            The maximum log Level.
-     * @param match
-     *            The action to take on a match.
-     * @param mismatch
-     *            The action to take on a mismatch.
-     * @return The created ThresholdFilter.
+     * @param minLevel the minimum level threshold
+     * @param maxLevel the maximum level threshold
+     * @param onMatch the result to return on a match
+     * @param onMismatch the result to return on a mismatch
+     * @return a new instance
      */
-    // TODO Consider refactoring to use AbstractFilter.AbstractFilterBuilder
     @PluginFactory
     public static LevelRangeFilter createFilter(
             // @formatter:off
             @PluginAttribute("minLevel") final Level minLevel,
             @PluginAttribute("maxLevel") final Level maxLevel,
-            @PluginAttribute("onMatch") final Result match,
-            @PluginAttribute("onMismatch") final Result mismatch) {
+            @PluginAttribute("onMatch") final Result onMatch,
+            @PluginAttribute("onMismatch") final Result onMismatch) {

Review Comment:
   I have indeed seen that TODO and checked it. Though the required LoC 
doubles. Hence, sticked to this version.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to