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 @Override
034 public void messageLogged(BuildEvent event) {
035 int priority = event.getPriority();
036
037 if (priority > msgOutputLevel) {
038 return;
039 }
040
041 StringBundler sb = new StringBundler();
042
043 try {
044 UnsyncBufferedReader unsyncBufferedReader =
045 new UnsyncBufferedReader(
046 new UnsyncStringReader(event.getMessage()));
047
048 String line = unsyncBufferedReader.readLine();
049
050 boolean first = true;
051
052 while (line != null) {
053 if (!first) {
054 sb.append(StringUtils.LINE_SEP);
055 }
056
057 first = false;
058
059 sb.append(" ");
060 sb.append(line);
061
062 line = unsyncBufferedReader.readLine();
063 }
064 }
065 catch (IOException ioe) {
066 }
067
068 String msg = sb.toString();
069
070 if (priority != Project.MSG_ERR) {
071 printMessage(msg, out, priority);
072 }
073 else {
074 printMessage(msg, err, priority);
075 }
076
077 log(msg);
078 }
079
080 }