cvs commit: jakarta-log4j/src/java/org/apache/log4j/filters NDCMatchFilter.java MDCMatchFilter.java MatchFilterBase.java LevelMatchFilter.java
[email protected] 12 Jun 2002 06:07:35 -0000
| Newsgroups | gmane.comp.jakarta.log4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
mwomack 2002/06/11 23:07:35
Modified: src/java/org/apache/log4j/filters NDCMatchFilter.java
MDCMatchFilter.java MatchFilterBase.java
LevelMatchFilter.java
Log:
Fixed formatting issues.
Fixed problem with property setter for setMatchReturnValue.
Revision Changes Path
1.2 +7 -14 jakarta-log4j/src/java/org/apache/log4j/filters/NDCMatchFilter.java
Index: NDCMatchFilter.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/filters/NDCMatchFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NDCMatchFilter.java 11 Jun 2002 07:04:53 -0000 1.1
+++ NDCMatchFilter.java 12 Jun 2002 06:07:34 -0000 1.2
@@ -39,8 +39,7 @@
@since 1.3
*/
-public
-class NDCMatchFilter extends MatchFilterBase {
+public class NDCMatchFilter extends MatchFilterBase {
/**
The value to match in the NDC value of the LoggingEvent. */
@@ -52,15 +51,13 @@
/**
Sets the value to match in the NDC value of the LoggingEvent. */
- public
- void setValueToMatch(String value) {
+ public void setValueToMatch(String value) {
valueToMatch = value;
}
/**
Gets the value to match in the NDC value of the LoggingEvent. */
- public
- String getValueToMatch() {
+ public String getValueToMatch() {
return valueToMatch;
}
@@ -69,13 +66,11 @@
value of the LoggingEvent. Set to false if the configured
value must only be contained in the NDC value of the
LoggingEvent. Default is false. */
- public
- void setExactMatch(boolean exact) {
+ public void setExactMatch(boolean exact) {
exactMatch = exact;
}
- public
- boolean getExactMatch() {
+ public boolean getExactMatch() {
return exactMatch;
}
@@ -86,15 +81,13 @@
is set to <code>false</code>, returns true when
<b>ValueToMatch</b> is contained anywhere within the NDC
value. Otherwise, false is returned. */
- protected
- boolean match(LoggingEvent event) {
+ protected boolean match(LoggingEvent event) {
// get the ndc value for the event
String eventNDC = event.getNDC();
// check for a match
- boolean matchOccured = false;
-
+
// if the NDC stack is empty
if (eventNDC == null) {
// return true if are we matching a null
1.2 +9 -19 jakarta-log4j/src/java/org/apache/log4j/filters/MDCMatchFilter.java
Index: MDCMatchFilter.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/filters/MDCMatchFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MDCMatchFilter.java 11 Jun 2002 07:04:53 -0000 1.1
+++ MDCMatchFilter.java 12 Jun 2002 06:07:34 -0000 1.2
@@ -45,8 +45,7 @@
@since 1.3
*/
-public
-class MDCMatchFilter extends MatchFilterBase {
+public class MDCMatchFilter extends MatchFilterBase {
/**
The key to match in the MDC of the LoggingEvent. */
@@ -62,29 +61,25 @@
/**
Sets the key to match in the MDC of the LoggingEvent. */
- public
- void setKeyToMatch(String key) {
+ public void setKeyToMatch(String key) {
keyToMatch = key;
}
/**
Gets the key to match in the MDC of the LoggingEvent. */
- public
- String getKeyToMatch() {
+ public String getKeyToMatch() {
return keyToMatch;
}
/**
Sets the value to match in the NDC value of the LoggingEvent. */
- public
- void setValueToMatch(String value) {
+ public void setValueToMatch(String value) {
valueToMatch = value;
}
/**
Gets the value to match in the NDC value of the LoggingEvent. */
- public
- String getValueToMatch() {
+ public String getValueToMatch() {
return valueToMatch;
}
@@ -93,18 +88,15 @@
value of the LoggingEvent. Set to false if the configured
value must only be contained in the MDC value of the
LoggingEvent. Default is false. */
- public
- void setExactMatch(boolean exact) {
+ public void setExactMatch(boolean exact) {
exactMatch = exact;
}
- public
- boolean getExactMatch() {
+ public boolean getExactMatch() {
return exactMatch;
}
- protected
- boolean canMatch() {
+ protected boolean canMatch() {
return (keyToMatch != null);
}
@@ -115,8 +107,7 @@
is set to <code>false</code>, returns true when
<b>ValueToMatch</b> is contained anywhere within the MDC
value. Otherwise, false is returned. */
- protected
- boolean match(LoggingEvent event) {
+ protected boolean match(LoggingEvent event) {
// get the mdc value for the key from the event
// use the toString() value of the value object
@@ -129,7 +120,6 @@
}
// check for a match
- boolean matchOccured = false;
if (mdcValue == null) {
if (valueToMatch == null) {
return true;
1.2 +26 -38 jakarta-log4j/src/java/org/apache/log4j/filters/MatchFilterBase.java
Index: MatchFilterBase.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/filters/MatchFilterBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MatchFilterBase.java 11 Jun 2002 07:04:53 -0000 1.1
+++ MatchFilterBase.java 12 Jun 2002 06:07:34 -0000 1.2
@@ -58,9 +58,7 @@
@since 1.3
*/
-public
-abstract
-class MatchFilterBase extends Filter {
+public abstract class MatchFilterBase extends Filter {
public static final String ACCEPT_ON_MATCH = "AcceptOnMatch";
public static final String DENY_ON_MATCH = "DenyOnMatch";
@@ -78,8 +76,7 @@
/**
Set the value to return upon a successful match. Valid
string values are "ACCEPT", "DENY", and "NEUTRAL". */
- public
- void setMatchReturnValue(String filterReturnValue) {
+ public void setMatchReturnValue(String filterReturnValue) {
if (filterReturnValue.equalsIgnoreCase("accept")) {
matchReturnValue = ACCEPT;
} else if (filterReturnValue.equalsIgnoreCase("deny")) {
@@ -95,8 +92,7 @@
Set the value to return upon a successful match. Valid
int values come from the Filter base class, ACCEPT,
DENY, and NEUTRAL. */
- public
- void setMatchReturnValue(int filterReturnValue) {
+ public void setMatchReturnValue(int filterReturnValue) {
if (filterReturnValue < DENY || filterReturnValue > ACCEPT) {
LogLog.error("invalid matchReturnValue: " + filterReturnValue);
return;
@@ -108,16 +104,21 @@
/**
Gets the value that will be returned upon a successful
match. */
- public
- int getMatchReturnValue() {
- return matchReturnValue;
+ public String getMatchReturnValue() {
+ if (matchReturnValue == ACCEPT)
+ return "accept";
+ else if (matchReturnValue == DENY)
+ return "deny";
+ else if (matchReturnValue == NEUTRAL)
+ return "neutral";
+ else
+ return "unknown"; // this one should never happen
}
/**
Set the value to return upon a successful match. Valid
string values are "ACCEPT", "DENY", and "NEUTRAL". */
- public
- void setNoMatchReturnValue(String filterReturnValue) {
+ public void setNoMatchReturnValue(String filterReturnValue) {
if (filterReturnValue.equalsIgnoreCase("accept")) {
noMatchReturnValue = ACCEPT;
} else if (filterReturnValue.equalsIgnoreCase("deny")) {
@@ -128,27 +129,19 @@
LogLog.error("invalid noMatchReturnValue: " + filterReturnValue);
}
}
-
- /**
- Set the value to return upon an unsuccessful match. Valid
- int values come from the Filter base class, ACCEPT,
- DENY, and NEUTRAL. */
- public
- void setNoMatchReturnValue(int filterReturnValue) {
- if (filterReturnValue < DENY || filterReturnValue > ACCEPT) {
- LogLog.error("invalid noMatchReturnValue: " + filterReturnValue);
- return;
- }
- noMatchReturnValue = filterReturnValue;
- }
-
/**
Gets the value that will be returned upon an unsuccessful
match. */
- public
- int getNoMatchReturnValue() {
- return noMatchReturnValue;
+ public String getNoMatchReturnValue() {
+ if (noMatchReturnValue == ACCEPT)
+ return "accept";
+ else if (noMatchReturnValue == DENY)
+ return "deny";
+ else if (noMatchReturnValue == NEUTRAL)
+ return "neutral";
+ else
+ return "unknown"; // this one should never happen
}
/**
@@ -156,8 +149,7 @@
string. Valid values for the policy string are defined as
constants for this class: ACCEPT_ON_MATCH, DENY_ON_MATCH,
ACCEPT_ON_NOMATCH, DENY_ON_NOMATCH. */
- public
- void setChainPolicy(String policyStr) {
+ public void setChainPolicy(String policyStr) {
if (policyStr.equalsIgnoreCase(ACCEPT_ON_MATCH)) {
matchReturnValue = ACCEPT;
noMatchReturnValue = NEUTRAL;
@@ -182,8 +174,7 @@
or noMatchReturnValue will be returned. If no match test can
be performed (canMatch() returned false), then Filter.NEUTRAL
is returned. */
- public
- int decide(LoggingEvent event) {
+ public int decide(LoggingEvent event) {
if (canMatch()) {
if (match(event)) {
return matchReturnValue;
@@ -201,8 +192,7 @@
to a misconfiguration. This method should return true if a match
test can be performed, and false if it cannot be performed. The
default version always returns true. */
- protected
- boolean canMatch() {
+ protected boolean canMatch() {
return true;
}
@@ -210,7 +200,5 @@
Subclasses must implement this method to perform the specific
match test that they require. This method should return true
if a match is made, and false if no match is made. */
- abstract
- protected
- boolean match(LoggingEvent event);
+ abstract protected boolean match(LoggingEvent event);
}
1.2 +5 -10 jakarta-log4j/src/java/org/apache/log4j/filters/LevelMatchFilter.java
Index: LevelMatchFilter.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/filters/LevelMatchFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LevelMatchFilter.java 11 Jun 2002 07:04:53 -0000 1.1
+++ LevelMatchFilter.java 12 Jun 2002 06:07:34 -0000 1.2
@@ -29,8 +29,7 @@
@since 1.3
*/
-public
-class LevelMatchFilter extends MatchFilterBase {
+public class LevelMatchFilter extends MatchFilterBase {
/**
The level to match against. */
@@ -38,31 +37,27 @@
/**
Sets the level to match against. */
- public
- void setLevelToMatch(String level) {
+ public void setLevelToMatch(String level) {
levelToMatch = OptionConverter.toLevel(level, null);
}
/**
Gets the level that will be matched against. */
- public
- String getLevelToMatch() {
+ public String getLevelToMatch() {
return levelToMatch == null ? null : levelToMatch.toString();
}
/**
Overrides the implementation from the base class to return
false if the levelToMatch has not been configured. */
- protected
- boolean canMatch() {
+ protected boolean canMatch() {
return (levelToMatch != null);
}
/**
Returns true if the levelToMatch matches the level of the
logging event. */
- protected
- boolean match(LoggingEvent event) {
+ protected boolean match(LoggingEvent event) {
return (levelToMatch.equals(event.level));
}
}