Skip to content
Snippets Groups Projects
Commit fa36d8e5 authored by brinn's avatar brinn
Browse files

change: show output of rsync executable if rsync exits with exit value != 0

SVN: 1809
parent 5112a8a1
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,8 @@ import java.io.IOException; ...@@ -21,8 +21,8 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.List; import java.util.List;
import org.apache.log4j.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import ch.systemsx.cisd.common.utilities.OSUtilities; import ch.systemsx.cisd.common.utilities.OSUtilities;
/** /**
...@@ -98,41 +98,52 @@ public class CmdLineHelper ...@@ -98,41 +98,52 @@ public class CmdLineHelper
private void logProcessExitValue(final int exitValue, final Process process, String command) private void logProcessExitValue(final int exitValue, final Process process, String command)
{ {
if (operationLog.isDebugEnabled()) if (exitValue != 0)
{ {
if (processTerminated(exitValue)) primLogProcessExitValue(Level.WARN, exitValue, command);
{ logProcessOutput(process, command);
operationLog.debug(String.format("[%s] process was destroyed.", command)); } else if (operationLog.isDebugEnabled())
} else {
primLogProcessExitValue(Level.DEBUG, exitValue, command);
}
}
private void primLogProcessExitValue(Level logLevel, final int exitValue, String command)
{
if (processTerminated(exitValue))
{
operationLog.log(logLevel, String.format("[%s] process was destroyed.", command));
} else
{
operationLog.log(logLevel, String.format("[%s] process returned with exit value %d.", command,
exitValue));
}
}
private void logProcessOutput(final Process process, String command)
{
final BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
try
{
machineLog.warn(String.format("[%s] output:", command));
String ln;
while ((ln = reader.readLine()) != null)
{ {
operationLog.debug(String.format("[%s] process returned with exit value %d.", command, exitValue)); if (ln.trim().length() > 0)
machineLog.warn(String.format("\"%s\"", ln));
} }
if (exitValue != 0) } catch (IOException e)
{
operationLog.warn(String.format("IOException when trying to read stderr, msg='%s'.", e
.getMessage()));
} finally
{
try
{
reader.close();
} catch (IOException e)
{ {
final BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); // Silence this.
try
{
machineLog.debug(String.format("[%s] output:", command));
String ln;
while ((ln = reader.readLine()) != null)
{
if (ln.trim().length() > 0)
machineLog.debug(String.format("\"%s\"", ln));
}
} catch (IOException e)
{
operationLog.debug(String.format("IOException when trying to read stderr, msg='%s'.", e
.getMessage()));
} finally
{
try
{
reader.close();
} catch (IOException e)
{
// Silence this.
}
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment