001
014
015 package com.liferay.portal.kernel.process.log;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.process.ProcessCallable;
020 import com.liferay.portal.kernel.util.StringPool;
021
022 import java.io.IOException;
023
024
027 public class LoggingProcessCallable implements ProcessCallable<String> {
028
029 public LoggingProcessCallable(byte[] bytes) {
030 this(bytes, false);
031 }
032
033 public LoggingProcessCallable(byte[] bytes, boolean error) {
034 _bytes = bytes;
035 _error = error;
036 }
037
038 public String call() {
039 try {
040 if (_error) {
041 System.err.write(_bytes);
042 }
043 else {
044 System.out.write(_bytes);
045 }
046 }
047 catch (IOException ioe) {
048 _log.error(
049 "Unable to output log message: " + new String(_bytes), ioe);
050 }
051
052 return StringPool.BLANK;
053 }
054
055 private static Log _log = LogFactoryUtil.getLog(
056 LoggingProcessCallable.class);
057
058 private final byte[] _bytes;
059 private final boolean _error;
060
061 }