ceki        2003/09/11 10:25:24

  Modified:    docs     .cvsignore
               src/java/org/apache/joran/action RootLoggerAction.java
                        LoggerAction.java LayoutAction.java
                        ActionConst.java AppenderRefAction.java
               tests/src/java/org/apache/joran JoranParserTest.java
  Log:
  
  Bug fixes
  
  Revision  Changes    Path
  1.4       +3 -0      jakarta-log4j/docs/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/docs/.cvsignore,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- .cvsignore        11 Sep 2003 17:00:41 -0000      1.3
  +++ .cvsignore        11 Sep 2003 17:25:24 -0000      1.4
  @@ -5,3 +5,6 @@
   contributors.html
   plan.html
   download.html
  +earlier.html
  +history.html
  +index.html
  \ No newline at end of file
  
  
  
  1.2       +73 -4     
jakarta-log4j/src/java/org/apache/joran/action/RootLoggerAction.java
  
  Index: RootLoggerAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/joran/action/RootLoggerAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RootLoggerAction.java     2 Sep 2003 18:36:13 -0000       1.1
  +++ RootLoggerAction.java     11 Sep 2003 17:25:24 -0000      1.2
  @@ -1,3 +1,52 @@
  +/*
  + * ============================================================================
  + *                   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 <http://www.apache.org/>.
  + *
  + */
  +
   package org.apache.joran.action;
   
   import org.apache.joran.ExecutionContext;
  @@ -7,24 +56,44 @@
   
   import org.w3c.dom.Element;
   
  +
   public class RootLoggerAction extends Action {
  -     
     static final String NAME_ATTR = "name";
     static final String CLASS_ATTR = "class";
     static final String ADDITIVITY_ATTR = "additivity";
     static final String EMPTY_STR = "";
     static final Class[] ONE_STRING_PARAM = new Class[] { String.class };
     Logger logger = Logger.getLogger(RootLoggerAction.class);
  +  Logger root;
   
     public void begin(ExecutionContext ec, Element loggerElement) {
  +    inError = false;
  +    logger.debug("In begin method");
   
  -             logger.debug("In begin method");
  -             
       LoggerRepository repository = (LoggerRepository) ec.getObject(0);
  -    Logger root = repository.getRootLogger();   
  +    root = repository.getRootLogger();
  +
  +    logger.debug("Pushing root logger on stack");
  +    ec.pushObject(root);
     }
   
     public void end(ExecutionContext ec, Element e) {
  +    logger.debug("end() called.");
  +
  +    if (inError) {
  +      return;
  +    }
  +
  +    Object o = ec.peekObject();
  +
  +    if (o != root) {
  +      logger.warn(
  +        "The object on the top the of the stack is not the root logger");
  +        logger.warn("It is: "+o);
  +    } else {
  +      logger.debug("Removing root logger from stack.");
  +      ec.popObject();
  +    }
     }
   
     public void finish(ExecutionContext ec) {
  
  
  
  1.2       +9 -11     jakarta-log4j/src/java/org/apache/joran/action/LoggerAction.java
  
  Index: LoggerAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/joran/action/LoggerAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoggerAction.java 2 Sep 2003 18:36:13 -0000       1.1
  +++ LoggerAction.java 11 Sep 2003 17:25:24 -0000      1.2
  @@ -13,19 +13,17 @@
   
   public class LoggerAction extends Action {
        
  -  static final String NAME_ATTR = "name";
  -  static final String CLASS_ATTR = "class";
  -  static final String ADDITIVITY_ATTR = "additivity";
  -  static final String EMPTY_STR = "";
  -  static final Class[] ONE_STRING_PARAM = new Class[] { String.class };
     Logger logger = Logger.getLogger(LoggerAction.class);
   
     public void begin(ExecutionContext ec, Element loggerElement) {
  +     // Let us forget about previous errors (in this object)
  +     inError = false; 
  +     
       LoggerRepository repository = (LoggerRepository) ec.getObject(0);
   
       // Create a new org.apache.log4j.Category object from the <category> element.
  -    String loggerName = loggerElement.getAttribute(NAME_ATTR);
  -    if(loggerName == null || EMPTY_STR.equals(loggerName)) {
  +    String loggerName = loggerElement.getAttribute(ActionConst.NAME_ATTRIBUTE);
  +    if(loggerName == null || ActionConst.EMPTY_STR.equals(loggerName)) {
         inError = true;
                        String errorMsg = "No 'name' attribute in element "
                                +loggerElement.getTagName();
  @@ -38,9 +36,9 @@
   
       Logger l;
   
  -    String className = loggerElement.getAttribute(CLASS_ATTR);
  +    String className = loggerElement.getAttribute(ActionConst.CLASS_ATTRIBUTE);
   
  -    if (EMPTY_STR.equals(className)) {
  +    if (ActionConst.EMPTY_STR.equals(className)) {
         logger.debug("Retreiving an instance of org.apache.log4j.Logger.");
         l = repository.getLogger(loggerName);
       } else {
  @@ -49,7 +47,7 @@
         try {
           Class clazz = Loader.loadClass(className);
           Method getInstanceMethod =
  -          clazz.getMethod("getLogger", ONE_STRING_PARAM);
  +          clazz.getMethod("getLogger", ActionConst.ONE_STRING_PARAM);
           l = (Logger) getInstanceMethod.invoke(null, new Object[] { loggerName });
         } catch (Exception oops) {
           logger.error(
  @@ -63,7 +61,7 @@
   
       boolean additivity =
         OptionConverter.toBoolean(
  -        loggerElement.getAttribute(ADDITIVITY_ATTR),
  +        loggerElement.getAttribute(ActionConst.ADDITIVITY_ATTRIBUTE),
           true);
       logger.debug(
         "Setting [" + l.getName() + "] additivity to [" + additivity + "].");
  
  
  
  1.2       +3 -0      jakarta-log4j/src/java/org/apache/joran/action/LayoutAction.java
  
  Index: LayoutAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/joran/action/LayoutAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LayoutAction.java 11 Sep 2003 17:00:42 -0000      1.1
  +++ LayoutAction.java 11 Sep 2003 17:25:24 -0000      1.2
  @@ -69,6 +69,9 @@
      *
      */
     public void begin(ExecutionContext ec, Element appenderElement) {
  +             // Let us forget about previous errors (in this object)
  +             inError = false; 
  +
       String className =
         appenderElement.getAttribute(ActionConst.CLASS_ATTRIBUTE);
       try {
  
  
  
  1.2       +4 -2      jakarta-log4j/src/java/org/apache/joran/action/ActionConst.java
  
  Index: ActionConst.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/joran/action/ActionConst.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ActionConst.java  10 Sep 2003 16:28:19 -0000      1.1
  +++ ActionConst.java  11 Sep 2003 17:25:24 -0000      1.2
  @@ -15,12 +15,14 @@
        public static final String NAME_ATTRIBUTE = "name";
        public static final String VALUE_ATTRIBUTE = "value";
        public static final String CLASS_ATTRIBUTE = "class";
  -     
  +  public static final String ADDITIVITY_ATTRIBUTE = "additivity";
  +
   
        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 static final String APPENDER_BAG = "APPENDER_BAG";
        
   
  
  
  
  1.3       +12 -2     
jakarta-log4j/src/java/org/apache/joran/action/AppenderRefAction.java
  
  Index: AppenderRefAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/joran/action/AppenderRefAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AppenderRefAction.java    11 Sep 2003 17:00:42 -0000      1.2
  +++ AppenderRefAction.java    11 Sep 2003 17:25:24 -0000      1.3
  @@ -63,6 +63,9 @@
     static final Logger logger = Logger.getLogger(AppenderRefAction.class);
   
     public void begin(ExecutionContext ec, Element appenderRef) {
  +             // Let us forget about previous errors (in this object)
  +             inError = false; 
  +
       logger.debug("begin called");
   
       Object o = ec.peekObject();
  @@ -120,9 +123,16 @@
         return;
       }
   
  +
  +    if(appenderAttachable instanceof Logger) {
       logger.debug(
  -      "Attaching appender named [" + appenderName + "] to "
  -      + appenderAttachable);
  +      "Attaching appender named [" + appenderName + "] to logger named ["
  +      + ((Logger)appenderAttachable).getName() +"].");
  +    } else {
  +                     logger.debug(
  +                                      "Attaching appender named [" + appenderName + 
"] to "
  +                                      + appenderAttachable);
  +    }
       appenderAttachable.addAppender(appender);
     }
   
  
  
  
  1.3       +0 -1      
jakarta-log4j/tests/src/java/org/apache/joran/JoranParserTest.java
  
  Index: JoranParserTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/tests/src/java/org/apache/joran/JoranParserTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JoranParserTest.java      11 Sep 2003 17:00:42 -0000      1.2
  +++ JoranParserTest.java      11 Sep 2003 17:25:24 -0000      1.3
  @@ -106,7 +106,6 @@
                         rs.addRule(new Pattern("log4j:configuration/logger"), new 
LoggerAction());
                         rs.addRule(new Pattern("log4j:configuration/logger/level"), 
new LevelAction());
                         rs.addRule(new Pattern("log4j:configuration/root"), new 
RootLoggerAction());
  -                      rs.addRule(new Pattern("log4j:configuration/root"), new 
RootLoggerAction());
                   rs.addRule(new Pattern("log4j:configuration/logger/appender-ref"), 
new AppenderRefAction());
                   rs.addRule(new Pattern("log4j:configuration/root/appender-ref"), 
new AppenderRefAction());
                   rs.addRule(new Pattern("log4j:configuration/appender"), new 
AppenderAction());
  
  
  

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

Reply via email to