You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2010/05/09 10:30:02 UTC
svn commit: r942512 - in /logging/log4j/companions:
extras/trunk/src/main/java/org/apache/log4j/filter/
extras/trunk/src/main/java/org/apache/log4j/rule/
extras/trunk/src/test/java/org/apache/log4j/rule/ receivers/trunk/
receivers/trunk/src/main/java/o...
Author: sdeboy
Date: Sun May 9 08:30:00 2010
New Revision: 942512
URL: http://svn.apache.org/viewvc?rev=942512&view=rev
Log:
Added ability to highlight search match text in the table (per-log panel preference, enabled by default)
- modified the Rule.evaluate method to accept a Map argument. If the map argument is not null, the map will be populated with text matches resulting from the rule evaluation - the keys are the field names containing text matches discovered during rule evaluation, the values are the (possibly multiple) text matches
- updated Chainsaw & receivers pom.xml to require log4j-extras 1.1 snapshot due to the change to the Rule API
- renamed JEditorPaneFormatter to JTextComponentFormatter
- modified the Search match color in the table from black background to grey background, from white foreground to black foreground
- reworked concurrency & use of event lists in ChainsawCyclicBufferTableModel
- added search matches to extendedloggingevent (used during rendering)
- updated findnext/previous logic to handle no selected row, better handling of wrapping forward & back
- reworked tablecellrenderer logic to support bolding of search-match text in the table (required changing multiline fields to use a jtextpane)
- updated all Rules to accept a Map which is populated by String keys representing the fields providing a text match, and Set values containing the one or more text matches for that field (if the map is null, no collection of results is performed)
- updated And, Or and Not rules to correctly aggregate text match results of their child rules
- updated ExpressionRule to allow definition of expressions containing keywords as text (must be single-quoted)
Modified:
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/ExpressionFilter.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/LocationInfoFilter.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/AndRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ColorRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/EqualsRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExistsRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InequalityRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelEqualsRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelInequalityRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LikeRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotEqualsRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotLevelEqualsRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/OrRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/PartialTextMatchRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/Rule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampEqualsRule.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampInequalityRule.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/AndRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/EqualsRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/ExistsRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelEqualsRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelInequalityRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotEqualsRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/OrRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/PartialTextMatchRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampEqualsRuleTest.java
logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampInequalityRuleTest.java
logging/log4j/companions/receivers/trunk/pom.xml
logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/LogFileXMLReceiver.java
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/ExpressionFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/ExpressionFilter.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/ExpressionFilter.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/ExpressionFilter.java Sun May 9 08:30:00 2010
@@ -150,7 +150,7 @@ public class ExpressionFilter extends Fi
* @return {@link Filter#NEUTRAL} is there is no string match.
*/
public int decide(final LoggingEvent event) {
- if (expressionRule.evaluate(event)) {
+ if (expressionRule.evaluate(event, null)) {
if (acceptOnMatch) {
return Filter.ACCEPT;
} else {
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/LocationInfoFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/LocationInfoFilter.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/LocationInfoFilter.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/filter/LocationInfoFilter.java Sun May 9 08:30:00 2010
@@ -104,7 +104,7 @@ public class LocationInfoFilter extends
* @return Filter.NEUTRAL.
*/
public int decide(final LoggingEvent event) {
- if (expressionRule.evaluate(event)) {
+ if (expressionRule.evaluate(event, null)) {
event.getLocationInformation();
}
return Filter.NEUTRAL;
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/AndRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/AndRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/AndRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/AndRule.java Sun May 9 08:30:00 2010
@@ -19,6 +19,11 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
@@ -86,7 +91,37 @@ public class AndRule extends AbstractRul
/**
* {@inheritDoc}
*/
- public boolean evaluate(final LoggingEvent event) {
- return (firstRule.evaluate(event) && secondRule.evaluate(event));
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ if (matches == null) {
+ return firstRule.evaluate(event, null) && secondRule.evaluate(event, null);
+ }
+ Map tempMatches1 = new HashMap();
+ Map tempMatches2 = new HashMap();
+ boolean result = firstRule.evaluate(event, tempMatches1) && secondRule.evaluate(event, tempMatches2);
+ if (result) {
+ for (Iterator iter = tempMatches1.entrySet().iterator();iter.hasNext();) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object key = entry.getKey();
+ Set value = (Set)entry.getValue();
+ Set mainSet = (Set) matches.get(key);
+ if (mainSet == null) {
+ mainSet = new HashSet();
+ matches.put(key, mainSet);
+ }
+ mainSet.addAll(value);
+ }
+ for (Iterator iter = tempMatches2.entrySet().iterator();iter.hasNext();) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object key = entry.getKey();
+ Set value = (Set)entry.getValue();
+ Set mainSet = (Set) matches.get(key);
+ if (mainSet == null) {
+ mainSet = new HashSet();
+ matches.put(key, mainSet);
+ }
+ mainSet.addAll(value);
+ }
+ }
+ return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ColorRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ColorRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ColorRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ColorRule.java Sun May 9 08:30:00 2010
@@ -19,6 +19,7 @@ package org.apache.log4j.rule;
import java.awt.Color;
import java.io.Serializable;
+import java.util.Map;
import org.apache.log4j.spi.LoggingEvent;
@@ -104,8 +105,9 @@ public class ColorRule extends AbstractR
/**
* {@inheritDoc}
*/
- public boolean evaluate(final LoggingEvent event) {
- return (rule != null && rule.evaluate(event));
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ //no need for color rules to build matches
+ return (rule != null && rule.evaluate(event, null));
}
/**
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/EqualsRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/EqualsRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/EqualsRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/EqualsRule.java Sun May 9 08:30:00 2010
@@ -20,6 +20,9 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.LoggingEventFieldResolver;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
@@ -99,9 +102,18 @@ public class EqualsRule extends Abstract
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
Object p2 = RESOLVER.getValue(field, event);
- return ((p2 != null) && p2.toString().equals(value));
+ boolean result = (p2 != null) && p2.toString().equals(value);
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(field.toUpperCase());
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(field.toUpperCase(), entries);
+ }
+ entries.add(value);
+ }
+ return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExistsRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExistsRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExistsRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExistsRule.java Sun May 9 08:30:00 2010
@@ -20,6 +20,9 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.LoggingEventFieldResolver;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
@@ -85,9 +88,18 @@ public class ExistsRule extends Abstract
/**
* {@inheritDoc}
*/
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
Object p2 = RESOLVER.getValue(field, event);
- return (!((p2 == null) || ((p2 != null) && p2.toString().equals(""))));
+ boolean result = !((p2 == null) || (p2.toString().equals("")));
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(field.toUpperCase());
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(field.toUpperCase(), entries);
+ }
+ entries.add(p2);
+ }
+ return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java Sun May 9 08:30:00 2010
@@ -19,6 +19,7 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
+import java.util.Map;
import java.util.Stack;
import java.util.StringTokenizer;
@@ -103,8 +104,8 @@ public class ExpressionRule extends Abst
/**
* {@inheritDoc}
*/
- public boolean evaluate(final LoggingEvent event) {
- return rule.evaluate(event);
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ return rule.evaluate(event, matches);
}
/**
@@ -130,62 +131,50 @@ public class ExpressionRule extends Abst
Stack stack = new Stack();
StringTokenizer tokenizer = new StringTokenizer(expression);
- while (tokenizer.hasMoreTokens()) {
- //examine each token
- String token = tokenizer.nextToken();
- if ((token.startsWith("'"))
- && (token.endsWith("'")
- && (token.length() > 2))) {
- token = token.substring(1, token.length() - 1);
- }
- if ((token.startsWith("'"))
- && (token.endsWith("'")
- && (token.length() == 2))) {
- token = "";
- }
-
- boolean inText = token.startsWith("'");
- if (inText) {
- token = token.substring(1);
- while (inText && tokenizer.hasMoreTokens()) {
- token = token + " " + tokenizer.nextToken();
- inText = !(token.endsWith("'"));
+ while (tokenizer.hasMoreTokens()) {
+ //examine each token
+ String token = tokenizer.nextToken();
+ if (token.startsWith("'")) {
+ token = token.substring(1);
+ while (!token.endsWith("'") && tokenizer.hasMoreTokens()) {
+ token = token + " " + tokenizer.nextToken();
+ }
+ if (token.length() > 0) {
+ token = token.substring(0, token.length() - 1);
+ }
+ } else {
+ //if a symbol is found, pop 2 off the stack,
+ // evaluate and push the result
+ if (factory.isRule(token)) {
+ Rule r = factory.getRule(token, stack);
+ stack.push(r);
+ //null out the token so we don't try to push it below
+ token = null;
+ }
+ }
+ //variables or constants are pushed onto the stack
+ if (token != null && token.length() > 0) {
+ stack.push(token);
+ }
}
- if (token.length() > 0) {
- token = token.substring(0, token.length() - 1);
+
+ if ((stack.size() == 1) && (!(stack.peek() instanceof Rule))) {
+ //while this may be an attempt at creating an expression,
+ //for ease of use, convert this single entry to a partial-text
+ //match on the MSG field
+ Object o = stack.pop();
+ stack.push("MSG");
+ stack.push(o);
+ return factory.getRule("~=", stack);
}
- }
- //if a symbol is found, pop 2 off the stack,
- // evaluate and push the result
- if (factory.isRule(token)) {
- Rule r = factory.getRule(token, stack);
- stack.push(r);
- } else {
- //variables or constants are pushed onto the stack
- if (token.length() > 0) {
- stack.push(token);
+ //stack should contain a single rule if the expression is valid
+ if ((stack.size() != 1) || (!(stack.peek() instanceof Rule))) {
+ throw new IllegalArgumentException("invalid expression: " + expression);
+ } else {
+ return (Rule) stack.pop();
}
}
- }
-
- if ((stack.size() == 1) && (!(stack.peek() instanceof Rule))) {
- //while this may be an attempt at creating an expression,
- //for ease of use, convert this single entry to a partial-text
- //match on the MSG field
- Object o = stack.pop();
- stack.push("MSG");
- stack.push(o);
- return factory.getRule("~=", stack);
- }
-
- //stack should contain a single rule if the expression is valid
- if ((stack.size() != 1) || (!(stack.peek() instanceof Rule))) {
- throw new IllegalArgumentException("invalid expression: " + expression);
- } else {
- return (Rule) stack.pop();
- }
- }
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InequalityRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InequalityRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InequalityRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InequalityRule.java Sun May 9 08:30:00 2010
@@ -20,6 +20,9 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.LoggingEventFieldResolver;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
@@ -119,12 +122,10 @@ public class InequalityRule extends Abst
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
long first = 0;
-
- try {
- first =
- new Long(RESOLVER.getValue(field, event).toString()).longValue();
+ try {
+ first = new Long(RESOLVER.getValue(field, event).toString()).longValue();
} catch (NumberFormatException nfe) {
return false;
}
@@ -148,7 +149,14 @@ public class InequalityRule extends Abst
} else if (">=".equals(inequalitySymbol)) {
result = first >= second;
}
-
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(field.toUpperCase());
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(field.toUpperCase(), entries);
+ }
+ entries.add(String.valueOf(first));
+ }
return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelEqualsRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelEqualsRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelEqualsRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelEqualsRule.java Sun May 9 08:30:00 2010
@@ -18,12 +18,16 @@
package org.apache.log4j.rule;
import java.io.IOException;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.log4j.Level;
import org.apache.log4j.helpers.UtilLoggingLevel;
import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.LoggingEventFieldResolver;
/**
* A Rule class implementing equals against two levels.
@@ -95,10 +99,20 @@ public class LevelEqualsRule extends Abs
/**
* {@inheritDoc}
*/
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
//both util.logging and log4j contain 'info' - use the int values instead of equality
//info level set to the same value for both levels
- return level.toInt() == event.getLevel().toInt();
+ Level eventLevel = event.getLevel();
+ boolean result = (level.toInt() == eventLevel.toInt());
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.LEVEL_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.LEVEL_FIELD, entries);
+ }
+ entries.add(eventLevel);
+ }
+ return result;
}
/**
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelInequalityRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelInequalityRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelInequalityRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LevelInequalityRule.java Sun May 9 08:30:00 2010
@@ -17,12 +17,16 @@
package org.apache.log4j.rule;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.log4j.Level;
import org.apache.log4j.helpers.UtilLoggingLevel;
import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.LoggingEventFieldResolver;
/**
* A Rule class implementing inequality evaluation for Levels (log4j and
@@ -143,8 +147,18 @@ public class LevelInequalityRule {
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
- return (event.getLevel().toInt() < newLevelInt);
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ Level eventLevel = event.getLevel();
+ boolean result = (eventLevel.toInt() < newLevelInt);
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.LEVEL_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.LEVEL_FIELD, entries);
+ }
+ entries.add(eventLevel);
+ }
+ return result;
}
}
@@ -167,8 +181,18 @@ public class LevelInequalityRule {
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
- return (event.getLevel().toInt() > newLevelInt);
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ Level eventLevel = event.getLevel();
+ boolean result = (eventLevel.toInt() > newLevelInt);
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.LEVEL_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.LEVEL_FIELD, entries);
+ }
+ entries.add(eventLevel);
+ }
+ return result;
}
}
@@ -192,8 +216,18 @@ public class LevelInequalityRule {
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
- return event.getLevel().toInt() >= newLevelInt;
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ Level eventLevel = event.getLevel();
+ boolean result = eventLevel.toInt() >= newLevelInt;
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.LEVEL_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.LEVEL_FIELD, entries);
+ }
+ entries.add(eventLevel);
+ }
+ return result;
}
}
@@ -218,8 +252,19 @@ public class LevelInequalityRule {
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
- return (event.getLevel().toInt() <= newLevelInt);
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ Level eventLevel = event.getLevel();
+ boolean result = eventLevel.toInt() <= newLevelInt;
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.LEVEL_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.LEVEL_FIELD, entries);
+ }
+ entries.add(eventLevel);
+ }
+
+ return result;
}
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LikeRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LikeRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LikeRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/LikeRule.java Sun May 9 08:30:00 2010
@@ -21,6 +21,9 @@ import org.apache.log4j.spi.LoggingEvent
import org.apache.log4j.spi.LoggingEventFieldResolver;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -104,7 +107,8 @@ public class LikeRule extends AbstractRu
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ //no need to figure out what part of the string matched, just set the entire string as a match
Object input = RESOLVER.getValue(field, event);
if((input != null) && (pattern != null)) {
if (matcher == null) {
@@ -112,7 +116,16 @@ public class LikeRule extends AbstractRu
} else {
matcher.reset(input.toString());
}
- return matcher.matches();
+ boolean result = matcher.matches();
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(field.toUpperCase());
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(field.toUpperCase(), entries);
+ }
+ entries.add(input);
+ }
+ return result;
}
return false;
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotEqualsRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotEqualsRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotEqualsRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotEqualsRule.java Sun May 9 08:30:00 2010
@@ -17,6 +17,9 @@
package org.apache.log4j.rule;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
import org.apache.log4j.spi.LoggingEvent;
@@ -100,9 +103,19 @@ public class NotEqualsRule extends Abstr
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
Object p2 = RESOLVER.getValue(field, event);
- return ((p2 != null) && !(p2.toString().equals(value)));
+ boolean result = (p2 != null) && !(p2.toString().equals(value));
+ if (result && matches != null) {
+ //not equals - add the text that isn't equal (p2)
+ Set entries = (Set) matches.get(field.toUpperCase());
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(field.toUpperCase(), entries);
+ }
+ entries.add(value);
+ }
+ return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotLevelEqualsRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotLevelEqualsRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotLevelEqualsRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotLevelEqualsRule.java Sun May 9 08:30:00 2010
@@ -18,12 +18,16 @@
package org.apache.log4j.rule;
import java.io.IOException;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.log4j.Level;
import org.apache.log4j.helpers.UtilLoggingLevel;
import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.LoggingEventFieldResolver;
/**
* A Rule class implementing not equals against two levels.
@@ -95,10 +99,20 @@ public class NotLevelEqualsRule extends
/**
* {@inheritDoc}
*/
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
//both util.logging and log4j contain 'info' - use the int values instead of equality
//info level set to the same value for both levels
- return level.toInt() != event.getLevel().toInt();
+ Level eventLevel = event.getLevel();
+ boolean result = level.toInt() != eventLevel.toInt();
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.LEVEL_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.LEVEL_FIELD, entries);
+ }
+ entries.add(eventLevel);
+ }
+ return result;
}
/**
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/NotRule.java Sun May 9 08:30:00 2010
@@ -19,6 +19,11 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
/**
@@ -75,7 +80,25 @@ public class NotRule extends AbstractRul
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
- return !(rule.evaluate(event));
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ if (matches == null) {
+ return !(rule.evaluate(event, null));
+ }
+ Map tempMatches = new HashMap();
+ boolean result = !(rule.evaluate(event, tempMatches));
+ if (result) {
+ for (Iterator iter = tempMatches.entrySet().iterator();iter.hasNext();) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object key = entry.getKey();
+ Set value = (Set)entry.getValue();
+ Set mainSet = (Set) matches.get(key);
+ if (mainSet == null) {
+ mainSet = new HashSet();
+ matches.put(key, mainSet);
+ }
+ mainSet.addAll(value);
+ }
+ }
+ return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/OrRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/OrRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/OrRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/OrRule.java Sun May 9 08:30:00 2010
@@ -19,6 +19,11 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
/**
@@ -83,7 +88,40 @@ public class OrRule extends AbstractRule
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
- return (rule1.evaluate(event) || rule2.evaluate(event));
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ if (matches == null) {
+ return (rule1.evaluate(event, null) || rule2.evaluate(event, null));
+ }
+ Map tempMatches1 = new HashMap();
+ Map tempMatches2 = new HashMap();
+ //not short-circuiting because we want to build the matches list
+ boolean result1 = rule1.evaluate(event, tempMatches1);
+ boolean result2 = rule2.evaluate(event, tempMatches2);
+ boolean result = result1 || result2;
+ if (result) {
+ for (Iterator iter = tempMatches1.entrySet().iterator();iter.hasNext();) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object key = entry.getKey();
+ Set value = (Set)entry.getValue();
+ Set mainSet = (Set) matches.get(key);
+ if (mainSet == null) {
+ mainSet = new HashSet();
+ matches.put(key, mainSet);
+ }
+ mainSet.addAll(value);
+ }
+ for (Iterator iter = tempMatches2.entrySet().iterator();iter.hasNext();) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object key = entry.getKey();
+ Set value = (Set)entry.getValue();
+ Set mainSet = (Set) matches.get(key);
+ if (mainSet == null) {
+ mainSet = new HashSet();
+ matches.put(key, mainSet);
+ }
+ mainSet.addAll(value);
+ }
+ }
+ return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/PartialTextMatchRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/PartialTextMatchRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/PartialTextMatchRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/PartialTextMatchRule.java Sun May 9 08:30:00 2010
@@ -20,6 +20,9 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.LoggingEventFieldResolver;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.Stack;
@@ -93,10 +96,17 @@ public class PartialTextMatchRule extend
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
Object p2 = RESOLVER.getValue(field, event);
-
- return ((p2 != null) && (value != null)
- && (p2.toString().toLowerCase().indexOf(value.toLowerCase()) > -1));
+ boolean result = ((p2 != null) && (value != null) && (p2.toString().toLowerCase().indexOf(value.toLowerCase()) > -1));
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(field.toUpperCase());
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(field.toUpperCase(), entries);
+ }
+ entries.add(value);
+ }
+ return result;
}
}
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/Rule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/Rule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/Rule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/Rule.java Sun May 9 08:30:00 2010
@@ -22,6 +22,7 @@ package org.apache.log4j.rule;
import org.apache.log4j.spi.LoggingEvent;
import java.beans.PropertyChangeListener;
+import java.util.Map;
/**
@@ -40,9 +41,12 @@ public interface Rule {
* <p>What True/False means can be client-specific.
*
* @param e LoggingEvent this instance will evaluate
+ * @param matches a Map of event field keys to Sets of matching strings (may be null) which will be
+ * updated during execution of this method to include field and string matches based on the rule
+ * evaluation results
* @return true if this Rule instance accepts the event, otherwise false.
*/
- boolean evaluate(LoggingEvent e);
+ boolean evaluate(LoggingEvent e, Map matches);
/**
* Adds a PropertyChangeListener to this instance, which is notified when
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampEqualsRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampEqualsRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampEqualsRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampEqualsRule.java Sun May 9 08:30:00 2010
@@ -21,6 +21,9 @@ import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.LoggingEventFieldResolver;
@@ -75,10 +78,19 @@ public class TimestampEqualsRule extends
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
- long eventTimeStamp = Long.parseLong(
- RESOLVER.getValue("TIMESTAMP", event).toString()) / 1000 * 1000;
- return eventTimeStamp == timeStamp;
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ String eventTimeStampString = RESOLVER.getValue(LoggingEventFieldResolver.TIMESTAMP_FIELD, event).toString();
+ long eventTimeStamp = Long.parseLong(eventTimeStampString) / 1000 * 1000;
+ boolean result = (eventTimeStamp == timeStamp);
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.TIMESTAMP_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.TIMESTAMP_FIELD, entries);
+ }
+ entries.add(eventTimeStampString);
+ }
+ return result;
}
/**
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampInequalityRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampInequalityRule.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampInequalityRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/TimestampInequalityRule.java Sun May 9 08:30:00 2010
@@ -21,6 +21,9 @@ import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.LoggingEventFieldResolver;
@@ -82,9 +85,10 @@ public class TimestampInequalityRule ext
}
/** {@inheritDoc} */
- public boolean evaluate(final LoggingEvent event) {
+ public boolean evaluate(final LoggingEvent event, Map matches) {
+ String eventTimeStampString = RESOLVER.getValue(LoggingEventFieldResolver.TIMESTAMP_FIELD, event).toString();
long eventTimeStamp = Long.parseLong(
- RESOLVER.getValue("TIMESTAMP", event).toString()) / 1000 * 1000;
+ eventTimeStampString) / 1000 * 1000;
boolean result = false;
long first = eventTimeStamp;
long second = timeStamp;
@@ -98,7 +102,14 @@ public class TimestampInequalityRule ext
} else if (">=".equals(inequalitySymbol)) {
result = first >= second;
}
-
+ if (result && matches != null) {
+ Set entries = (Set) matches.get(LoggingEventFieldResolver.TIMESTAMP_FIELD);
+ if (entries == null) {
+ entries = new HashSet();
+ matches.put(LoggingEventFieldResolver.TIMESTAMP_FIELD, entries);
+ }
+ entries.add(eventTimeStampString);
+ }
return result;
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/AndRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/AndRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/AndRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/AndRuleTest.java Sun May 9 08:30:00 2010
@@ -82,7 +82,7 @@ public class AndRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -98,7 +98,7 @@ public class AndRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -114,7 +114,7 @@ public class AndRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
@@ -131,7 +131,7 @@ public class AndRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
@@ -148,7 +148,7 @@ public class AndRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/EqualsRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/EqualsRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/EqualsRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/EqualsRuleTest.java Sun May 9 08:30:00 2010
@@ -82,7 +82,7 @@ public class EqualsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -99,7 +99,7 @@ public class EqualsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -114,7 +114,7 @@ public class EqualsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -129,7 +129,7 @@ public class EqualsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -144,7 +144,7 @@ public class EqualsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/ExistsRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/ExistsRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/ExistsRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/ExistsRuleTest.java Sun May 9 08:30:00 2010
@@ -76,7 +76,7 @@ public class ExistsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -90,7 +90,7 @@ public class ExistsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -104,7 +104,7 @@ public class ExistsRuleTest extends Test
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelEqualsRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelEqualsRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelEqualsRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelEqualsRuleTest.java Sun May 9 08:30:00 2010
@@ -48,7 +48,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -59,7 +59,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -71,7 +71,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -83,7 +83,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -94,7 +94,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINER,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -105,7 +105,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINE,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -117,7 +117,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINER,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -129,7 +129,7 @@ public class LevelEqualsRuleTest extends
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINE,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelInequalityRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelInequalityRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelInequalityRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/LevelInequalityRuleTest.java Sun May 9 08:30:00 2010
@@ -68,7 +68,7 @@ public class LevelInequalityRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -80,7 +80,7 @@ public class LevelInequalityRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -91,7 +91,7 @@ public class LevelInequalityRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINER,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -102,7 +102,7 @@ public class LevelInequalityRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINER,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -114,7 +114,7 @@ public class LevelInequalityRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINER,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -126,7 +126,7 @@ public class LevelInequalityRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), UtilLoggingLevel.FINER,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotEqualsRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotEqualsRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotEqualsRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotEqualsRuleTest.java Sun May 9 08:30:00 2010
@@ -81,7 +81,7 @@ public class NotEqualsRuleTest extends T
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.WARN,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -97,7 +97,7 @@ public class NotEqualsRuleTest extends T
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -112,7 +112,7 @@ public class NotEqualsRuleTest extends T
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -127,7 +127,7 @@ public class NotEqualsRuleTest extends T
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -142,7 +142,7 @@ public class NotEqualsRuleTest extends T
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/NotRuleTest.java Sun May 9 08:30:00 2010
@@ -79,7 +79,7 @@ public class NotRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -94,7 +94,7 @@ public class NotRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
@@ -110,7 +110,7 @@ public class NotRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
@@ -126,7 +126,7 @@ public class NotRuleTest extends TestCas
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/OrRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/OrRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/OrRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/OrRuleTest.java Sun May 9 08:30:00 2010
@@ -82,7 +82,7 @@ public class OrRuleTest extends TestCase
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -98,7 +98,7 @@ public class OrRuleTest extends TestCase
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -114,7 +114,7 @@ public class OrRuleTest extends TestCase
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
@@ -131,7 +131,7 @@ public class OrRuleTest extends TestCase
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -147,7 +147,7 @@ public class OrRuleTest extends TestCase
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
@@ -164,7 +164,7 @@ public class OrRuleTest extends TestCase
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/PartialTextMatchRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/PartialTextMatchRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/PartialTextMatchRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/PartialTextMatchRuleTest.java Sun May 9 08:30:00 2010
@@ -79,7 +79,7 @@ public class PartialTextMatchRuleTest ex
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
@@ -95,7 +95,7 @@ public class PartialTextMatchRuleTest ex
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -110,7 +110,7 @@ public class PartialTextMatchRuleTest ex
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -125,7 +125,7 @@ public class PartialTextMatchRuleTest ex
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampEqualsRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampEqualsRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampEqualsRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampEqualsRuleTest.java Sun May 9 08:30:00 2010
@@ -20,13 +20,11 @@ package org.apache.log4j.rule;
import junit.framework.TestCase;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.UtilLoggingLevel;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.util.SerializationTestHelper;
import java.io.IOException;
import java.util.Calendar;
-import java.util.Date;
import java.util.GregorianCalendar;
/**
@@ -52,7 +50,7 @@ public class TimestampEqualsRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -64,7 +62,7 @@ public class TimestampEqualsRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
@@ -77,7 +75,7 @@ public class TimestampEqualsRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -90,7 +88,7 @@ public class TimestampEqualsRuleTest ext
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
/**
Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampInequalityRuleTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampInequalityRuleTest.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampInequalityRuleTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/rule/TimestampInequalityRuleTest.java Sun May 9 08:30:00 2010
@@ -20,7 +20,6 @@ package org.apache.log4j.rule;
import junit.framework.TestCase;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.UtilLoggingLevel;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.util.SerializationTestHelper;
@@ -73,7 +72,7 @@ public class TimestampInequalityRuleTest
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO,
"Hello, World", null);
- assertTrue(rule.evaluate(event));
+ assertTrue(rule.evaluate(event, null));
}
/**
@@ -86,7 +85,7 @@ public class TimestampInequalityRuleTest
LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger",
Logger.getRootLogger(), cal.getTimeInMillis(), Level.WARN,
"Hello, World", null);
- assertFalse(rule.evaluate(event));
+ assertFalse(rule.evaluate(event, null));
}
}
Modified: logging/log4j/companions/receivers/trunk/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/pom.xml?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/receivers/trunk/pom.xml (original)
+++ logging/log4j/companions/receivers/trunk/pom.xml Sun May 9 08:30:00 2010
@@ -245,7 +245,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
- <version>1.0</version>
+ <version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>oro</groupId>
Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java (original)
+++ logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java Sun May 9 08:30:00 2010
@@ -566,7 +566,7 @@ public class LogFilePatternReceiver exte
private boolean passesExpression(LoggingEvent event) {
if (event != null) {
if (expressionRule != null) {
- return (expressionRule.evaluate(event));
+ return (expressionRule.evaluate(event, null));
}
}
return true;
Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/LogFileXMLReceiver.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/LogFileXMLReceiver.java?rev=942512&r1=942511&r2=942512&view=diff
==============================================================================
--- logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/LogFileXMLReceiver.java (original)
+++ logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/LogFileXMLReceiver.java Sun May 9 08:30:00 2010
@@ -151,7 +151,7 @@ public class LogFileXMLReceiver extends
private boolean passesExpression(LoggingEvent event) {
if (event != null) {
if (expressionRule != null) {
- return (expressionRule.evaluate(event));
+ return (expressionRule.evaluate(event, null));
}
}
return true;
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org