You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mcclain <mc...@webhelp.com> on 2000/09/19 22:02:24 UTC

TerseLogger

Hi all.

I'm new to this whole open source thing, but i've been using ant for a
bit, and it doesn't play well with vim's emacs output parsing stuff, due
to the extraneous stuff tacked on ahead of and before the compiler
output.  instead of bitching, i wrote a TerseLogger.java and made a
patch based on the 9.19 nightly, both of which are attached.

one architectural thing i should mention, is that i was somewhat annoyed
by the necessity of having to pass this in from the command line, but
after taking a peek at the init code, the project data is not parsed at
the point that the log listeners are added.  imho, log listeners should
be added after the project data is populated, so they can be specified
in the build.xml file.  ant related config file errors shouldn't wind up
in my editors parser anyway.  in general, there seems to be alot of
extra text being tacked onto the compiler output *outside* of the
logging system (name of config file, "build.xml:24: Compile failed,
messages should have been provided." etc), which makes trying to alter
the logging system kind of a pain, since chances are you don't want that
info. my $.02 on that.

a note on the patch: it seems to me alot of people might like to
subclass DefaultLogger instead of implementing the somewhat onerous
BuildLogger interface, so that's why the visibility change.  at least
make an adapter or something.




cheers, and thanks for making ant.


-- 
M. Looney
Lead Programmer
WebHelp.com

Re: TerseLogger

Posted by mcclain <mc...@webhelp.com>.
Ken Wood wrote:
> 
> Did you try the -emacs option which was designed
> to suppress stuff just for the purposes of
> playing nicely with emacs?
> 
yup, that  works, but still spits out a bunch of noise, which makes life
tricky if you need to expect only compiler output.

do with the code what you will. i'm usin it <g>

 
-- 
M. Looney
Lead Programmer
WebHelp.com

Re: TerseLogger

Posted by Ken Wood <kw...@i2.com>.
Did you try the -emacs option which was designed
to suppress stuff just for the purposes of
playing nicely with emacs?

mcclain wrote:
> 
> Hi all.
> 
> I'm new to this whole open source thing, but i've been using ant for a
> bit, and it doesn't play well with vim's emacs output parsing stuff, due
> to the extraneous stuff tacked on ahead of and before the compiler
> output.  instead of bitching, i wrote a TerseLogger.java and made a
> patch based on the 9.19 nightly, both of which are attached.
> 
> one architectural thing i should mention, is that i was somewhat annoyed
> by the necessity of having to pass this in from the command line, but
> after taking a peek at the init code, the project data is not parsed at
> the point that the log listeners are added.  imho, log listeners should
> be added after the project data is populated, so they can be specified
> in the build.xml file.  ant related config file errors shouldn't wind up
> in my editors parser anyway.  in general, there seems to be alot of
> extra text being tacked onto the compiler output *outside* of the
> logging system (name of config file, "build.xml:24: Compile failed,
> messages should have been provided." etc), which makes trying to alter
> the logging system kind of a pain, since chances are you don't want that
> info. my $.02 on that.
> 
> a note on the patch: it seems to me alot of people might like to
> subclass DefaultLogger instead of implementing the somewhat onerous
> BuildLogger interface, so that's why the visibility change.  at least
> make an adapter or something.
> 
> cheers, and thanks for making ant.
> 
> --
> M. Looney
> Lead Programmer
> WebHelp.com
> 
>   ------------------------------------------------------------------------
> --- DefaultLogger.orig  Tue Sep 19 00:03:20 2000
> +++ DefaultLogger.java  Tue Sep 19 14:25:37 2000
> @@ -62,16 +62,16 @@
>   *  any messages that get logged.
>   */
>  public class DefaultLogger implements BuildLogger {
> -    private static int LEFT_COLUMN_SIZE = 12;
> +    protected static int LEFT_COLUMN_SIZE = 12;
> 
> -    private PrintStream out;
> -    private PrintStream err;
> -    private int msgOutputLevel;
> +    protected PrintStream out;
> +    protected PrintStream err;
> +    protected int msgOutputLevel;
>      private long startTime = System.currentTimeMillis();
> 
>      private static String lSep = System.getProperty("line.separator");
> 
> -    private boolean emacsMode = false;
> +    protected boolean emacsMode = false;
> 
>      /**
>       * Set the msgOutputLevel this logger is to respond to.
> 
>   ------------------------------------------------------------------------
> /*
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 1999 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution, if
>  *    any, must include the following acknowlegement:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowlegement may appear in the software itself,
>  *    if and wherever such third-party acknowlegements normally appear.
>  *
>  * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
>  *    Foundation" must not be used to endorse or promote products derived
>  *    from this software without prior written permission. For written
>  *    permission, please contact apache@apache.org.
>  *
>  * 5. Products derived from this software may not be called "Apache"
>  *    nor may "Apache" appear in their names without prior written
>  *    permission of the Apache Group.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> 
> package org.apache.tools.ant;
> 
> import java.io.*;
> 
> /**
>  *  Writes more terse output.
>  *  @author mcclain@looneys.net
>  */
> public class TerseLogger extends DefaultLogger {
> 
> 
>     /**
>      *  Prints any errors the occured during the build.
>      */
>     public void buildFinished(BuildEvent event) {
>         Throwable error = event.getException();
>         if (error != null) {
>           if (error instanceof BuildException) {
>               err.println(error.toString());
>               Throwable nested = ((BuildException)error).getException();
>               if (nested != null) {
>                   nested.printStackTrace(err);
>               }
>           }else {
>               error.printStackTrace(err);
>           }
>       }
>     }
> 
>     /**
>       Does nothing.
>       */
>     public void targetStarted(BuildEvent event) {
>         //noop this.
>     }
> 
>     /**
>       Prints out terse errors that emacs/vi can understand and jump to.
>       */
>     public void messageLogged(BuildEvent event) {
>         PrintStream logTo = event.getPriority() == Project.MSG_ERR ? err : out;
>         // Filter out messages based on priority
>         if (event.getPriority() <= msgOutputLevel) {
>             // Print out the name of the task if we're in one
>             if (event.getTask() != null) {
>                 String name = event.getTask().getTaskName();
>                 if (!emacsMode) {
>                   String msg="";
>                     for (int i = 0; i < (LEFT_COLUMN_SIZE - msg.length()); i++) {
>                         logTo.print(" ");
>                     }
>                     logTo.print(msg);
>                 }
>             }
>             // Print the message
>             logTo.println(event.getMessage());
>         }
>     }
> 
> }

Re: TerseLogger

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "m" == mcclain  <mc...@webhelp.com> writes:

Others have already pointed you to -emacs so I won't repeat that 8^).

 m> imho, log listeners should be added after the project data is
 m> populated, so they can be specified in the build.xml file.

This implies you don't have a logger in place if Ant detects errors in
the buildfile itself. 

The datatype <fileset> will throw an exception if the specified dir
attribute points to something other but an existing dir - and do so at
parser time - for example.

 m> a note on the patch: it seems to me alot of people might like to
 m> subclass DefaultLogger instead of implementing the somewhat
 m> onerous BuildLogger interface, so that's why the visibility
 m> change.

Yes, I've come accross this myself.

Stefan

Re: Copydir question - empty directories...

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "KW" == Ken Wood <kw...@i2.com> writes:

 KW> Well, the same problem exists in copydir - it skips empty
 KW> directories.

Glenn's been rewriting these tasks (and rumors are he's finally gotten
his CVS access 8^). I don't actually know if the new copy task cares
for empty directories, but if it doesn't we should modify this instead
of the old tasks that are going to be deprecated.

Stefan

Copydir question - empty directories...

Posted by Ken Wood <kw...@i2.com>.
Maybe this was covered and I missed it, but...


I recall that zip and jar were fixed so that they
didn't skip empty directories. Well, the same problem
exists in copydir - it skips empty directories.

For some situations, that may not be an issue.
But when you are preparing a directory tree for
a product distribution, and there are empty directories
in the tree that must be preserved, this problem
hurts. 

Example- you have a log directory for you app
to dump log files. Initially it is empty.
The distribution package should create the empty
directory. Well, we have that empty directory in
our source controlled model tree, but when I copydir
to create the distribution, all the empty dirs
are gone.

Has anyone already addressed this before I start
looking at zip and jar and trying to figure out
what to do to fix it in copydir????

Re: TerseLogger

Posted by Peter Donald <pj...@cs.latrobe.edu.au>.
At 03:02  19/9/00 -0500, you wrote:
>I'm new to this whole open source thing, but i've been using ant for a
>bit, and it doesn't play well with vim's emacs output parsing stuff, due
>to the extraneous stuff tacked on ahead of and before the compiler
>output.  instead of bitching, i wrote a TerseLogger.java and made a
>patch based on the 9.19 nightly, both of which are attached.

check out latest CVS version as it has a -emacs parameter to ant that does
just that :P

Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*