Commits

Brydie McCoy  committed dbef0e5

Adding debug information for processes

  • Participants
  • Parent commits 9ca9a54

Comments (0)

Files changed (1)

File src/main/java/com/atlassian/utils/process/ExternalProcess.java

         {
             pb.environment().putAll(environment);
         }
+
+        if (log.isDebugEnabled())
+        {
+            logProcessDetails(pb);
+        }
+
         return pb.start();
     }
 
                 processBuilder.environment().putAll(environment);
             }
 
-    		return processBuilder.start();
+            if (log.isDebugEnabled())
+            {
+                logProcessDetails(processBuilder);
+            }
+
+            return processBuilder.start();
     	}
     }
-    
+
+    private void logProcessDetails(ProcessBuilder processBuilder)
+    {
+        String divider = "---------------------------";
+        log.debug(divider);
+        log.debug("Start Process Debug Information");
+        log.debug(divider);
+        log.debug("Command");
+        log.debug(divider);
+        log.debug(processBuilder.command());
+        log.debug(divider);
+        log.debug("Working Dir");
+        log.debug(divider);
+        log.debug(processBuilder.directory());
+        log.debug(divider);
+        log.debug("Environment");
+        log.debug(divider);
+        for (Map.Entry entry : processBuilder.environment().entrySet())
+        {
+            log.debug(entry.getKey() + ": " + entry.getValue());
+        }
+        log.debug(divider);
+        log.debug("Redirect Error Stream?");
+        log.debug(divider);
+        log.debug(processBuilder.redirectErrorStream());
+        log.debug(divider);
+        log.debug("End Process Debug Information");
+    }
+
     /**
      * Start the external process and setup the IO pump threads needed to
      * manage the process IO. If you call this method you must eventually call the