donaldp     01/12/23 06:23:48

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant
                        AntClassLoader.java Project.java
                        ProjectComponent.java Task.java TaskAdapter.java
               proposal/myrmidon/src/main/org/apache/tools/ant/types
                        FileSet.java FilterSet.java Path.java
               proposal/myrmidon/src/main/org/apache/tools/ant/util
                        SourceFileScanner.java
  Log:
  Start updating logging to myrmidon style logging
  
  Revision  Changes    Path
  1.11      +30 -12    
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java
  
  Index: AntClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AntClassLoader.java       2001/12/23 06:34:49     1.10
  +++ AntClassLoader.java       2001/12/23 14:23:47     1.11
  @@ -23,6 +23,8 @@
   import java.util.zip.ZipEntry;
   import java.util.zip.ZipFile;
   import org.apache.avalon.excalibur.io.FileUtil;
  +import org.apache.avalon.framework.logger.LogEnabled;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.types.Path;
   
  @@ -38,7 +40,7 @@
    */
   public class AntClassLoader
       extends ClassLoader
  -    implements BuildListener
  +    implements BuildListener, LogEnabled
   {
       /**
        * The size of buffers to be used in this classloader.
  @@ -50,6 +52,23 @@
       private static Method getContextClassLoader;
       private static Method setContextClassLoader;
   
  +    private Logger m_logger;
  +
  +    /**
  +     * Provide component with a logger.
  +     *
  +     * @param logger the logger
  +     */
  +    public void enableLogging( Logger logger )
  +    {
  +        m_logger = logger;
  +    }
  +
  +    protected final Logger getLogger()
  +    {
  +        return m_logger;
  +    }
  +
       /**
        * The components of the classpath that the classloader searches for 
classes
        */
  @@ -336,7 +355,7 @@
   
           if( url == null )
           {
  -            log( "Couldn't load Resource " + name, Project.MSG_DEBUG );
  +            getLogger().debug( "Couldn't load Resource " + name );
           }
   
           return url;
  @@ -477,7 +496,7 @@
       public Class findClass( String name )
           throws ClassNotFoundException
       {
  -        log( "Finding class " + name, Project.MSG_DEBUG );
  +        getLogger().debug( "Finding class " + name );
   
           return findClassInComponents( name );
       }
  @@ -495,7 +514,7 @@
       public Class forceLoadClass( String classname )
           throws ClassNotFoundException
       {
  -        log( "force loading " + classname, Project.MSG_DEBUG );
  +        getLogger().debug( "force loading " + classname );
   
           Class theClass = findLoadedClass( classname );
   
  @@ -521,7 +540,7 @@
       public Class forceLoadSystemClass( String classname )
           throws ClassNotFoundException
       {
  -        log( "force system loading " + classname, Project.MSG_DEBUG );
  +        getLogger().debug( "force system loading " + classname );
   
           Class theClass = findLoadedClass( classname );
   
  @@ -622,12 +641,12 @@
               try
               {
                   theClass = findBaseClass( classname );
  -                log( "Class " + classname + " loaded from parent loader", 
Project.MSG_DEBUG );
  +                getLogger().debug( "Class " + classname + " loaded from 
parent loader" );
               }
               catch( ClassNotFoundException cnfe )
               {
                   theClass = findClass( classname );
  -                log( "Class " + classname + " loaded from ant loader", 
Project.MSG_DEBUG );
  +                getLogger().debug( "Class " + classname + " loaded from ant 
loader" );
               }
           }
           else
  @@ -635,7 +654,7 @@
               try
               {
                   theClass = findClass( classname );
  -                log( "Class " + classname + " loaded from ant loader", 
Project.MSG_DEBUG );
  +                getLogger().debug( "Class " + classname + " loaded from ant 
loader" );
               }
               catch( ClassNotFoundException cnfe )
               {
  @@ -644,7 +663,7 @@
                       throw cnfe;
                   }
                   theClass = findBaseClass( classname );
  -                log( "Class " + classname + " loaded from parent loader", 
Project.MSG_DEBUG );
  +                getLogger().debug( "Class " + classname + " loaded from 
parent loader" );
               }
           }
   
  @@ -793,8 +812,7 @@
           }
           catch( Exception e )
           {
  -            log( "Ignoring Exception " + e.getClass().getName() + ": " + 
e.getMessage() +
  -                 " reading resource " + resourceName + " from " + file, 
Project.MSG_VERBOSE );
  +            getLogger().debug( "Ignoring Exception " + 
e.getClass().getName() + ": " + e.getMessage() + " reading resource " + 
resourceName + " from " + file );
           }
   
           return null;
  @@ -948,7 +966,7 @@
                   catch( IOException ioe )
                   {
                       // ioe.printStackTrace();
  -                    log( "Exception reading component " + pathComponent, 
Project.MSG_VERBOSE );
  +                    getLogger().debug( "Exception reading component " + 
pathComponent );
                   }
               }
   
  
  
  
  1.14      +11 -3     
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Project.java      2001/12/23 06:34:49     1.13
  +++ Project.java      2001/12/23 14:23:47     1.14
  @@ -12,6 +12,8 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Iterator;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.types.FilterSet;
   import org.apache.tools.ant.types.FilterSetCollection;
  @@ -28,6 +30,7 @@
    * @author [EMAIL PROTECTED]
    */
   public class Project
  +    extends AbstractLogEnabled
   {
       public final static int MSG_ERR = 0;
       public final static int MSG_WARN = 1;
  @@ -106,6 +109,11 @@
           }
       }
   
  +    public Logger hackGetLogger()
  +    {
  +        return super.getLogger();
  +    }
  +
       /**
        * static query of the java version
        *
  @@ -183,9 +191,9 @@
               throw new TaskException( "Ant cannot work on Java 1.0" );
           }
   
  -        log( "Detected Java version: " + javaVersion + " in: " + 
System.getProperty( "java.home" ), MSG_VERBOSE );
  +        getLogger().debug( "Detected Java version: " + javaVersion + " in: " 
+ System.getProperty( "java.home" ) );
   
  -        log( "Detected OS: " + System.getProperty( "os.name" ), MSG_VERBOSE 
);
  +        getLogger().debug( "Detected OS: " + System.getProperty( "os.name" ) 
);
       }
   
       /**
  @@ -373,7 +381,7 @@
                   String propertyName = (String)j.next();
                   if( !keys.containsKey( propertyName ) )
                   {
  -                    project.log( "Property ${" + propertyName + "} has not 
been set", Project.MSG_VERBOSE );
  +                    project.getLogger().debug( "Property ${" + propertyName 
+ "} has not been set" );
                   }
                   fragment = ( keys.containsKey( propertyName ) ) ? 
(String)keys.get( propertyName )
                       : "${" + propertyName + "}";
  
  
  
  1.11      +9 -3      
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java
  
  Index: ProjectComponent.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ProjectComponent.java     2001/12/23 06:34:49     1.10
  +++ ProjectComponent.java     2001/12/23 14:23:47     1.11
  @@ -7,6 +7,7 @@
    */
   package org.apache.tools.ant;
   
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.myrmidon.api.AbstractTask;
   import org.apache.myrmidon.api.TaskException;
   
  @@ -20,8 +21,13 @@
   public abstract class ProjectComponent
       extends AbstractTask
   {
  -    private Project project;
  +    private Project m_project;
   
  +    public Logger hackGetLogger()
  +    {
  +        return super.getLogger();
  +    }
  +
       /**
        * Sets the project object of this component. This method is used by 
project
        * when a component is added to it so that the component has access to 
the
  @@ -31,7 +37,7 @@
        */
       public void setProject( Project project )
       {
  -        this.project = project;
  +        this.m_project = project;
       }
   
       /**
  @@ -41,7 +47,7 @@
        */
       public Project getProject()
       {
  -        return project;
  +        return m_project;
       }
   
       public void execute()
  
  
  
  1.20      +2 -2      
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java
  
  Index: Task.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Task.java 2001/12/23 06:34:48     1.19
  +++ Task.java 2001/12/23 14:23:47     1.20
  @@ -13,12 +13,12 @@
   {
       protected void handleErrorOutput( String line )
       {
  -        log( line, Project.MSG_ERR );
  +        getLogger().error( line );
       }
   
       protected void handleOutput( String line )
       {
  -        log( line, Project.MSG_INFO );
  +        getLogger().info( line );
       }
   }
   
  
  
  
  1.8       +4 -4      
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java
  
  Index: TaskAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TaskAdapter.java  2001/12/23 06:34:48     1.7
  +++ TaskAdapter.java  2001/12/23 14:23:47     1.8
  @@ -61,8 +61,8 @@
           }
           catch( Exception ex )
           {
  -            log( "Error setting project in " + proxy.getClass(),
  -                 Project.MSG_ERR );
  +            final String message = "Error setting project in " + 
proxy.getClass();
  +            getLogger().error( message, ex );
               throw new TaskException( "Error", ex );
           }
   
  @@ -73,7 +73,7 @@
               executeM = c.getMethod( "execute", new Class[ 0 ] );
               if( executeM == null )
               {
  -                log( "No public execute() in " + proxy.getClass(), 
Project.MSG_ERR );
  +                getLogger().error( "No public execute() in " + 
proxy.getClass() );
                   throw new TaskException( "No public execute() in " + 
proxy.getClass() );
               }
               executeM.invoke( proxy, null );
  @@ -81,7 +81,7 @@
           }
           catch( Exception ex )
           {
  -            log( "Error in " + proxy.getClass(), Project.MSG_ERR );
  +            getLogger().error( "Error in " + proxy.getClass() );
               throw new TaskException( "Error", ex );
           }
   
  
  
  
  1.9       +4 -4      
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java
  
  Index: FileSet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FileSet.java      2001/12/23 06:32:48     1.8
  +++ FileSet.java      2001/12/23 14:23:47     1.9
  @@ -27,9 +27,10 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Magesh Umasankar</a>
    */
  -public class FileSet extends DataType implements Cloneable
  +public class FileSet
  +    extends DataType
  +    implements Cloneable
   {
  -
       private PatternSet defaultPatterns = new PatternSet();
       private ArrayList additionalPatterns = new ArrayList();
       private boolean useDefaultExcludes = true;
  @@ -199,8 +200,7 @@
               defaultPatterns.append( (PatternSet)o, p );
           }
   
  -        p.log( "FileSet: Setup file scanner in dir " + dir +
  -               " with " + defaultPatterns, p.MSG_DEBUG );
  +        getLogger().debug( "FileSet: Setup file scanner in dir " + dir + " 
with " + defaultPatterns );
   
           ds.setIncludes( defaultPatterns.getIncludePatterns( p ) );
           ds.setExcludes( defaultPatterns.getExcludePatterns( p ) );
  
  
  
  1.7       +2 -3      
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java
  
  Index: FilterSet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FilterSet.java    2001/12/23 06:32:48     1.6
  +++ FilterSet.java    2001/12/23 14:23:47     1.7
  @@ -16,7 +16,6 @@
   import java.util.Iterator;
   import java.util.Properties;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.Project;
   
   /**
    * A set of filters to be applied to something. A filter set may have 
begintoken
  @@ -266,7 +265,7 @@
   
           if( filtersFile.isFile() )
           {
  -            log( "Reading filters from " + filtersFile, Project.MSG_VERBOSE 
);
  +            getLogger().debug( "Reading filters from " + filtersFile );
               FileInputStream in = null;
               try
               {
  @@ -343,7 +342,7 @@
                       if( tokens.containsKey( token ) )
                       {
                           value = (String)tokens.get( token );
  -                        log( "Replacing: " + beginToken + token + endToken + 
" -> " + value, Project.MSG_VERBOSE );
  +                        getLogger().debug( "Replacing: " + beginToken + 
token + endToken + " -> " + value );
                           b.append( value );
                           i = index + beginToken.length() + token.length() + 
endToken.length();
                       }
  
  
  
  1.8       +5 -6      
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java
  
  Index: Path.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Path.java 2001/12/23 06:32:48     1.7
  +++ Path.java 2001/12/23 14:23:47     1.8
  @@ -118,7 +118,7 @@
        * @param source Description of Parameter
        * @return Description of the Returned Value
        */
  -    public static String[] translatePath( Project project, String source )
  +    public String[] translatePath( Project project, String source )
       {
           final ArrayList result = new ArrayList();
           if( source == null )
  @@ -136,8 +136,7 @@
               }
               catch( TaskException e )
               {
  -                project.log( "Dropping path element " + pathElement + " as 
it is not valid relative to the project",
  -                             Project.MSG_VERBOSE );
  +                getLogger().debug( "Dropping path element " + pathElement + 
" as it is not valid relative to the project" );
               }
               for( int i = 0; i < element.length(); i++ )
               {
  @@ -498,8 +497,8 @@
               // last: don't trust the developer
               if( !order.equals( "last" ) )
               {
  -                log( "invalid value for build.sysclasspath: " + order,
  -                     Project.MSG_WARN );
  +                final String message = "invalid value for 
build.sysclasspath: " + order;
  +                getLogger().warn( message );
               }
   
               result.addExisting( this );
  @@ -728,7 +727,7 @@
   
           public void setPath( String path )
           {
  -            parts = Path.translatePath( getProject(), path );
  +            parts = translatePath( getProject(), path );
           }
   
           public String[] getParts()
  
  
  
  1.8       +8 -12     
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/SourceFileScanner.java
  
  Index: SourceFileScanner.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/SourceFileScanner.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SourceFileScanner.java    2001/12/23 06:32:30     1.7
  +++ SourceFileScanner.java    2001/12/23 14:23:48     1.8
  @@ -10,9 +10,9 @@
   import java.io.File;
   import java.util.ArrayList;
   import org.apache.avalon.excalibur.io.FileUtil;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.Os;
  -import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   
   /**
  @@ -26,6 +26,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
    */
   public class SourceFileScanner
  +    extends AbstractLogEnabled
   {
       private Task m_task;
   
  @@ -77,8 +78,7 @@
               String[] targets = mapper.mapFileName( files[ i ] );
               if( targets == null || targets.length == 0 )
               {
  -                m_task.log( files[ i ] + " skipped - don\'t know how to 
handle it",
  -                            Project.MSG_VERBOSE );
  +                getLogger().debug( files[ i ] + " skipped - don\'t know how 
to handle it" );
                   continue;
               }
   
  @@ -86,8 +86,8 @@
   
               if( src.lastModified() > now )
               {
  -                m_task.log( "Warning: " + files[ i ] + " modified in the 
future.",
  -                            Project.MSG_WARN );
  +                final String message = "Warning: " + files[ i ] + " modified 
in the future.";
  +                getLogger().warn( message );
               }
   
               boolean added = false;
  @@ -98,15 +98,13 @@
   
                   if( !dest.exists() )
                   {
  -                    m_task.log( files[ i ] + " added as " + 
dest.getAbsolutePath() + " doesn\'t exist.",
  -                                Project.MSG_VERBOSE );
  +                    getLogger().debug( files[ i ] + " added as " + 
dest.getAbsolutePath() + " doesn\'t exist." );
                       v.add( files[ i ] );
                       added = true;
                   }
                   else if( src.lastModified() > dest.lastModified() )
                   {
  -                    m_task.log( files[ i ] + " added as " + 
dest.getAbsolutePath() + " is outdated.",
  -                                Project.MSG_VERBOSE );
  +                    getLogger().debug( files[ i ] + " added as " + 
dest.getAbsolutePath() + " is outdated." );
                       v.add( files[ i ] );
                       added = true;
                   }
  @@ -122,9 +120,7 @@
   
               if( !added )
               {
  -                m_task.log( files[ i ] + " omitted as " + 
targetList.toString()
  -                            + ( targets.length == 1 ? " is" : " are " )
  -                            + " up to date.", Project.MSG_VERBOSE );
  +                getLogger().debug( files[ i ] + " omitted as " + 
targetList.toString() + ( targets.length == 1 ? " is" : " are " ) + " up to 
date." );
               }
   
           }
  
  
  

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

Reply via email to