ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Recorder.java RecorderEntry.java
Date Fri, 12 Apr 2002 09:35:40 GMT
bodewig     02/04/12 02:35:40

  Modified:    docs/manual/CoreTasks recorder.html
               src/main/org/apache/tools/ant DefaultLogger.java
               src/main/org/apache/tools/ant/taskdefs Recorder.java
                        RecorderEntry.java
  Log:
  Add emacsmode to <recorder>.
  
  PR: 7432
  
  <recorder> is a difficult beast with regard to bug 7552 as it holds
  state in a static Hashtable - at least it won't create multiple
  loggers for the same files, so it should be relatively save.
  
  Revision  Changes    Path
  1.8       +9 -11     jakarta-ant/docs/manual/CoreTasks/recorder.html
  
  Index: recorder.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/recorder.html,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- recorder.html	3 Feb 2002 22:00:42 -0000	1.7
  +++ recorder.html	12 Apr 2002 09:35:39 -0000	1.8
  @@ -54,6 +54,13 @@
       <td align="center" valign="middle">no</td>
     </tr>
     <tr>
  +    <td valign="top">emacsmode</td>
  +    <td valign="top">Removes <code>[task]</code> banners like Ant's
  +    <code>-emacs</code> command line switch if set to
  +    <em>true</em>.</td>
  +    <td align="center" valign="middle">no, default is <em>false</em></td>
  +  </tr>
  +  <tr>
       <td valign="top">loglevel</td>
       <td valign="top">At what logging level should this recorder instance
       record to?  This is not a once only parameter (like <code>append</code>
  @@ -98,14 +105,6 @@
       <td align="center" valign="top"><b>Required</b></td>
     </tr>
     <tr>
  -    <td valign="top">messageprefix</td>
  -    <td valign="top">Whether or not to include the message prefixes (things
  -    like the name of the tasks or targets, etc). This has the same effect as
  -    the <code>-emacs</code> command line parameter does to the screen output.
  -    [yes|no]</td>
  -    <td align="center" valign="middle">no</td>
  -  </tr>
  -  <tr>
       <td valign="top">listener</td>
       <td valign="top">A classname of a build listener to use from this point
       on instead of the default listener.</td>
  @@ -150,9 +149,8 @@
   
   
   
  -<hr><p align="center">Copyright &copy; 2001 Apache Software Foundation.
All rights
  -Reserved.</p>
  +<hr><p align="center">Copyright &copy; 2001-2002 Apache Software
  +Foundation. All rights Reserved.</p>
   
   </body>
   </html>
  -
  
  
  
  1.36      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/DefaultLogger.java
  
  Index: DefaultLogger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/DefaultLogger.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- DefaultLogger.java	9 Apr 2002 14:19:32 -0000	1.35
  +++ DefaultLogger.java	12 Apr 2002 09:35:39 -0000	1.36
  @@ -71,7 +71,7 @@
        * Size of left-hand column for right-justified task name.
        * @see #messageLogged(BuildEvent)
        */
  -    private static final int LEFT_COLUMN_SIZE = 12;
  +    public static final int LEFT_COLUMN_SIZE = 12;
   
       /** PrintStream to write non-error messages to */
       protected PrintStream out;
  
  
  
  1.10      +13 -3     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Recorder.java
  
  Index: Recorder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Recorder.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Recorder.java	3 Mar 2002 01:46:20 -0000	1.9
  +++ Recorder.java	12 Apr 2002 09:35:39 -0000	1.10
  @@ -75,7 +75,7 @@
    * @see RecorderEntry
    * @author <a href="mailto:jayglanville@home.com">J D Glanville</a>
    * @version 0.5
  - *
  + * @since Ant 1.4
    * @ant.task name="record" category="utility"
    */
   public class Recorder extends Task {
  @@ -95,6 +95,10 @@
       private Boolean start = null;
       /** The level to log at. A level of -1 means not initialized yet. */
       private int loglevel = -1;
  +    /**
  +     * Strip task banners if true.
  +     */
  +    private boolean emacsMode = false;
       /** The list of recorder entries. */
       private static Hashtable recorderEntries = new Hashtable();
   
  @@ -131,6 +135,10 @@
           this.append = new Boolean(append);
       }
   
  +    public void setEmacsMode(boolean emacsMode) {
  +        this.emacsMode = emacsMode;
  +    }
  +
       /**
        * Sets the level to which this recorder entry should log to.
        * @see VerbosityLevelChoices
  @@ -163,13 +171,14 @@
           }
   
           getProject().log( "setting a recorder for name " + filename,
  -            Project.MSG_DEBUG );
  +                          Project.MSG_DEBUG );
   
           // get the recorder entry
           RecorderEntry recorder = getRecorder( filename, getProject() );
           // set the values on the recorder
           recorder.setMessageOutputLevel( loglevel );
           recorder.setRecordState( start );
  +        recorder.setEmacsMode( emacsMode );
       }
   
       //////////////////////////////////////////////////////////////////////
  @@ -202,7 +211,8 @@
        * Gets the recorder that's associated with the passed in name.
        * If the recorder doesn't exist, then a new one is created.
        */
  -    protected RecorderEntry getRecorder( String name, Project proj ) throws BuildException
{
  +    protected RecorderEntry getRecorder( String name, Project proj ) 
  +        throws BuildException {
           Object o = recorderEntries.get(name);
           RecorderEntry entry;
           if ( o == null ) {
  
  
  
  1.6       +24 -13    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java
  
  Index: RecorderEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RecorderEntry.java	8 Jan 2002 22:39:36 -0000	1.5
  +++ RecorderEntry.java	12 Apr 2002 09:35:39 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -55,6 +55,7 @@
   package org.apache.tools.ant.taskdefs;
   
   import org.apache.tools.ant.BuildLogger;
  +import org.apache.tools.ant.DefaultLogger;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.BuildEvent;
   import org.apache.tools.ant.util.StringUtils;
  @@ -67,7 +68,7 @@
    * to the build process.
    * @author <a href="mailto:jayglanville@home.com">J D Glanville</a>
    * @version 0.5
  - *
  + * @since Ant 1.4
    */
   public class RecorderEntry implements BuildLogger  {
   
  @@ -94,6 +95,10 @@
        * The start time of the last know target.
        */
       private long targetStartTime = 0l;
  +    /**
  +     * Strip task banners if true.
  +     */
  +    private boolean emacsMode = false;
   
       //////////////////////////////////////////////////////////////////////
       // CONSTRUCTORS / INITIALIZERS
  @@ -137,7 +142,8 @@
           if (error == null) {
               out.println(StringUtils.LINE_SEP + "BUILD SUCCESSFUL");
           } else {
  -            out.println(StringUtils.LINE_SEP + "BUILD FAILED" + StringUtils.LINE_SEP);
  +            out.println(StringUtils.LINE_SEP + "BUILD FAILED" 
  +                        + StringUtils.LINE_SEP);
               error.printStackTrace(out);
           }
           out.flush();
  @@ -146,13 +152,14 @@
   
       public void targetStarted(BuildEvent event) {
           log( ">> TARGET STARTED -- " + event.getTarget(), Project.MSG_DEBUG );
  -        log( StringUtils.LINE_SEP + event.getTarget().getName() + ":", Project.MSG_INFO
);
  +        log( StringUtils.LINE_SEP + event.getTarget().getName() + ":", 
  +             Project.MSG_INFO );
           targetStartTime = System.currentTimeMillis();
       }
   
       public void targetFinished(BuildEvent event) {
           log( "<< TARGET FINISHED -- " + event.getTarget(), Project.MSG_DEBUG );
  -        String time = formatTime( System.currentTimeMillis() - targetStartTime );
  +        String time = formatTime(System.currentTimeMillis() - targetStartTime);
           log( event.getTarget() + ":  duration " + time, Project.MSG_VERBOSE );
           out.flush();
       }
  @@ -171,12 +178,16 @@
   
           StringBuffer buf = new StringBuffer();
           if ( event.getTask() != null ) {
  -            String name = "[" + event.getTask().getTaskName() + "]";
  -            /** @todo replace 12 with DefaultLogger.LEFT_COLUMN_SIZE */
  -            for ( int i = 0; i < (12 - name.length()); i++ ) {
  -                buf.append( " " );
  -            } // for
  -            buf.append( name );
  +            String name = event.getTask().getTaskName();
  +            
  +            if (!emacsMode) {
  +                String label = "[" + name + "] ";
  +                int size = DefaultLogger.LEFT_COLUMN_SIZE - label.length();
  +                for (int i = 0; i < size; i++) {
  +                    buf.append(" ");
  +                } // for
  +                buf.append(label);
  +            } // if
           } // if
           buf.append( event.getMessage() );
   
  @@ -190,7 +201,7 @@
        */
       private void log( String mesg, int level ) {
           if ( record && (level <= loglevel) ) {
  -                out.println(mesg);
  +            out.println(mesg);
           }
       }
   
  @@ -205,7 +216,7 @@
       }
   
       public void setEmacsMode(boolean emacsMode) {
  -        throw new java.lang.RuntimeException("Method setEmacsMode() not yet implemented.");
  +        this.emacsMode = emacsMode;
       }
   
       public void setErrorPrintStream(PrintStream err) {
  
  
  

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


Mime
View raw message