diff --git a/docs/manual/CoreTasks/recorder.html b/docs/manual/CoreTasks/recorder.html index 45d6fa62d..fd660a8e4 100644 --- a/docs/manual/CoreTasks/recorder.html +++ b/docs/manual/CoreTasks/recorder.html @@ -53,6 +53,13 @@ a buildFinished event.

this file. [Values = {yes|no}, Default=yes] no + + emacsmode + Removes [task] banners like Ant's + -emacs command line switch if set to + true. + no, default is false + loglevel At what logging level should this recorder instance @@ -97,14 +104,6 @@ future. They include things like the following:

Description Required - - messageprefix - 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 -emacs command line parameter does to the screen output. - [yes|no] - no - listener A classname of a build listener to use from this point @@ -150,9 +149,8 @@ future. They include things like the following:

-

Copyright © 2001 Apache Software Foundation. All rights -Reserved.

+

Copyright © 2001-2002 Apache Software +Foundation. All rights Reserved.

- diff --git a/src/main/org/apache/tools/ant/DefaultLogger.java b/src/main/org/apache/tools/ant/DefaultLogger.java index bb6587f2f..795871891 100644 --- a/src/main/org/apache/tools/ant/DefaultLogger.java +++ b/src/main/org/apache/tools/ant/DefaultLogger.java @@ -71,7 +71,7 @@ public class DefaultLogger implements BuildLogger { * 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; diff --git a/src/main/org/apache/tools/ant/taskdefs/Recorder.java b/src/main/org/apache/tools/ant/taskdefs/Recorder.java index dbb7ae0f0..47a1e4d1a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Recorder.java +++ b/src/main/org/apache/tools/ant/taskdefs/Recorder.java @@ -75,7 +75,7 @@ import java.util.Hashtable; * @see RecorderEntry * @author J D Glanville * @version 0.5 - * + * @since Ant 1.4 * @ant.task name="record" category="utility" */ public class Recorder extends Task { @@ -95,6 +95,10 @@ public class Recorder extends Task { 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 @@ public class Recorder extends Task { 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 @@ public class Recorder extends Task { } 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 @@ public class Recorder extends Task { * 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 ) { diff --git a/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java b/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java index 10c77c3a3..5c8449704 100644 --- a/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java +++ b/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java @@ -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 @@ import java.io.PrintStream; * to the build process. * @author J D Glanville * @version 0.5 - * + * @since Ant 1.4 */ public class RecorderEntry implements BuildLogger { @@ -94,6 +95,10 @@ public class RecorderEntry implements BuildLogger { * 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 @@ public class RecorderEntry implements BuildLogger { 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 class RecorderEntry implements BuildLogger { 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 @@ public class RecorderEntry implements BuildLogger { 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 @@ public class RecorderEntry implements BuildLogger { */ private void log( String mesg, int level ) { if ( record && (level <= loglevel) ) { - out.println(mesg); + out.println(mesg); } } @@ -205,7 +216,7 @@ public class RecorderEntry implements BuildLogger { } public void setEmacsMode(boolean emacsMode) { - throw new java.lang.RuntimeException("Method setEmacsMode() not yet implemented."); + this.emacsMode = emacsMode; } public void setErrorPrintStream(PrintStream err) {