001
014
015 package com.liferay.util.ant;
016
017 import com.liferay.portal.kernel.io.unsync.UnsyncBufferedReader;
018 import com.liferay.portal.kernel.io.unsync.UnsyncStringReader;
019 import com.liferay.portal.kernel.util.StringBundler;
020
021 import java.io.IOException;
022
023 import org.apache.tools.ant.BuildEvent;
024 import org.apache.tools.ant.DefaultLogger;
025 import org.apache.tools.ant.Project;
026 import org.apache.tools.ant.util.StringUtils;
027
028
031 public class SystemLogger extends DefaultLogger {
032
033 public void messageLogged(BuildEvent event) {
034 int priority = event.getPriority();
035
036 if (priority <= msgOutputLevel) {
037 StringBundler sb = new StringBundler();
038
039 try {
040 UnsyncBufferedReader unsyncBufferedReader =
041 new UnsyncBufferedReader(
042 new UnsyncStringReader(event.getMessage()));
043
044 String line = unsyncBufferedReader.readLine();
045
046 boolean first = true;
047
048 while (line != null) {
049 if (!first) {
050 sb.append(StringUtils.LINE_SEP);
051 }
052
053 first = false;
054
055 sb.append(" ");
056 sb.append(line);
057
058 line = unsyncBufferedReader.readLine();
059 }
060 }
061 catch (IOException e) {
062 }
063
064 String msg = sb.toString();
065
066 if (priority != Project.MSG_ERR) {
067 printMessage(msg, out, priority);
068 }
069 else {
070 printMessage(msg, err, priority);
071 }
072
073 log(msg);
074 }
075 }
076
077 }