X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fio%2FSimpleProcess.java;h=399d0030a9a86aec0311490a70d756ca7956f5c2;hb=26805fc0810098c4bd8009a35c8719478e74153e;hp=5e18b16cb7a97c7375fb4b0842e962f3a4c74680;hpb=1092f4c2e75cabd49c41a087f9dc67cd966d11fa;p=utils diff --git a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java index 5e18b16c..399d0030 100644 --- a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java +++ b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.BufferedReader; @@ -23,9 +23,8 @@ import java.io.InputStreamReader; import java.io.StringWriter; import java.io.Writer; import java.util.Arrays; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -33,7 +32,8 @@ import org.apache.commons.logging.LogFactory; * @version $Revision$ */ public class SimpleProcess { - private static final Log LOG = LogFactory.getLog(SimpleProcess.class); + private static final Logger LOG = Logger.getLogger(SimpleProcess.class + .getName()); private File directory; @@ -88,7 +88,7 @@ public class SimpleProcess { fullcmd.append(" " + part); } - LOG.debug("Executing '" + fullcmd + "' in directory '" + directory + + LOG.fine("Executing '" + fullcmd + "' in directory '" + directory + "'"); java.lang.Process proc = Runtime.getRuntime().exec(cmd, null, @@ -119,9 +119,9 @@ public class SimpleProcess { stderr = myStderr.toString(); if (proc.exitValue() != 0) { - LOG.warn("Exit value was non-zero: " + this); + LOG.warning("Exit value was non-zero: " + this); } else { - LOG.debug("Process finished"); + LOG.fine("Process finished"); } return proc.exitValue(); @@ -138,8 +138,11 @@ public class SimpleProcess { aReaderThread.join(); } catch (InterruptedException e) { LOG - .warn(this + - ": error waiting for output stream reader of process to finish"); + .log( + Level.WARNING, + this + + ": error waiting for output stream reader of process to finish", + e); } } @@ -156,18 +159,19 @@ public class SimpleProcess { String str; while ((str = br.readLine()) != null) { - LOG.debug(aPrefix + str); + LOG.fine(aPrefix + str); aOutput.write(str); } } catch (IOException e) { - LOG.warn(SimpleProcess.this + + LOG.log(Level.FINE, SimpleProcess.this + ": error reading input stream", e); } finally { if (br != null) { try { br.close(); } catch (IOException e) { - LOG.warn("Error closing stream " + aPrefix); + LOG.log(Level.WARNING, "Error closing stream " + + aPrefix, e); } } }