01: package net.sourceforge.cruisecontrol.builders;
02:
03: import org.apache.tools.ant.BuildEvent;
04: import org.apache.tools.ant.Project;
05: import org.apache.tools.ant.DefaultLogger;
06:
07: import java.io.PrintStream;
08:
09: /**
10: * Ant Logger impl used to send progress messages back to an AntBuilder.
11: * Intended for use in conjuction with {@link AntProgressXmlListener}.
12: *
13: * Ideas adapted from contrib/XmlLoggerWithStatus, written by IgorSemenko (igor@semenko.com).
14: *
15: * @author Dan Rollo
16: * Date: Aug 10, 2007
17: * Time: 5:07:53 AM
18: * To change this template use File | Settings | File Templates.
19: */
20: public class AntProgressXmlLogger extends DefaultLogger {
21:
22: public void targetStarted(BuildEvent event) {
23: if (Project.MSG_INFO <= msgOutputLevel
24: && !event.getTarget().getName().equals("")) {
25:
26: final String name = event.getTarget().getName();
27:
28: // @todo Add filter support, like XmlLoggerWithStatus
29: // if (this.targetFilter != null && name.matches(this.targetFilter)){
30: // return;
31: // }
32:
33: final String msg = AntProgressLogger.MSG_PREFIX_ANT_PROGRESS
34: + name;
35: // use super to actually print to sysout
36: super .printMessage(msg, out, event.getPriority());
37: log(msg);
38: }
39: }
40:
41: /**
42: * Prints a message to a PrintStream.
43: *
44: * @param message The message to print.
45: * Should not be <code>null</code>.
46: * @param stream A PrintStream to print the message to.
47: * Must not be <code>null</code>.
48: * @param priority The priority of the message.
49: * (Ignored in this implementation.)
50: */
51: protected void printMessage(final String message,
52: final PrintStream stream, final int priority) {
53:
54: // no-op to stop console output - similar behavior to XmlLogger when used as Logger;
55: }
56:
57: /** @return current value of message output level */
58: public int getMessageOutputLevel() {
59: return msgOutputLevel;
60: }
61: }
|