cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-12-10 Thread sdeboy
sdeboy  2003/12/10 22:10:27

  Modified:src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  removed debug msgs
  
  Revision  ChangesPath
  1.15  +0 -3  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java
  
  Index: LoggingEventFieldResolver.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- LoggingEventFieldResolver.java11 Dec 2003 05:45:59 -  1.14
  +++ LoggingEventFieldResolver.java11 Dec 2003 06:10:27 -  1.15
  @@ -137,12 +137,9 @@
 
 while (tokenizer.hasMoreTokens()) {
 String token = tokenizer.nextToken();
  -  System.out.println("examining" + token);
 if (isField(token)  || (token.toUpperCase().startsWith(MDC_FIELD) || 
token.toUpperCase().startsWith(PROP_FIELD))) {
  -  System.out.println("was token - value is " +getValue(token, 
event).toString()); 
 result.append(getValue(token, event).toString());
 } else { 
  -  System.out.println("Was not a token - appending " + token);
 result.append(token);
 }
 }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-10-30 Thread sdeboy
sdeboy  2003/10/30 00:10:27

  Modified:src/java/org/apache/log4j/chainsaw/rule RuleTest.java
   src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  added event field and operator support to expression builder's context menu
  
  Revision  ChangesPath
  1.13  +94 -14
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/RuleTest.java
  
  Index: RuleTest.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/RuleTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RuleTest.java 30 Oct 2003 07:04:27 -  1.12
  +++ RuleTest.java 30 Oct 2003 08:10:26 -  1.13
  @@ -49,14 +49,6 @@
   
   package org.apache.log4j.chainsaw.rule;
   
  -import org.apache.log4j.Level;
  -import org.apache.log4j.Logger;
  -import org.apache.log4j.MDC;
  -import org.apache.log4j.chainsaw.ChainsawConstants;
  -import org.apache.log4j.chainsaw.LoggingEventFieldResolver;
  -import org.apache.log4j.chainsaw.filter.FilterModel;
  -import org.apache.log4j.spi.LoggingEvent;
  -
   import java.awt.BorderLayout;
   import java.awt.GridLayout;
   import java.awt.Point;
  @@ -65,12 +57,12 @@
   import java.awt.event.KeyEvent;
   import java.awt.event.MouseAdapter;
   import java.awt.event.MouseEvent;
  -
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
   
   import javax.swing.AbstractAction;
  +import javax.swing.DefaultListModel;
   import javax.swing.JButton;
   import javax.swing.JFrame;
   import javax.swing.JLabel;
  @@ -82,6 +74,14 @@
   import javax.swing.JTextField;
   import javax.swing.WindowConstants;
   
  +import org.apache.log4j.Level;
  +import org.apache.log4j.Logger;
  +import org.apache.log4j.MDC;
  +import org.apache.log4j.chainsaw.ChainsawConstants;
  +import org.apache.log4j.chainsaw.LoggingEventFieldResolver;
  +import org.apache.log4j.chainsaw.filter.FilterModel;
  +import org.apache.log4j.spi.LoggingEvent;
  +
   
   public class RuleTest extends JFrame {
 /**
  @@ -233,11 +233,38 @@
   JPopupMenu contextMenu = new JPopupMenu();
   JList list = new JList();
   final JTextField textField;
  +private DefaultListModel fieldModel = new DefaultListModel();
  +private DefaultListModel operatorModel = new DefaultListModel();
   
   public ContextListener(final JTextField textField) {
 this.textField = textField;
  -  list.setVisibleRowCount(5);
  +  fieldModel.addElement("LOGGER");
  +  fieldModel.addElement("LEVEL");
  +  fieldModel.addElement("CLASS");
  +  fieldModel.addElement("FILE");
  +  fieldModel.addElement("LINE");
  +  fieldModel.addElement("METHOD");
  +  fieldModel.addElement("MSG");
  +  fieldModel.addElement("NDC");
  +  fieldModel.addElement("EXCEPTION");
  +  fieldModel.addElement("TIMESTAMP");
  +  fieldModel.addElement("THREAD");
  +  fieldModel.addElement("MDC");
  +  fieldModel.addElement("PROP");
  +
  +  operatorModel.addElement("&&");
  +  operatorModel.addElement("||");
  +  operatorModel.addElement("!");
  +  operatorModel.addElement("!=");
  +  operatorModel.addElement("==");
  +  operatorModel.addElement("~=");
  +  operatorModel.addElement("like");
  +  operatorModel.addElement("<");
  +  operatorModel.addElement(">");
  +  operatorModel.addElement("<=");
  +  operatorModel.addElement(">=");
   
  +  list.setVisibleRowCount(5);
 PopupListener popupListener = new PopupListener();
 textField.addMouseListener(popupListener);
   
  @@ -269,8 +296,8 @@
 String text = textField.getText();
 int position = textField.getCaretPosition();
 textField.setText(
  -text.substring(0, position) + value + text.substring(position));
  -  textField.setCaretPosition(position + value.length());
  +text.substring(0, position) + value + " " + text.substring(position));
  +  textField.setCaretPosition(position + value.length() + 1);
   }
   
   public void keyPressed(KeyEvent e) {
  @@ -289,9 +316,33 @@
   list.setSelectedIndex(0);
   
   Point p = textField.getCaret().getMagicCaretPosition();
  -contextMenu.show(textField, p.x, (p.y + (textField.getHeight() - 6)));
  +contextMenu.show(textField, p.x, (p.y + (textField.getHeight() - 5)));
   list.requestFocus();
  -  }
  +  } else {
  +if (isOperatorContextValid()) {
  +list.setModel(operatorModel);
  +list.setSelectedIndex(0);
  +
  +Point p = textField.getCaret().getMagicCaretPosition();
  +contextMenu.show(textField, p.x, (p.y + (textField.getHeight() - 5)));
  +list.requestFocus();
  +} else if (isFieldContextValid()) {
  +list.setModel(fieldModel);
  

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-10-30 Thread sdeboy
sdeboy  2003/10/29 23:04:27

  Modified:src/java/org/apache/log4j/chainsaw/filter
EventTypeEntryContainer.java
   src/java/org/apache/log4j/chainsaw/rule RuleTest.java
   src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  updated context menu code - now support for context menu via right mouse button or 
ctrl-space
  mdc lookup now functions correctly
  
  Revision  ChangesPath
  1.3   +5 -9  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/filter/EventTypeEntryContainer.java
  
  Index: EventTypeEntryContainer.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/filter/EventTypeEntryContainer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EventTypeEntryContainer.java  29 Oct 2003 08:50:36 -  1.2
  +++ EventTypeEntryContainer.java  30 Oct 2003 07:04:27 -  1.3
  @@ -93,7 +93,7 @@
 private static final String FILE_FIELD = "FILE";
 private static final String THREAD_FIELD = "THREAD";
 private static final String METHOD_FIELD = "METHOD";
  -  private static final String MDC_FIELD = "MDC.";
  +  private static final String MDC_FIELD = "MDC";
 private static final String NDC_FIELD = "NDC";
   
 public EventTypeEntryContainer() {
  @@ -104,23 +104,19 @@
 modelMap.put(THREAD_FIELD, threadListModel);
 modelMap.put(METHOD_FIELD, methodListModel);
 modelMap.put(NDC_FIELD, ndcListModel);
  -  //mdc supported, but not in map
  +  modelMap.put(MDC_FIELD, mdcListModel);
 }
 
 public boolean modelExists(String fieldName) {
 if (fieldName != null) {
  -  return ((fieldName.toUpperCase().startsWith(MDC_FIELD)) || 
(modelMap.keySet().contains(fieldName.toUpperCase(;
  +  return (modelMap.keySet().contains(fieldName.toUpperCase()));
 }
 return false;
 }
 
 public ListModel getModel(String fieldName) {
  -  if (modelExists(fieldName)) {
  -  if (fieldName.toUpperCase().startsWith(MDC_FIELD)) {
  -  return mdcListModel;
  -  } else {
  -  return (ListModel)modelMap.get(fieldName.toUpperCase());
  -  }
  +  if (fieldName != null) {
  +  return (ListModel)modelMap.get(fieldName.toUpperCase());
 }
 return null;
 } 
  
  
  
  1.12  +159 -93   
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/RuleTest.java
  
  Index: RuleTest.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/RuleTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RuleTest.java 29 Oct 2003 08:50:37 -  1.11
  +++ RuleTest.java 30 Oct 2003 07:04:27 -  1.12
  @@ -49,6 +49,14 @@
   
   package org.apache.log4j.chainsaw.rule;
   
  +import org.apache.log4j.Level;
  +import org.apache.log4j.Logger;
  +import org.apache.log4j.MDC;
  +import org.apache.log4j.chainsaw.ChainsawConstants;
  +import org.apache.log4j.chainsaw.LoggingEventFieldResolver;
  +import org.apache.log4j.chainsaw.filter.FilterModel;
  +import org.apache.log4j.spi.LoggingEvent;
  +
   import java.awt.BorderLayout;
   import java.awt.GridLayout;
   import java.awt.Point;
  @@ -57,6 +65,7 @@
   import java.awt.event.KeyEvent;
   import java.awt.event.MouseAdapter;
   import java.awt.event.MouseEvent;
  +
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  @@ -72,16 +81,6 @@
   import javax.swing.JTextArea;
   import javax.swing.JTextField;
   import javax.swing.WindowConstants;
  -import javax.swing.event.CaretEvent;
  -import javax.swing.event.CaretListener;
  -
  -import org.apache.log4j.Level;
  -import org.apache.log4j.Logger;
  -import org.apache.log4j.MDC;
  -import org.apache.log4j.chainsaw.ChainsawConstants;
  -import org.apache.log4j.chainsaw.LoggingEventFieldResolver;
  -import org.apache.log4j.chainsaw.filter.FilterModel;
  -import org.apache.log4j.spi.LoggingEvent;
   
   
   public class RuleTest extends JFrame {
  @@ -106,8 +105,9 @@
   
   LoggingEventFieldResolver resolver =
 LoggingEventFieldResolver.getInstance();
  -  
  +
   filterModel = new FilterModel();
  +
   final List eventList = new ArrayList();
   MDC.put("entry1", "123");
   eventList.add(
  @@ -133,10 +133,13 @@
   "org.apache.log4j.chainsaw", Logger.getLogger("logger4"),
   System.currentTimeMillis(), Level.WARN, "message4",
   new Exception("test4")));
  +
   Iterator iter = eventList.iterator();
  +
   while (iter.hasNext()) {
  -LoggingEvent event = (LoggingEvent)iter.next();
  -filterModel.processNewLoggingEvent(ChainsawConstants.LOG4J_EVENT_TYPE, 
event);
  + 

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-10-27 Thread sdeboy
sdeboy  2003/10/27 00:35:31

  Modified:src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Added:   src/java/org/apache/log4j/varia ExpressionFilter.java
  Log:
  First commit of ExpressionRule-based filter - see the org.apache.log4j.chainsaw.rule 
package and org.apache.log4j.chainsaw.LoggingEventFieldResolver for more information.
  
  Supported operators: !, ==, !=, ~= (partial text), like (ORO), <, <=, >, >=, ||, &&
  
  Supported event keywords:
  
  LOGGER
  LEVEL
  CLASS
  FILE
  LINE
  METHOD
  MSG
  NDC
  EXCEPTION
  TIMESTAMP
  THREAD
  MDC.*
  PROP.*
  
  NOTE:  MDC and Properties require a user-specified parameter to do the lookup in the 
table - specified after the '.' - for example, MDC.userID
  
  Also supports grouping via parentheses.
  
  Revision  ChangesPath
  1.1  
jakarta-log4j/src/java/org/apache/log4j/varia/ExpressionFilter.java
  
  Index: ExpressionFilter.java
  ===
  /*
   * 
   *   The Apache Software License, Version 1.1
   * 
   *
   *Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modifica-
   * tion, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of  source code must  retain the above copyright  notice,
   *this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *this list of conditions and the following disclaimer in the documentation
   *and/or other materials provided with the distribution.
   *
   * 3. The end-user documentation included with the redistribution, if any, must
   *include  the following  acknowledgment:  "This product includes  software
   *developed  by the  Apache Software Foundation  (http://www.apache.org/)."
   *Alternately, this  acknowledgment may  appear in the software itself,  if
   *and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
   *endorse  or promote  products derived  from this  software without  prior
   *written permission. For written permission, please contact
   *[EMAIL PROTECTED]
   *
   * 5. Products  derived from this software may not  be called "Apache", nor may
   *"Apache" appear  in their name,  without prior written permission  of the
   *Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software  consists of voluntary contributions made  by many individuals
   * on  behalf of the Apache Software  Foundation.  For more  information on the
   * Apache Software Foundation, please see .
   *
   */
  
  package org.apache.log4j.varia;
  
  import org.apache.log4j.chainsaw.rule.ExpressionRule;
  import org.apache.log4j.chainsaw.rule.Rule;
  import org.apache.log4j.spi.Filter;
  import org.apache.log4j.spi.LoggingEvent;
  
  
  /**
   *A filter supporting complex expressions - supports both infix and postfix 
expressions 
   *(infix expressions must first be converted to postfix prior to processing).
   *
   *See org.apache.log4j.chainsaw.LoggingEventFieldResolver.java 
   *for the correct names for logging event fields used when building expressions.
   *
   *See  package for a list of available rules 
which can
   *be applied using the expression syntax.
   *
   *See org.apache.log4j.chainsaw.RuleFactory for the symbols used to 
   *activate the corresponding rules.
   *
   *NOTE:  Grouping using parentheses is supported - all tokens must be separated by 
spaces, and
   *operands which contain spaces are not yet supported.
   *
   *Example:
   *
   *In order to build a filter that displays all messages with infomsg-45 or 
infomsg-44 in the message,
   *as well as all messages with a level of WARN or higher, build an expression using 
   *th

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-10-27 Thread sdeboy
sdeboy  2003/10/27 00:22:15

  Modified:src/java/org/apache/log4j/chainsaw/rule NotEqualsRule.java
ExpressionRule.java LevelInequalityRule.java
NotRule.java OrRule.java AndRule.java
InequalityRule.java EqualsRule.java LikeRule.java
InFixToPostFix.java PartialTextMatchRule.java
   src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  Modified rules to make them accessible outside package, modified field resolver to 
throw runtime exception if an invalid field was requested.
  
  Revision  ChangesPath
  1.2   +2 -5  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/NotEqualsRule.java
  
  Index: NotEqualsRule.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/NotEqualsRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NotEqualsRule.java23 Oct 2003 09:18:12 -  1.1
  +++ NotEqualsRule.java27 Oct 2003 08:22:15 -  1.2
  @@ -55,7 +55,7 @@
   import java.util.Stack;
   
   /**
  - * A Rule class implementing not equals against two strings (case sensitive).
  + * A Rule class implementing not equals against two strings.
* 
* @author Scott Deboy <[EMAIL PROTECTED]>
*/
  @@ -69,20 +69,17 @@
   this.secondParam = secondParam;
 }
   
  -  static Rule getRule(Stack stack) {
  +  public static Rule getRule(Stack stack) {
   String p1 = stack.pop().toString();
   String p2 = stack.pop().toString();
  -System.out.println("get not equals op " + p1 + ".." + p2);
   
   return new NotEqualsRule(p1, p2);
 }
   
 public boolean evaluate(LoggingEvent event) {
   String p2 = resolver.getValue(secondParam, event).toString();
  -System.out.println("not equals op " + firstParam + ".." + p2);
   
   boolean result = ((p2 != null) && !(p2.equals(firstParam)));
  -System.out.println("result is " + result);
   
   return result;
 }
  
  
  
  1.4   +13 -8 
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/ExpressionRule.java
  
  Index: ExpressionRule.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/ExpressionRule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExpressionRule.java   24 Oct 2003 08:04:03 -  1.3
  +++ ExpressionRule.java   27 Oct 2003 08:22:15 -  1.4
  @@ -59,8 +59,13 @@
* A Rule class supporting both infix and postfix expressions, accepting any rule 
which 
* is supported by the RuleFactory.
* 
  - * NOTE: parsing is supported through the use of StringTokenizer, 
which means 
  - * all tokens in the expression must be separated by spaces. 
  + * NOTE: parsing is supported through the use of StringTokenizer, 
which 
  + * implies two limitations:
  + * 1: all tokens in the expression must be separated by spaces,
  + * 2: operands which contain spaces in the value being evaluated are not supported
  + *(for example, attempting to perform 'msg == some other msg' will fail, since 
'some other msg'
  + *will be parsed as individual tokens in the expression instead of a single 
token (this is 
  + *the next planned fix). 
* 
* @author Scott Deboy <[EMAIL PROTECTED]>
*/
  @@ -76,7 +81,7 @@
   this.rule = rule;
 }
   
  -  static Rule getRule(String expression, boolean isPostFix) {
  +  public static Rule getRule(String expression, boolean isPostFix) {
   if (!isPostFix) {
 expression = convertor.convert(expression);
   }
  @@ -97,7 +102,6 @@
 class PostFixExpressionCompiler {
   
   Rule compileExpression(String expression) {
  -  System.out.println("compiling expression: " + expression);
   
 Stack stack = new Stack();
 Enumeration tokenizer = new StringTokenizer(expression);
  @@ -109,16 +113,17 @@
   //if a symbol is found, pop 2 off the stack, evaluate and push the result 
   if (RuleFactory.isRule(nextToken)) {
 Rule r = (Rule) RuleFactory.getRule(nextToken, stack);
  -  System.out.println("pushing rule " + r);
 stack.push(r);
   } else {
  -  System.out.println("pushing token " + nextToken);
   
 //variables or constants are pushed onto the stack
 stack.push(nextToken);
   }
 }
  -
  -  return (Rule)stack.pop();
  +  if (!(stack.peek() instanceof Rule)) {
  +  throw new RuntimeException("invalid expression: " + expression);
  +  } else {
  +return (Rule)stack.pop();
  +  }
   }
   }
  
  
  
  1.3   +1 -4  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/LevelInequalityRule.java
  
  Index: LevelIn

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-10-25 Thread sdeboy
sdeboy  2003/10/25 00:52:55

  Modified:src/java/org/apache/log4j/chainsaw/rule
LevelInequalityRule.java RuleTest.java
InequalityRule.java
   src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  Corrected inequality rule logic errors, added example ruletest expression 
demonstrating regular expressions, inequality and access of MDC entries in the 
expressions.
  
  Revision  ChangesPath
  1.2   +70 -64
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/LevelInequalityRule.java
  
  Index: LevelInequalityRule.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/LevelInequalityRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LevelInequalityRule.java  24 Oct 2003 08:04:03 -  1.1
  +++ LevelInequalityRule.java  25 Oct 2003 07:52:55 -  1.2
  @@ -49,78 +49,84 @@
   
   package org.apache.log4j.chainsaw.rule;
   
  +import org.apache.log4j.Level;
  +import org.apache.log4j.UtilLoggingLevel;
  +import org.apache.log4j.chainsaw.LoggingEventFieldResolver;
  +import org.apache.log4j.spi.LoggingEvent;
  +
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.List;
   import java.util.Stack;
   
  -import org.apache.log4j.Level;
  -import org.apache.log4j.UtilLoggingLevel;
  -import org.apache.log4j.chainsaw.LoggingEventFieldResolver;
  -import org.apache.log4j.spi.LoggingEvent;
  +
   /**
* A Rule class implementing inequality evaluation for Levels (log4j and 
util.logging) using the toInt method.
* 
* @author Scott Deboy <[EMAIL PROTECTED]>
*/
  -
   class LevelInequalityRule extends AbstractRule {
  -LoggingEventFieldResolver resolver = LoggingEventFieldResolver.getInstance();
  -
  - Level levelFirstParam;
  -  String levelSecondParam;
  -  List utilList = new LinkedList();
  -  List levelList = new LinkedList();
  -  String inequalitySymbol;
  -
  -  private LevelInequalityRule(String inequalitySymbol, String levelFirstParam, 
String levelSecondParam) {
  -  levelList.add(Level.FATAL.toString());
  -  levelList.add(Level.ERROR.toString());
  -  levelList.add(Level.WARN.toString());
  -  levelList.add(Level.INFO.toString());
  -  levelList.add(Level.DEBUG.toString());
  -
  -  Iterator iter = UtilLoggingLevel.getAllPossibleLevels().iterator();
  -  while (iter.hasNext()) {
  -  utilList.add(((UtilLoggingLevel)iter.next()).toString());
  -  }
  -
  -if (levelList.contains(levelFirstParam)) {
  -this.levelFirstParam = Level.toLevel(levelFirstParam);
  -} else {
  -this.levelFirstParam = UtilLoggingLevel.toLevel(levelFirstParam);
  -}
  -this.inequalitySymbol = inequalitySymbol;
  -this.levelSecondParam = levelSecondParam;
  -  }
  -
  -  static Rule getRule(String inequalitySymbol, Stack stack) {
  -  String p1 = stack.pop().toString();
  -  String p2 = stack.pop().toString();
  -  return new LevelInequalityRule(inequalitySymbol, p1, p2);
  -  }
  -  
  -  public boolean evaluate(LoggingEvent event) {
  -//use the type of the first level to access the static toLevel method on 
the second param
  -Level level2 = levelFirstParam.toLevel(resolver.getValue(levelSecondParam, 
event).toString());
  -System.out.println("lessthan level op " + levelFirstParam + ".." + level2);
  -
  -boolean result = false;
  -int first = levelFirstParam.toInt();
  -int second = level2.toInt();
  -
  -if ("<".equals(inequalitySymbol)) {
  -result = first < second;
  -} else if (">".equals(inequalitySymbol)) {
  -result = first > second;
  -} else if ("<=".equals(inequalitySymbol)){
  -result = first <= second;
  -} else if (">=".equals(inequalitySymbol)) {
  -result = first >= second;
  -}
  -System.out.println("result is " + result);
  -
  -return result;
  -  }
  -  
  -  }
  \ No newline at end of file
  +  LoggingEventFieldResolver resolver = LoggingEventFieldResolver.getInstance();
  +  Level levelFirstParam;
  +  String levelSecondParam;
  +  List utilList = new LinkedList();
  +  List levelList = new LinkedList();
  +  String inequalitySymbol;
  +
  +  private LevelInequalityRule(
  +String inequalitySymbol, String levelFirstParam, String levelSecondParam) {
  +levelList.add(Level.FATAL.toString());
  +levelList.add(Level.ERROR.toString());
  +levelList.add(Level.WARN.toString());
  +levelList.add(Level.INFO.toString());
  +levelList.add(Level.DEBUG.toString());
  +
  +Iterator iter = UtilLoggingLevel.getAllPos

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-10-23 Thread sdeboy
sdeboy  2003/10/23 02:32:23

  Modified:src/java/org/apache/log4j/chainsaw/rule ExpressionRule.java
   src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  Simplified expressionrule, referencing constants in fieldresolver
  
  Revision  ChangesPath
  1.2   +6 -37 
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/ExpressionRule.java
  
  Index: ExpressionRule.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/ExpressionRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExpressionRule.java   23 Oct 2003 09:18:12 -  1.1
  +++ ExpressionRule.java   23 Oct 2003 09:32:23 -  1.2
  @@ -52,9 +52,6 @@
   import org.apache.log4j.spi.LoggingEvent;
   
   import java.util.Enumeration;
  -import java.util.Iterator;
  -import java.util.LinkedList;
  -import java.util.List;
   import java.util.Stack;
   import java.util.StringTokenizer;
   
  @@ -72,11 +69,11 @@
 private static InFixToPostFix convertor = new InFixToPostFix();
 private static PostFixExpressionCompiler compiler =
   new PostFixExpressionCompiler();
  -  List list = null;
  +  Rule rule = null;
 Stack stack = new Stack();
   
  -  private ExpressionRule(List list) {
  -this.list = list;
  +  private ExpressionRule(Rule rule) {
  +this.rule = rule;
 }
   
 static Rule getRule(String expression, boolean isPostFix) {
  @@ -88,30 +85,7 @@
 }
   
 public boolean evaluate(LoggingEvent event) {
  -stack.clear();
  -
  -boolean result = false;
  -Iterator iter = list.iterator();
  -
  -while (iter.hasNext()) {
  -  //examine each token
  -  Object nextItem = iter.next();
  -
  -  //if a symbol is found, pop 2 off the stack, evaluate and push the result 
  -  if (nextItem instanceof Rule) {
  -Rule r = (Rule) nextItem;
  -stack.push(new Boolean(r.evaluate(event)));
  -  } else {
  -//variables or constants are pushed onto the stack
  -stack.push(nextItem);
  -  }
  -}
  -
  -if (stack.size() > 0) {
  -  result = new Boolean(stack.pop().toString()).booleanValue();
  -}
  -
  -return result;
  +  return rule.evaluate(event);
 }
   }
   
  @@ -122,10 +96,9 @@
*/
   class PostFixExpressionCompiler {
   
  -  List compileExpression(String expression) {
  +  Rule compileExpression(String expression) {
   System.out.println("compiling expression: " + expression);
   
  -List list = new LinkedList();
   Stack stack = new Stack();
   Enumeration tokenizer = new StringTokenizer(expression);
   
  @@ -146,10 +119,6 @@
 }
   }
   
  -while (!stack.isEmpty()) {
  -  list.add(stack.pop());
  -}
  -
  -return list;
  +return (Rule)stack.pop();
 }
   }
  
  
  
  1.5   +54 -25
jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java
  
  Index: LoggingEventFieldResolver.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LoggingEventFieldResolver.java17 Sep 2003 06:24:38 -  1.4
  +++ LoggingEventFieldResolver.java23 Oct 2003 09:32:23 -  1.5
  @@ -49,6 +49,9 @@
   
   package org.apache.log4j.chainsaw;
   
  +import java.util.ArrayList;
  +import java.util.List;
  +
   import org.apache.log4j.spi.LoggingEvent;
   
   
  @@ -93,62 +96,88 @@
*
*/
   public final class LoggingEventFieldResolver {
  +  private static final List keywordList = new ArrayList();
  +
  +  private static final String LOGGER_FIELD = "LOGGER";
  +  private static final String LEVEL_FIELD = "LEVEL";
  +  private static final String CLASS_FIELD = "CLASS";
  +  private static final String FILE_FIELD = "FILE";
  +  private static final String LINE_FIELD = "LINE";
  +  private static final String METHOD_FIELD = "METHOD";
  +  private static final String MSG_FIELD = "MSG";
  +  private static final String NDC_FIELD = "NDC";
  +  private static final String EXCEPTION_FIELD = "EXCEPTION";
  +  private static final String TIMESTAMP_FIELD = "TIMESTAMP";
  +  private static final String THREAD_FIELD = "THREAD";
  +  private static final String MDC_FIELD = "MDC.";
  +  private static final String PROP_FIELD = "PROP.";
  +  
  +  private static final String EMPTY_STRING = "";
  +
 private static final LoggingEventFieldResolver resolver =
   new LoggingEventFieldResolver();
  -
  +  
 private LoggingEventFieldResolver() {
  +keywordList.add(LOGGER_FIELD);
  +keywordList.add(LEVEL_FIELD);
  +keywordList.add(CLASS_FIELD);
  +keywordList.add(FILE_FIELD);
  +keywordList.add(LINE_FIELD);
  +  

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-09-16 Thread sdeboy
sdeboy  2003/09/16 23:24:38

  Modified:src/java/org/apache/log4j/chainsaw/rule RuleTest.java
   src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  Updated loggingeventfieldresolver and ruletest to actually process logging events.
  
  NOTE: spaces in event fields aren't being handled correctly
  
  Revision  ChangesPath
  1.4   +81 -83
jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/RuleTest.java
  
  Index: RuleTest.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/rule/RuleTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RuleTest.java 15 Sep 2003 02:20:26 -  1.3
  +++ RuleTest.java 17 Sep 2003 06:24:38 -  1.4
  @@ -52,9 +52,10 @@
   import java.awt.BorderLayout;
   import java.awt.GridLayout;
   import java.awt.event.ActionEvent;
  -
  +import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   import java.util.Stack;
  @@ -66,11 +67,14 @@
   import javax.swing.JFrame;
   import javax.swing.JLabel;
   import javax.swing.JPanel;
  -import javax.swing.JTable;
  +import javax.swing.JTextArea;
   import javax.swing.JTextField;
   import javax.swing.WindowConstants;
  -import javax.swing.table.DefaultTableModel;
  -import javax.swing.table.TableModel;
  +
  +import org.apache.log4j.Level;
  +import org.apache.log4j.Logger;
  +import org.apache.log4j.chainsaw.LoggingEventFieldResolver;
  +import org.apache.log4j.spi.LoggingEvent;
   
   
   public class RuleTest extends JFrame {
  @@ -86,14 +90,40 @@
  * @author Scott Deboy <[EMAIL PROTECTED]>
  *
  */
  -  private final Vector data = new Vector();
  -  private final Vector colnames = new Vector();
  -
 public RuleTest(String booleanPostFixExpression, String inFixExpression) {
   setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   getContentPane().setLayout(new BorderLayout());
   
  -JPanel fieldPanel = new JPanel(new GridLayout(8, 1));
  + final LoggingEventFieldResolver resolver = 
LoggingEventFieldResolver.getInstance();
  +
  +final List eventList = new ArrayList();
  +
  +eventList.add(new LoggingEvent("org.apache.log4j.chainsaw", 
Logger.getLogger("logger1"), System.currentTimeMillis(), Level.DEBUG, "message1", new 
Exception("test")));
  + eventList.add(new LoggingEvent("org.apache.log4j.chainsaw", 
Logger.getLogger("logger2"), System.currentTimeMillis(), Level.DEBUG, "message2", new 
Exception("test2")));
  + eventList.add(new LoggingEvent("org.apache.log4j.net", 
Logger.getLogger("logger3"), System.currentTimeMillis(), Level.DEBUG, "message3", new 
Exception("test3")));
  + eventList.add(new LoggingEvent("org.apache.log4j.chainsaw", 
Logger.getLogger("logger4"), System.currentTimeMillis(), Level.WARN, "message4", new 
Exception("test4")));
  +
  +JPanel fieldPanel = new JPanel(new GridLayout(12, 1));
  +
  + fieldPanel.add(
  +   new JLabel("Enter infix expression to convert to postfix: "));
  +
  + final JTextField inFixTextField = new JTextField(inFixExpression);
  + fieldPanel.add(inFixTextField);
  +
  + JButton inFixButton = new JButton("Convert InFix to PostFix");
  + fieldPanel.add(inFixButton);
  +
  + final JTextField inFixResult = new JTextField();
  + fieldPanel.add(inFixResult);
  + inFixButton.addActionListener(
  +   new AbstractAction() {
  + public void actionPerformed(ActionEvent evt) {
  +   InFixToPostFix inFixConverter = new InFixToPostFix();
  +   inFixResult.setText(
  + inFixConverter.convert(inFixTextField.getText()));
  + }
  +   });
   
   fieldPanel.add(
 new JLabel("Enter boolean postfix expression to evaluate: "));
  @@ -118,64 +148,56 @@
   }
 });
   
  -fieldPanel.add(
  -  new JLabel("Enter infix expression to convert to postfix: "));
   
  -final JTextField inFixTextField = new JTextField(inFixExpression);
  -fieldPanel.add(inFixTextField);
  + JPanel resultsPanel = new JPanel(new BorderLayout());
   
  -JButton inFixButton = new JButton("Convert InFix to PostFix");
  -fieldPanel.add(inFixButton);
  + JButton resultsButton = new JButton("Replace fields (processes expression in 
'Enter boolean postfix expression to evaluate' box)");
  + resultsPanel.add(resultsButton, BorderLayout.NORTH);
   
  -final JTextField inFixResult = new JTextField();
  -fieldPanel.add(inFixResult);
  -inFixButton.addActionListener(
  -  new AbstractAction() {
  -public void actionPerformed(ActionEvent evt) {
  -  InFixToPostFix inFixConverter = new InFixToPostFix();
  -  inFixResult.setText(
  -  

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-09-16 Thread sdeboy
sdeboy  2003/09/16 21:03:23

  Modified:src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  Updated return type to Object and documented specific return types for each field
  
  Revision  ChangesPath
  1.3   +25 -29
jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java
  
  Index: LoggingEventFieldResolver.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LoggingEventFieldResolver.java16 Sep 2003 05:32:23 -  1.2
  +++ LoggingEventFieldResolver.java17 Sep 2003 04:03:22 -  1.3
  @@ -58,25 +58,28 @@
*
* This class defines a grammar used in creation of an expression-based Rule.
*
  - * The only available method is getField(String fieldName, LoggingEvent event).
  + * The only available method is Object getField(String fieldName, LoggingEvent 
event).
*
* Here is a description of the mapping of field names in the grammar
  - * to fields on the logging event:
  + * to fields on the logging event.  While the getField method returns an Object, 
the 
  + * individual types returned per field are described here: 
*
  - * Field NameField value (String representation
  - * LOGGERcategory name (logger)
  - * LEVEL level
  - * CLASS locationInformation's class name
  - * FILE  locationInformation's file name
  - * LINE  locationInformation's line number
  - * METHODlocationInformation's method name
  - * MSG   message
  - * NDC   NDC
  - * EXCEPTION throwable string representation
  - * TIMESTAMP timestamp
  - * THREADthread
  - * MDC.keyName   entry in the MDC hashtable mapped to key 'keyName'
  - * PROP.keyName  entry in the Property hashtable mapped to the key 
'keyName'
  + * Field NameField value (String representation  Return 
type
  + * LOGGERcategory name (logger) 
 String
  + * LEVEL level  
 Level
  + * CLASS locationInformation's class nameString
  + * FILE  locationInformation's file name String
  + * LINE  locationInformation's line number   String
  + * METHODlocationInformation's method name   String
  + * MSG   message
 Object
  + * NDC   NDC
 String
  + * EXCEPTION throwable string representation 
ThrowableInformation
  + * TIMESTAMP timestamp  
 Long
  + * THREADthread 
 String
  + * MDC.keyName   entry in the MDC hashtable  Object
  + *mapped to key 'keyName'   
 
  + * PROP.keyName  entry in the Property hashtable String
  + *mapped to the key 'keyName'   
 
   
* NOTE:  the values for the 'keyName' portion of the MDC and PROP mappings must
* be an exact match to the key in the hashTable (case sensitive).
  @@ -99,7 +102,7 @@
   return resolver;
 }
   
  -  public String getValue(String fieldName, LoggingEvent event) {
  +  public Object getValue(String fieldName, LoggingEvent event) {
   if (fieldName == null) {
 return "";
   }
  @@ -109,7 +112,7 @@
   if ("LOGGER".equals(fieldName)) {
 return event.getLoggerName();
   } else if ("LEVEL".equals(fieldName)) {
  -  return event.getLevel().toString();
  +  return event.getLevel();
   } else if ("CLASS".equals(fieldName)) {
 return event.getLocationInformation().getClassName();
   } else if ("FILE".equals(fieldName)) {
  @@ -119,24 +122,17 @@
   } else if ("METHOD".equals(fieldName)) {
 return event.getLocationInformation().getMethodName();
   } else if ("MSG".equals(fieldName)) {
  -  return event.getMessage().toString();
  +  return event.getMessage();
   } else if ("NDC".equals(fieldName)) {
 return event.getNDC();
   } else if ("EXCEPTION".equals(fieldName)) {
  -  StringBuffer buf = new StringBuffer();
  -
  -  for (int i = 0; i 

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-09-15 Thread sdeboy
sdeboy  2003/09/15 22:32:23

  Modified:src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  Updated comments and added line separator for exception output
  
  Revision  ChangesPath
  1.2   +82 -70
jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java
  
  Index: LoggingEventFieldResolver.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoggingEventFieldResolver.java16 Sep 2003 05:18:50 -  1.1
  +++ LoggingEventFieldResolver.java16 Sep 2003 05:32:23 -  1.2
  @@ -51,84 +51,96 @@
   
   import org.apache.log4j.spi.LoggingEvent;
   
  +
   /**
  - * A singleton helper utility which accepts a field name and a LoggingEvent and 
returns the 
  + * A singleton helper utility which accepts a field name and a LoggingEvent and 
returns the
* String value of that field.
  - * 
  + *
* This class defines a grammar used in creation of an expression-based Rule.
  - * 
  - * Here is a description of the mapping of field names in the grammar 
  + *
  + * The only available method is getField(String fieldName, LoggingEvent event).
  + *
  + * Here is a description of the mapping of field names in the grammar
* to fields on the logging event:
  - * 
  - * Field NameField value (String representation
  - * LOGGERcategory name (logger)
  - * LEVEL level
  - * CLASS locationInformation's class name
  - * FILE  locationInformation's file name
  - * LINE  locationInformation's line number
  - * METHODlocationInformation's method name
  - * MSG   message
  - * NDC   NDC
  - * EXCEPTION throwable string representation
  - * TIMESTAMP timestamp
  - * THREADthread
  - * MDC.keyName   entry in the MDC hashtable mapped to key 'keyName'
  - * PROP.keyName  entry in the Property hashtable mapped to the key 
'keyName'
  - * 
  - * If the passed-in field is null or does not match an entry in the above-described 
  + *
  + * Field NameField value (String representation
  + * LOGGERcategory name (logger)
  + * LEVEL level
  + * CLASS locationInformation's class name
  + * FILE  locationInformation's file name
  + * LINE  locationInformation's line number
  + * METHODlocationInformation's method name
  + * MSG   message
  + * NDC   NDC
  + * EXCEPTION throwable string representation
  + * TIMESTAMP timestamp
  + * THREADthread
  + * MDC.keyName   entry in the MDC hashtable mapped to key 'keyName'
  + * PROP.keyName  entry in the Property hashtable mapped to the key 
'keyName'
  +
  + * NOTE:  the values for the 'keyName' portion of the MDC and PROP mappings must
  + * be an exact match to the key in the hashTable (case sensitive).
  + *
  + * If the passed-in field is null or does not match an entry in the above-described
* mapping, an empty string is returned.
  - * 
  + *
* @author Scott Deboy <[EMAIL PROTECTED]>
* @author Paul Smith <[EMAIL PROTECTED]>
*
*/
  -
   public final class LoggingEventFieldResolver {
  - private static final LoggingEventFieldResolver resolver = new 
LoggingEventFieldResolver();
  - 
  - private LoggingEventFieldResolver(){}
  - 
  - public static LoggingEventFieldResolver getInstance() {
  - return resolver;
  - }
  -
  - public String getValue(String fieldName, LoggingEvent event) {
  - if (fieldName == null) {
  - return "";
  - }
  - String lowerProp = fieldName.toUpperCase();
  - if ("LOGGER".equals(fieldName)) {
  - return event.getLoggerName();
  - } else if ("LEVEL".equals(fieldName)) {
  - return event.getLevel().toString();
  - } else if ("CLASS".equals(fieldName)) {
  - return event.getLocationInformation().getClassName();
  - } else if ("FILE".equals(fieldName)) {
  - return event.getLocationInformation().getFileName();
  - } else if ("LINE".equals(fieldName)) {
  - return event.getLocationInformation().getLineNumber();
  - } else if ("METHOD".equals(fieldName)) {
  - return event.getLocationInformation().getMethodName();
  - } else if ("MSG".e

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggingEventFieldResolver.java

2003-09-15 Thread sdeboy
sdeboy  2003/09/15 22:18:50

  Added:   src/java/org/apache/log4j/chainsaw
LoggingEventFieldResolver.java
  Log:
  Added helper class which will be used in the evaluation of postfix expressions.
  
  Revision  ChangesPath
  1.1  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggingEventFieldResolver.java
  
  Index: LoggingEventFieldResolver.java
  ===
  /*
   * 
   *   The Apache Software License, Version 1.1
   * 
   *
   *Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modifica-
   * tion, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of  source code must  retain the above copyright  notice,
   *this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *this list of conditions and the following disclaimer in the documentation
   *and/or other materials provided with the distribution.
   *
   * 3. The end-user documentation included with the redistribution, if any, must
   *include  the following  acknowledgment:  "This product includes  software
   *developed  by the  Apache Software Foundation  (http://www.apache.org/)."
   *Alternately, this  acknowledgment may  appear in the software itself,  if
   *and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
   *endorse  or promote  products derived  from this  software without  prior
   *written permission. For written permission, please contact
   *[EMAIL PROTECTED]
   *
   * 5. Products  derived from this software may not  be called "Apache", nor may
   *"Apache" appear  in their name,  without prior written permission  of the
   *Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software  consists of voluntary contributions made  by many individuals
   * on  behalf of the Apache Software  Foundation.  For more  information on the
   * Apache Software Foundation, please see .
   *
   */
  
  package org.apache.log4j.chainsaw;
  
  import org.apache.log4j.spi.LoggingEvent;
  
  /**
   * A singleton helper utility which accepts a field name and a LoggingEvent and 
returns the 
   * String value of that field.
   * 
   * This class defines a grammar used in creation of an expression-based Rule.
   * 
   * Here is a description of the mapping of field names in the grammar 
   * to fields on the logging event:
   * 
   * Field Name Field value (String representation
   * LOGGER category name (logger)
   * LEVEL  level
   * CLASS  locationInformation's class name
   * FILE   locationInformation's file name
   * LINE   locationInformation's line number
   * METHOD locationInformation's method name
   * MSGmessage
   * NDCNDC
   * EXCEPTION  throwable string representation
   * TIMESTAMP  timestamp
   * THREAD thread
   * MDC.keyNameentry in the MDC hashtable mapped to key 'keyName'
   * PROP.keyName   entry in the Property hashtable mapped to the key 
'keyName'
   * 
   * If the passed-in field is null or does not match an entry in the above-described 
   * mapping, an empty string is returned.
   * 
   * @author Scott Deboy <[EMAIL PROTECTED]>
   * @author Paul Smith <[EMAIL PROTECTED]>
   *
   */
  
  public final class LoggingEventFieldResolver {
private static final LoggingEventFieldResolver resolver = new 
LoggingEventFieldResolver();

private LoggingEventFieldResolver(){}

public