logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/src/java/org/apache/log4j/joran/action AppenderAction.java LevelAction.java ConversionRuleAction.java LayoutAction.java LoggerAction.java AppenderRefAction.java
Date Sat, 03 Apr 2004 14:19:58 GMT
ceki        2004/04/03 06:19:58

  Modified:    src/java/org/apache/log4j/joran/action AppenderAction.java
                        LevelAction.java ConversionRuleAction.java
                        LayoutAction.java LoggerAction.java
                        AppenderRefAction.java
  Log:
  
  Parsing errors are now collected in ErrorItem objects instead of simple Strings.
  
  Revision  Changes    Path
  1.6       +12 -8     logging-log4j/src/java/org/apache/log4j/joran/action/AppenderAction.java
  
  Index: AppenderAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/AppenderAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AppenderAction.java	31 Mar 2004 13:13:15 -0000	1.5
  +++ AppenderAction.java	3 Apr 2004 14:19:58 -0000	1.6
  @@ -1,21 +1,21 @@
   /*
    * Copyright 1999,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  -
   package org.apache.log4j.joran.action;
   
  +import org.apache.joran.ErrorItem;
   import org.apache.joran.ExecutionContext;
   import org.apache.joran.action.Action;
   import org.apache.joran.helper.Option;
  @@ -26,6 +26,7 @@
   import org.apache.log4j.spi.OptionHandler;
   
   import org.xml.sax.Attributes;
  +
   import java.util.HashMap;
   
   
  @@ -38,9 +39,9 @@
      *
      * The appender thus generated is placed in the ExecutionContext appender bag.
      */
  -  public void begin(ExecutionContext ec, String localName, Attributes attributes) {
  -    String className =
  -      attributes.getValue(CLASS_ATTRIBUTE);
  +  public void begin(
  +    ExecutionContext ec, String localName, Attributes attributes) {
  +    String className = attributes.getValue(CLASS_ATTRIBUTE);
   
       try {
         logger.debug(
  @@ -71,7 +72,10 @@
         inError = true;
         logger.error(
           "Could not create an Appender. Reported error follows.", oops);
  -      ec.addError("Could not create appender of type " + className + "].");
  +      ec.addError(
  +        new ErrorItem(
  +          "Could not create appender of type " + className + "].",
  +          ec.getLocator()));
       }
     }
   
  
  
  
  1.6       +29 -25    logging-log4j/src/java/org/apache/log4j/joran/action/LevelAction.java
  
  Index: LevelAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/LevelAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LevelAction.java	31 Mar 2004 19:34:16 -0000	1.5
  +++ LevelAction.java	3 Apr 2004 14:19:58 -0000	1.6
  @@ -1,5 +1,6 @@
   package org.apache.log4j.joran.action;
   
  +import org.apache.joran.ErrorItem;
   import org.apache.joran.ExecutionContext;
   import org.apache.joran.action.Action;
   
  @@ -7,48 +8,51 @@
   import org.apache.log4j.Logger;
   import org.apache.log4j.helpers.Loader;
   import org.apache.log4j.helpers.OptionConverter;
  +
   import org.xml.sax.Attributes;
  -import java.lang.reflect.Method;
   
  -public class LevelAction extends Action {
  +import java.lang.reflect.Method;
   
  -  final static Logger logger = Logger.getLogger(LevelAction.class);
   
  +public class LevelAction extends Action {
  +  static final Logger logger = Logger.getLogger(LevelAction.class);
     static final String VALUE_ATTR = "value";
  -	static final String CLASS_ATTR = "class";
  +  static final String CLASS_ATTR = "class";
     static final String INHERITED = "INHERITED";
     static final String NULL = "NULL";
     static final String EMPTY_STR = "";
  -
     static final Class[] ONE_STRING_PARAM = new Class[] { String.class };
   
     public void begin(ExecutionContext ec, String name, Attributes attributes) {
  -    
  -		Object o = ec.peekObject();
  -		
  -		if(!(o instanceof Logger)) {
  -			logger.warn("Could not find a logger at the top of execution stack.");
  -			inError = true; 
  -			ec.addError("For element <level>, could not find a logger at the top of execution
stack.");
  -			return;
  -		}
  +    Object o = ec.peekObject();
  +
  +    if (!(o instanceof Logger)) {
  +      logger.warn("Could not find a logger at the top of execution stack.");
  +      inError = true;
  +      ec.addError(
  +        new ErrorItem(
  +          "For element <level>, could not find a logger at the top of execution stack.",
  +          ec.getLocator()));
  +
  +      return;
  +    }
  +
       Logger l = (Logger) o;
  -    
  +
       String loggerName = l.getName();
   
       String levelStr = attributes.getValue(VALUE_ATTR);
       logger.debug(
  -      "Encapsulating logger name is [" + loggerName + "], levelvalue is  [" 
  +      "Encapsulating logger name is [" + loggerName + "], levelvalue is  ["
         + levelStr + "].");
   
  -    if (INHERITED.equalsIgnoreCase(levelStr)
  -      || NULL.equalsIgnoreCase(levelStr)) {
  +    if (
  +      INHERITED.equalsIgnoreCase(levelStr) || NULL.equalsIgnoreCase(levelStr)) {
         l.setLevel(null);
       } else {
  -
         String className = attributes.getValue(CLASS_ATTR);
   
  -      if (className == null || EMPTY_STR.equals(className)) {
  +      if ((className == null) || EMPTY_STR.equals(className)) {
           l.setLevel(OptionConverter.toLevel(levelStr, Level.DEBUG));
         } else {
           logger.debug("Desired Level sub-class: [" + className + ']');
  @@ -61,18 +65,18 @@
             l.setLevel(pri);
           } catch (Exception oops) {
             logger.error(
  -            "Could not create level [" + levelStr + "]. Reported error follows.",
  -            oops);
  +            "Could not create level [" + levelStr
  +            + "]. Reported error follows.", oops);
  +
             return;
           }
         }
       }
   
       logger.debug(loggerName + " level set to " + l.getLevel());
  -
     }
  -  
  -  public  void finish(ExecutionContext ec) {
  +
  +  public void finish(ExecutionContext ec) {
     }
   
     public void end(ExecutionContext ec, String e) {
  
  
  
  1.6       +4 -3      logging-log4j/src/java/org/apache/log4j/joran/action/ConversionRuleAction.java
  
  Index: ConversionRuleAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/ConversionRuleAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConversionRuleAction.java	31 Mar 2004 13:13:15 -0000	1.5
  +++ ConversionRuleAction.java	3 Apr 2004 14:19:58 -0000	1.6
  @@ -16,6 +16,7 @@
   
   package org.apache.log4j.joran.action;
   
  +import org.apache.joran.ErrorItem;
   import org.apache.joran.ExecutionContext;
   import org.apache.joran.action.Action;
   import org.apache.joran.helper.Option;
  @@ -50,7 +51,7 @@
         inError = true;
         errorMsg = "No 'conversionWord' attribute in <conversionRule>";
         logger.warn(errorMsg);
  -      ec.addError(errorMsg);
  +      ec.addError(new ErrorItem(errorMsg, ec.getLocator()));
   
         return;
       }
  @@ -59,7 +60,7 @@
         inError = true;
         errorMsg = "No 'converterClass' attribute in <conversionRule>";
         logger.warn(errorMsg);
  -      ec.addError(errorMsg);
  +      ec.addError(new ErrorItem(errorMsg, ec.getLocator()));
   
         return;
       }
  @@ -79,7 +80,7 @@
         inError = true;
         errorMsg = "Could not add conversion rule to PatternLayout.";
         logger.error(errorMsg, oops);
  -      ec.addError(errorMsg);
  +      ec.addError(new ErrorItem(errorMsg, ec.getLocator()));
       }
     }
   
  
  
  
  1.6       +2 -1      logging-log4j/src/java/org/apache/log4j/joran/action/LayoutAction.java
  
  Index: LayoutAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/LayoutAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LayoutAction.java	31 Mar 2004 13:13:15 -0000	1.5
  +++ LayoutAction.java	3 Apr 2004 14:19:58 -0000	1.6
  @@ -16,6 +16,7 @@
   
   package org.apache.log4j.joran.action;
   
  +import org.apache.joran.ErrorItem;
   import org.apache.joran.ExecutionContext;
   import org.apache.joran.action.Action;
   
  @@ -56,7 +57,7 @@
         inError = true;
         logger.error(
           "Could not create an Layout. Reported error follows.", oops);
  -      ec.addError("Could not create layout of type " + className + "].");
  +      ec.addError(new ErrorItem("Could not create layout of type " + className + "].",
ec.getLocator()));
       }
     }
   
  
  
  
  1.5       +2 -1      logging-log4j/src/java/org/apache/log4j/joran/action/LoggerAction.java
  
  Index: LoggerAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/LoggerAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LoggerAction.java	31 Mar 2004 13:13:15 -0000	1.4
  +++ LoggerAction.java	3 Apr 2004 14:19:58 -0000	1.5
  @@ -16,6 +16,7 @@
   
   package org.apache.log4j.joran.action;
   
  +import org.apache.joran.ErrorItem;
   import org.apache.joran.ExecutionContext;
   import org.apache.joran.action.Action;
   import org.apache.joran.helper.Option;
  @@ -52,7 +53,7 @@
         String errorMsg = "No 'name' attribute in element " + name + line;
   
         logger.warn(errorMsg);
  -      ec.addError(errorMsg);
  +      ec.addError(new ErrorItem(errorMsg, ec.getLocator()));
   
         return;
       }
  
  
  
  1.7       +4 -3      logging-log4j/src/java/org/apache/log4j/joran/action/AppenderRefAction.java
  
  Index: AppenderRefAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/AppenderRefAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AppenderRefAction.java	31 Mar 2004 14:04:08 -0000	1.6
  +++ AppenderRefAction.java	3 Apr 2004 14:19:58 -0000	1.7
  @@ -16,6 +16,7 @@
   
   package org.apache.log4j.joran.action;
   
  +import org.apache.joran.ErrorItem;
   import org.apache.joran.ExecutionContext;
   import org.apache.joran.action.Action;
   import org.apache.joran.helper.Option;
  @@ -48,7 +49,7 @@
   
         logger.warn(errMsg);
         inError = true;
  -      ec.addError(errMsg);
  +      ec.addError(new ErrorItem(errMsg, ec.getLocator()));
   
         return;
       }
  @@ -63,7 +64,7 @@
   
         logger.warn(errMsg);
         inError = true;
  -      ec.addError(errMsg);
  +      ec.addError(new ErrorItem(errMsg, ec.getLocator()));
   
         return;
       }
  @@ -75,7 +76,7 @@
       if (appender == null) {
         logger.warn("Could not find an appender named [" + appenderName + "]");
         inError = true;
  -      ec.addError("Could not find an appender named [" + appenderName + "]");
  +      ec.addError(new ErrorItem("Could not find an appender named [" + appenderName + "]",
ec.getLocator()));
   
         return;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message