1 package net.sf.statsvn.ant;
2
3 import net.sf.statcvs.output.ConfigurationOptions;
4 import net.sf.statsvn.util.TaskLogger;
5
6 import org.apache.tools.ant.Task;
7
8 /**
9 * This class wraps up an Ant task which is going to be used to log some text
10 * when the tool is used with Ant.
11 *
12 * @author Benoit Xhenseval
13 */
14 public final class AntTaskLogger implements TaskLogger {
15 /** the Ant task. */
16 private final Task task;
17
18 private Boolean shouldAcceptLog = null;
19
20 private Boolean shouldAcceptInfo = null;
21
22 /**
23 * Constructor that will hide the specific logging mechanism.
24 *
25 * @param antTask
26 * an Ant task
27 */
28 AntTaskLogger(final Task antTask) {
29 this.task = antTask;
30 }
31
32 /**
33 * Uses the Ant mechanism to log the text.
34 *
35 * @param text
36 * to be logged.
37 */
38 public void log(final String text) {
39 if (shouldAcceptLog == null) {
40 shouldAcceptLog = Boolean.valueOf(ConfigurationOptions.getLoggingProperties().indexOf("debug") >= 0);
41 }
42 if (shouldAcceptLog.booleanValue()) {
43 task.log(text);
44 }
45 }
46
47 /**
48 * Uses the Ant mechanism to log the text.
49 *
50 * @param text
51 * to be logged.
52 */
53 public void error(final String arg) {
54 log(arg);
55 }
56
57 /**
58 * Uses the Ant mechanism to log the text.
59 *
60 * @param text
61 * to be logged.
62 */
63 public void info(final String arg) {
64 if (shouldAcceptInfo == null) {
65 shouldAcceptInfo = Boolean.valueOf(ConfigurationOptions.getLoggingProperties().indexOf("verbose") >= 0);
66 }
67 if (shouldAcceptInfo.booleanValue()) {
68 log(arg);
69 }
70 }
71 }