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 @Override
039 public String call() {
040 try {
041 if (_error) {
042 System.err.write(_bytes);
043 }
044 else {
045 System.out.write(_bytes);
046 }
047 }
048 catch (IOException ioe) {
049 _log.error(
050 "Unable to output log message: " + new String(_bytes), ioe);
051 }
052
053 return StringPool.BLANK;
054 }
055
056 private static final long serialVersionUID = 1L;
057
058 private static Log _log = LogFactoryUtil.getLog(
059 LoggingProcessCallable.class);
060
061 private final byte[] _bytes;
062 private final boolean _error;
063
064 }