(no commit message)
[utils] / support / general / src / main / java / org / wamblee / io / SimpleProcess.java
index f0090f53215c0d6af3a80228329eddaed930b97e..399d0030a9a86aec0311490a70d756ca7956f5c2 100644 (file)
  * 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 org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintStream;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Arrays;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * 
@@ -35,7 +32,8 @@ import java.util.Arrays;
  * @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;
 
@@ -90,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,
@@ -121,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();
@@ -140,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);
         }
     }
 
@@ -158,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);
                         }
                     }
                 }