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 ce...@apache.org on 2004/05/28 18:39:52 UTC

cvs commit: logging-log4j/src/java/org/apache/log4j/pattern PropertiesPatternConverter.java

ceki        2004/05/28 09:39:52

  Modified:    src/java/org/apache/log4j/pattern
                        PropertiesPatternConverter.java
  Log:
  A bit more descriptive name.
  
  Revision  Changes    Path
  1.7       +37 -37    logging-log4j/src/java/org/apache/log4j/pattern/PropertiesPatternConverter.java
  
  Index: PropertiesPatternConverter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/pattern/PropertiesPatternConverter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PropertiesPatternConverter.java	28 May 2004 16:28:56 -0000	1.6
  +++ PropertiesPatternConverter.java	28 May 2004 16:39:52 -0000	1.7
  @@ -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.
  @@ -33,49 +33,49 @@
    *@since 1.3
    */
   public class PropertiesPatternConverter extends PatternConverter {
  +  
  +  String name;
  +  
  +  public StringBuffer convert(LoggingEvent event) {
   
  -    public StringBuffer convert(LoggingEvent event) {
  -
  -        StringBuffer buf = new StringBuffer(32);
  +    StringBuffer buf = new StringBuffer(32);
   
  -        /**
  -         * if there is no additional options, we output every single
  -         * Key/Value pair for the MDC in a similar format to Hashtable.toString()
  -         */
  -        if (option == null) {
  -            buf.append("{");
  +    // if there is no additional options, we output every single
  +    // Key/Value pair for the MDC in a similar format to Hashtable.toString()
  +    if (option == null) {
  +      buf.append("{");
   
  -            Set keySet = event.getPropertyKeySet();
  +      Set keySet = event.getPropertyKeySet();
   
  -            for (Iterator i = keySet.iterator(); i.hasNext();) {
  +      for (Iterator i = keySet.iterator(); i.hasNext();) {
  +        Object item = i.next();
  +        Object val = event.getProperty(item.toString());
  +        buf.append("{").append(item).append(",").append(val).append("}");
  +      }
   
  -                Object item = i.next();
  -                Object val = event.getProperty(item.toString());
  -                buf.append("{").append(item).append(",").append(val).append(
  -                    "}");
  -            }
  +      buf.append("}");
   
  -            buf.append("}");
  -
  -            return buf;
  -        }
  +      return buf;
  +    }
   
  -        /**
  -         * otherwise they just want a single key output
  -         */
  -        Object val = event.getProperty(option);
  +    // otherwise they just want a single key output
  +    Object val = event.getProperty(option);
   
  -        if (val != null) {
  +    if (val != null) {
  +      return buf.append(val);
  +    }
   
  -            return buf.append(val);
  -        }
  +    return buf;
  +  }
   
  -        return buf;
  -    }
  -    
  -    public String getName()
  -    {
  -        return "Property";
  +  public String getName() {
  +    if(name == null) {
  +      if(option != null) {
  +        name += "Property{"+option+"}";
  +      } else {
  +        name = "Properties";
  +      }
       }
  -    
  +    return name;
  +  }
   }
  
  
  

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