avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mirceat...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory FileTargetFactory.java ServletTargetFactory.java StreamTargetFactory.java
Date Wed, 19 Dec 2001 23:34:50 GMT
mirceatoma    01/12/19 15:34:50

  Modified:    src/java/org/apache/avalon/excalibur/logger/factory
                        FileTargetFactory.java ServletTargetFactory.java
                        StreamTargetFactory.java
  Log:
  Use FormatterFactory to get a formatter.
  
  Revision  Changes    Path
  1.8       +8 -16     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/FileTargetFactory.java
  
  Index: FileTargetFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/FileTargetFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FileTargetFactory.java	2001/12/14 08:35:16	1.7
  +++ FileTargetFactory.java	2001/12/19 23:34:50	1.8
  @@ -111,15 +111,12 @@
    * </dl>
    *
    * @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/12/14 08:35:16 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/12/19 23:34:50 $
    * @since 4.0
    */
   public class FileTargetFactory 
       extends AbstractTargetFactory 
   {
  -    //Format of default formatter
  -    private static final String FORMAT =
  -        "%7.7{priority} %5.5{time}   [%8.8{category}] (%{context}): %{message}\\n%{throwable}";
   
       /**
        * Create a LogTarget based on a Configuration
  @@ -280,22 +277,17 @@
           } 
       }    
   
  -    protected Formatter getFormatter(final Configuration conf) 
  +    protected Formatter getFormatter( final Configuration conf )
       {
  -        final String type = conf.getAttribute( "type", "pattern" );
  -        final String format = conf.getValue( FORMAT );
  -        
  -        if( "extended".equals( type ) )
  -        {
  -            return new ExtendedPatternFormatter( format );
  -        }
  -        else if( "raw".equals( type ) )
  +        Formatter formatter = null;
  +
  +        if ( null != conf )
           {
  -            return new RawFormatter();
  +            final FormatterFactory formatterFactory = new FormatterFactory();
  +            formatter = formatterFactory.createFormatter( conf );
           }
           
  -        // default formatter
  -        return new PatternFormatter( format );
  +        return formatter;
       }
   
       /** 
  
  
  
  1.4       +8 -16     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/ServletTargetFactory.java
  
  Index: ServletTargetFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/ServletTargetFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServletTargetFactory.java	2001/12/11 09:53:30	1.3
  +++ ServletTargetFactory.java	2001/12/19 23:34:50	1.4
  @@ -45,15 +45,12 @@
    * </dl>
    *
    * @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/12/11 09:53:30 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/12/19 23:34:50 $
    * @since 4.0
    */
   public final class ServletTargetFactory
       extends AbstractTargetFactory
   {
  -    //Format of default formatter
  -    private static final String FORMAT =
  -        "%7.7{priority} %5.5{time}   [%8.8{category}] (%{context}): %{message}\\n%{throwable}";
   
       /**
        * create a LogTarget based on a Configuration
  @@ -81,21 +78,16 @@
           return new ServletOutputLogTarget( sctx );
       }
   
  -    protected Formatter getFormatter(final Configuration conf)
  +    protected Formatter getFormatter( final Configuration conf )
       {
  -        final String type = conf.getAttribute( "type", "pattern" );
  -        final String format = conf.getValue( FORMAT );
  +        Formatter formatter = null;
   
  -        if( "extended".equals( type ) )
  +        if ( null != conf )
           {
  -            return new ExtendedPatternFormatter( format );
  +            final FormatterFactory formatterFactory = new FormatterFactory();
  +            formatter = formatterFactory.createFormatter( conf );
           }
  -        else if( "raw".equals( type ) )
  -        {
  -            return new RawFormatter();
  -        }
  -
  -        // default formatter
  -        return new PatternFormatter( format );
  +        
  +        return formatter;
       }
   }
  
  
  
  1.3       +18 -24    jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/StreamTargetFactory.java
  
  Index: StreamTargetFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/StreamTargetFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StreamTargetFactory.java	2001/12/11 09:53:30	1.2
  +++ StreamTargetFactory.java	2001/12/19 23:34:50	1.3
  @@ -43,15 +43,12 @@
    * <p>The syntax of "format" is the same as in <code>FileTargetFactory</code>.</p>
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/12/11 09:53:30 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/12/19 23:34:50 $
    */
   public class StreamTargetFactory
       extends AbstractTargetFactory 
       implements Contextualizable
   {
  -    // Default format
  -    private static final String FORMAT =
  -        "%7.7{priority} %5.5{time}   [%8.8{category}] (%{context}): %{message}\\n%{throwable}";
   
       /**
        * Create a LogTarget based on a Configuration
  @@ -81,29 +78,13 @@
               }
           }
   
  -        final Formatter formatter = getFormatter( configuration.getChild( "format" ) );
  -
  +        final Configuration formatterConf = configuration.getChild( "format" );
  +        final Formatter formatter = getFormatter( formatterConf );
  + 
           return new StreamTarget( stream, formatter );
       }
  -
  -    protected Formatter getFormatter( final Configuration conf )
  -    {
  -        final String type = conf.getAttribute( "type", "pattern" );
  -        final String format = conf.getValue( FORMAT );
  -
  -        if( "extended".equals( type ) )
  -        {
  -            return new ExtendedPatternFormatter( format );
  -        }
  -        else if( "raw".equals( type ) )
  -        {
  -            return new RawFormatter();
  -        }
  -
  -        // default formatter
  -        return new PatternFormatter( format );
  -    }
   
  + 
       public void contextualize( final Context context )
           throws ContextException
       {
  @@ -114,6 +95,19 @@
           newContext.put( "System.err", System.err );
   
           super.contextualize( newContext );
  +    }
  +
  +    protected Formatter getFormatter( final Configuration conf )
  +    {
  +        Formatter formatter = null;
  +
  +        if ( null != conf )
  +        {
  +            final FormatterFactory formatterFactory = new FormatterFactory();
  +            formatter = formatterFactory.createFormatter( conf );
  +        }
  +        
  +        return formatter;
       }
   }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message