1
14
15 package com.liferay.util.ant;
16
17 import com.liferay.portal.kernel.io.unsync.UnsyncBufferedReader;
18 import com.liferay.portal.kernel.io.unsync.UnsyncStringReader;
19 import com.liferay.portal.kernel.util.StringBundler;
20
21 import java.io.IOException;
22
23 import org.apache.tools.ant.BuildEvent;
24 import org.apache.tools.ant.DefaultLogger;
25 import org.apache.tools.ant.Project;
26 import org.apache.tools.ant.util.StringUtils;
27
28
33 public class SystemLogger extends DefaultLogger {
34
35 public void messageLogged(BuildEvent event) {
36 int priority = event.getPriority();
37
38 if (priority <= msgOutputLevel) {
39 StringBundler sb = new StringBundler();
40
41 try {
42 UnsyncBufferedReader unsyncBufferedReader =
43 new UnsyncBufferedReader(
44 new UnsyncStringReader(event.getMessage()));
45
46 String line = unsyncBufferedReader.readLine();
47
48 boolean first = true;
49
50 while (line != null) {
51 if (!first) {
52 sb.append(StringUtils.LINE_SEP);
53 }
54
55 first = false;
56
57 sb.append(" ");
58 sb.append(line);
59
60 line = unsyncBufferedReader.readLine();
61 }
62 }
63 catch (IOException e) {
64 }
65
66 String msg = sb.toString();
67
68 if (priority != Project.MSG_ERR) {
69 printMessage(msg, out, priority);
70 }
71 else {
72 printMessage(msg, err, priority);
73 }
74
75 log(msg);
76 }
77 }
78
79 }