Added more logging

This commit is contained in:
Erik C. Thauvin 2023-08-27 10:56:11 -07:00
parent c230f7f979
commit 9843cfeb6b
2 changed files with 17 additions and 0 deletions

6
.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
@ -75,6 +76,10 @@ public class ExecOperation extends AbstractOperation<ExecOperation> {
pb.command(args_);
pb.directory(workDir);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info(String.join(" ", args_));
}
var proc = pb.start();
var err = proc.waitFor(30, TimeUnit.SECONDS);
var stdout = readStream(proc.getInputStream());
@ -99,6 +104,12 @@ public class ExecOperation extends AbstractOperation<ExecOperation> {
errorMessage.append("STDOUT -> ").append(stdout.get(0));
}
}
if (LOGGER.isLoggable(Level.INFO) && errorMessage.isEmpty() && !stdout.isEmpty()) {
for (var l : stdout) {
LOGGER.info(l);
}
}
} else {
errorMessage.append("Invalid working directory: ").append(workDir.getCanonicalPath());
}