[izpack-devel] AntAction logging

Eric Rose eric at forge.com.au
Wed Jul 12 02:07:38 CEST 2006


I've been using IzPackfor a while - and finding it very useful, thank you. 
Lately, I've added some tasks as ant actions, and noticed that the logging 
attribute in the Ant actions specification seemed to be ignored.

Looking through the code, I noted that the logFile variable is set from the 
XML, but never used. The following patch appears to do the right thing for me 
and I was wondering if it was worth including this functionality in the 
project generally.


Index: /home/ericr/workspace/izpack-src/src/lib/com/izforge/izpack/event/AntAction.java
--- /home/ericr/workspace/izpack-src/src/lib/com/izforge/izpack/event/AntAction.java	
(revision 1484)
+++ /home/ericr/workspace/izpack-src/src/lib/com/izforge/izpack/event/AntAction.java	
(working copy)
@@ -24,6 +24,8 @@
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -396,8 +398,26 @@
         else if (quiet) msgOutputLevel = 1;
         BuildLogger logger = new DefaultLogger();
-        logger.setOutputPrintStream(System.out);
-        logger.setErrorPrintStream(System.err);
+        if (logFile != null)
+        {
+            PrintStream printStream;
+            try
+            {
+                printStream = new PrintStream(new FileOutputStream(logFile));
+                logger.setOutputPrintStream(printStream);
+                logger.setErrorPrintStream(printStream);
+            }
+            catch (FileNotFoundException e)
+            {
+                logger.setOutputPrintStream(System.out);
+                logger.setErrorPrintStream(System.err);
+            }
+        }
+        else
+        {
+            logger.setOutputPrintStream(System.out);
+            logger.setErrorPrintStream(System.err);
+        }
         return logger;

Eric Rose              | "Sed quis custodiet ipsos custodes?"
eric at integeo.com       |         Juvenal (Satires, VI.347-8)

This message contains privileged and confidential information intended
only for the use of the addressee named above.  If you are not the
intended recipient of this message you must not disseminate, copy or
take any action in reliance on it.  If you have received this message
in error please notify the sender immediately.  Any views expressed in
this message are those of the individual sender, except where the
sender specifically states them to be the views of another (including
a Body Corporate).

If you wish to opt out from future messages, send an email to
unsubscribe at integeo.com with the subject UNSUBSCRIBE

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.berlios.de/pipermail/izpack-devel/attachments/20060712/8db387e7/attachment.pgp 

More information about the izpack-devel mailing list