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/filter LevelMatchFilter.java
Date Tue, 04 Jan 2005 19:48:29 GMT
ceki        2005/01/04 11:48:29

  Modified:    src/java/org/apache/log4j/joran/action PluginAction.java
                        AppenderAction.java LevelAction.java
                        LayoutAction.java
               src/java/org/apache/log4j/filter LevelMatchFilter.java
  Log:
  Log4j components now see their owning LR.
  
  Revision  Changes    Path
  1.6       +3 -1      logging-log4j/src/java/org/apache/log4j/joran/action/PluginAction.java
  
  Index: PluginAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/PluginAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PluginAction.java	28 Dec 2004 16:33:57 -0000	1.5
  +++ PluginAction.java	4 Jan 2005 19:48:29 -0000	1.6
  @@ -45,8 +45,10 @@
         getLogger().debug(
           "About to instantiate plugin of type [" + className + "]");
   
  +      OptionConverter oc = new OptionConverter();
  +      oc.setLoggerRepository(this.repository);
         Object instance =
  -        OptionConverter.instantiateByClassName(
  +        oc.instantiateByClassName(
             className, org.apache.log4j.plugins.Plugin.class, null);
         plugin = (Plugin) instance;
   
  
  
  
  1.15      +8 -7      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AppenderAction.java	28 Dec 2004 23:08:12 -0000	1.14
  +++ AppenderAction.java	4 Jan 2005 19:48:29 -0000	1.15
  @@ -13,6 +13,7 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  +
   package org.apache.log4j.joran.action;
   
   import org.apache.joran.ExecutionContext;
  @@ -31,11 +32,9 @@
   
   
   public class AppenderAction extends Action {
  -  
     Appender appender;
  -
     private boolean inError = false;
  -  
  +
     /**
      * Instantiates an appender of the given class and sets its name.
      *
  @@ -49,14 +48,16 @@
         getLogger().debug(
           "About to instantiate appender of type [" + className + "]");
   
  +      OptionConverter oc = new OptionConverter();
  +      oc.setLoggerRepository(this.repository);
         Object instance =
  -        OptionConverter.instantiateByClassName(
  +        oc.instantiateByClassName(
             className, org.apache.log4j.Appender.class, null);
         appender = (Appender) instance;
   
         LoggerRepository repo = (LoggerRepository) ec.getObjectStack().get(0);
         appender.setLoggerRepository(repo);
  -      
  +
         String appenderName = attributes.getValue(NAME_ATTRIBUTE);
   
         if (Option.isEmpty(appenderName)) {
  @@ -71,6 +72,7 @@
         // created thus far.
         HashMap appenderBag =
           (HashMap) ec.getObjectMap().get(ActionConst.APPENDER_BAG);
  +
         // add the appender just created to the appender bag.
         appenderBag.put(appenderName, appender);
   
  @@ -81,8 +83,7 @@
         getLogger().error(
           "Could not create an Appender. Reported error follows.", oops);
         ec.addError(
  -        new ErrorItem(
  -          "Could not create appender of type " + className + "]."));
  +        new ErrorItem("Could not create appender of type " + className + "]."));
       }
     }
   
  
  
  
  1.12      +3 -1      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LevelAction.java	28 Dec 2004 16:28:59 -0000	1.11
  +++ LevelAction.java	4 Jan 2005 19:48:29 -0000	1.12
  @@ -54,7 +54,9 @@
         String className = attributes.getValue(CLASS_ATTR);
   
         if ((className == null) || EMPTY_STR.equals(className)) {
  -        l.setLevel(OptionConverter.toLevel(levelStr, Level.DEBUG));
  +        OptionConverter oc = new OptionConverter();
  +        oc.setLoggerRepository(this.repository);
  +        l.setLevel(oc.toLevel(levelStr, Level.DEBUG));
         } else {
           getLogger().debug("Desired Level sub-class: [" + className + ']');
   
  
  
  
  1.14      +22 -17    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- LayoutAction.java	28 Dec 2004 23:08:12 -0000	1.13
  +++ LayoutAction.java	4 Jan 2005 19:48:29 -0000	1.14
  @@ -1,12 +1,12 @@
   /*
    * 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.
  @@ -32,35 +32,38 @@
   public class LayoutAction extends Action {
     Layout layout;
     boolean inError = false;
  -  
  +
     /**
      * Instantiates an layout of the given class and sets its name.
      *
      */
     public void begin(ExecutionContext ec, String name, Attributes attributes) {
  -		// Let us forget about previous errors (in this object)
  -		inError = false; 
  +    // Let us forget about previous errors (in this object)
  +    inError = false;
   
  -    String className =
  -      attributes.getValue(CLASS_ATTRIBUTE);
  +    String className = attributes.getValue(CLASS_ATTRIBUTE);
       try {
  -      getLogger().debug("About to instantiate layout of type [" + className + "]");
  +      getLogger().debug(
  +        "About to instantiate layout of type [" + className + "]");
   
  +      OptionConverter oc = new OptionConverter();
  +      oc.setLoggerRepository(this.repository);
         Object instance =
  -        OptionConverter.instantiateByClassName(
  +        oc.instantiateByClassName(
             className, org.apache.log4j.Layout.class, null);
         layout = (Layout) instance;
  -      
  +
         LoggerRepository repo = (LoggerRepository) ec.getObjectStack().get(0);
         layout.setLoggerRepository(repo);
  -      
  +
         getLogger().debug("Pushing layout on top of the object stack.");
         ec.pushObject(layout);
       } catch (Exception oops) {
         inError = true;
         getLogger().error(
           "Could not create an Layout. Reported error follows.", oops);
  -      ec.addError(new ErrorItem("Could not create layout of type " + className + "]."));
  +      ec.addError(
  +        new ErrorItem("Could not create layout of type " + className + "]."));
       }
     }
   
  @@ -85,13 +88,15 @@
       } else {
         getLogger().debug("Popping layout from the object stack");
         ec.popObject();
  -      
  +
         try {
  -      	getLogger().debug("About to set the layout of the containing appender.");
  +        getLogger().debug(
  +          "About to set the layout of the containing appender.");
           Appender appender = (Appender) ec.peekObject();
           appender.setLayout(layout);
  -      } catch(Exception ex) {
  -      	getLogger().error("Could not set the layout for containing appender.", ex);
  +      } catch (Exception ex) {
  +        getLogger().error(
  +          "Could not set the layout for containing appender.", ex);
         }
       }
     }
  
  
  
  1.2       +3 -1      logging-log4j/src/java/org/apache/log4j/filter/LevelMatchFilter.java
  
  Index: LevelMatchFilter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/filter/LevelMatchFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LevelMatchFilter.java	3 Jan 2005 11:01:02 -0000	1.1
  +++ LevelMatchFilter.java	4 Jan 2005 19:48:29 -0000	1.2
  @@ -48,7 +48,9 @@
     Level levelToMatch;
   
     public void setLevelToMatch(String level) {
  -    levelToMatch = OptionConverter.toLevel(level, null);
  +    OptionConverter oc = new OptionConverter();
  +    oc.setLoggerRepository(this.repository);
  +    levelToMatch = oc.toLevel(level, null);
     }
   
     public String getLevelToMatch() {
  
  
  

---------------------------------------------------------------------
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