Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java	(revision 31591)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java	(revision 31592)
@@ -335,5 +335,4 @@
 		// http://www.cgi101.com/class/ch3/text.html
 		// setenv QUERY_STRING and REQUEST_METHOD = GET.
-		// Run the perl command as a simple process: no logging to the collection's build log
 		if (runPerlCommand(command_str, envvars, new File(cgi_directory)))
 				   //new File(GlobalProperties.getGSDL3Home() + File.separator + "WEB-INF" + File.separator + "cgi")))
@@ -402,5 +401,6 @@
     }
 
-    // ModifyMetadata operations call runSimplePerlCommand which produces no output in build log
+    // If you want to run a Perl command without doing GS2PerlConstructor's custom logging in the build log
+    // The use the runSimplePerlCommand() versions, which use the default behaviour of running a SafeProcess
     protected boolean runSimplePerlCommand(String[] command) {	
 	return runSimplePerlCommand(command, null, null);
@@ -417,5 +417,5 @@
 	sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str));
 	
-	logger.info("### Running simple command = " + command_str);
+	///logger.info("### Running simple command = " + command_str);
 
 	// This is where we create and run our perl process safely
@@ -459,5 +459,5 @@
 	sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str));
 	
-	logger.info("### Running logged command = " + command_str);
+	///logger.info("### Running logged command = " + command_str);
 
 	// This is where we create and run our perl process safely
@@ -526,26 +526,20 @@
 	    // Now display final message based on exit value		    
 	    
-	    if (perlProcess.getExitValue() == 0) {	
-		//status = OK;
+	    if (perlProcess.getExitValue() == 0) { //status = OK;
+		
 		sendProcessStatus(new ConstructionEvent(this, GSStatus.CONTINUING, "Success"));
-		
 		success = true;
-	    } else {
-		//status = ERROR;
+
+	    } else { //status = ERROR;
 		sendProcessStatus(new ConstructionEvent(this, GSStatus.ERROR, "Failure"));
-		
-		//return false;
 		success = false;
 		
 	    }
-	} else { // cancelled
+	} else { // cancelled. The code would never come here, including in the old version of runPerlCommand
+	    // but leaving this here for an exact port of the old runPerlCommand to the new one which
+	    // uses SafeProcess. Also to allow the cancel functionality in future
 	    
 	    // I need to somehow kill the child process. Unfortunately Thread.stop() and Process.destroy() both fail to do this. But now, thankx to the magic of Michaels 'close the stream suggestion', it works fine.
 	    sendProcessStatus(new ConstructionEvent(this, GSStatus.HALTED, "killing the process"));
-	    //prcs.getOutputStream().close();
-	    //prcs.destroy();
-	    ////status = ERROR;
-	    
-	    //return false;
 	    success = false;
 	}
@@ -752,6 +746,6 @@
 		    }
 		    
-///		    System.out.println("@@@ GOT LINE: " + line);
-///		    GS2PerlConstructor.logger.info("@@@ GOT LINE: " + line + " STDOUT=1: " + source);
+		    ///System.out.println("@@@ GOT LINE: " + line);
+
 
 		    //if(this.source == STDERR) {
@@ -814,5 +808,4 @@
 		bwHandle.write(line + "\n");	
 	    
-///		System.out.println("@@@ WROTE LINE: " + line);
 ///		GS2PerlConstructor.logger.info("@@@ WROTE LINE: " + line);
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java	(revision 31591)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java	(revision 31592)
@@ -1026,9 +1026,9 @@
     {
 	if(allowedMetaFieldsPattern == null) { // null when user has edit permissions, so they can set any meta
-	    logger.info("### User has permissions to set any meta.");
+	    ///logger.info("### User has permissions to set any meta.");
 	    return true;
 	}
 	if(metaname == null) {
-	    logger.info("### Can't check null metaname against pattern");
+	    ///logger.info("### Can't check null metaname against pattern");
 	    return false;
 	}
@@ -1036,5 +1036,5 @@
 	Matcher m = allowedMetaFieldsPattern.matcher(metaname);
 	if(!m.matches()) {
-	    logger.info("### metaname: " + metaname + " doesn't match allowed allowed fields: " + allowedMetaFieldsPattern.toString());
+	    ///logger.info("### metaname: " + metaname + " doesn't match allowed allowed fields: " + allowedMetaFieldsPattern.toString());
 	    return false;
 	} else {
@@ -1065,5 +1065,5 @@
 		    docids[index] = docInfo.getString("docid"); // should exist if metatable existed
 
-		    logger.info("@@@ Found docid: " + docids[index]);
+		    ///logger.info("@@@ Found docid: " + docids[index]);
 
 		    JSONArray metatable = docInfo.getJSONArray("metatable");
@@ -1072,5 +1072,5 @@
 
 			String metaname = meta.getString("metaname");
-			logger.info("### metaname: " + metaname);
+			///logger.info("### metaname: " + metaname);
 			
 			if(!isAllowedToSetMeta(metaname, filterFields)) {
@@ -1123,5 +1123,6 @@
     }
 
-    // START DEBUG
+    /* 
+    // FOR DEBUGGING
     Set<Map.Entry<String, Serializable>> entries = params.entrySet();
     Iterator<Map.Entry<String, Serializable>> i = entries.iterator();
@@ -1138,5 +1139,5 @@
     
     logger.info("XXXXXXXXXXXXX PARAMETERS:\n" + parametersLine);
-    // END DEBUG
+    */
 
     for (String group : context.getGroups()) {
Index: /main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java	(revision 31591)
+++ /main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java	(revision 31592)
@@ -123,15 +123,13 @@
 		    
 		    if(this.dir == null) {
-			logger.info("\twith: " + Arrays.toString(this.envp));
+			//logger.info("\twith: " + Arrays.toString(this.envp));
 			prcs = rt.exec(this.command_args, this.envp);
 		    } else {
-			logger.info("\tfrom directory: " + this.dir);
-			logger.info("\twith: " + Arrays.toString(this.envp));
+			//logger.info("\tfrom directory: " + this.dir);
+			//logger.info("\twith: " + Arrays.toString(this.envp));
 			prcs = rt.exec(this.command_args, this.envp, this.dir);
 		    }
 		}
 	    }
-
-	    logger.info("### Before creating ProcessInGobbler");
 
 	    // Create the streamgobblers and set any specified handlers on them
@@ -146,6 +144,4 @@
 	    }
 
-	    logger.info("### Before creating ProcessErrGobbler");
-	    
 	    // PROC ERR STREAM to monitor for any error messages or expected output in the process' stderr
 	    if(procErrHandler == null) {
@@ -157,6 +153,4 @@
 	    }
 
-	    logger.info("### Before creating ProcessOutGobbler");
-
             // PROC OUT STREAM to monitor for the expected std output line(s)
 	    if(procOutHandler == null) {
@@ -169,6 +163,4 @@
 
 	    
-	    logger.info("### Before streamgobblers.start()");
-
             // kick off the stream gobblers
             inputGobbler.start();
@@ -176,12 +168,8 @@
             outputGobbler.start();
 
-	    logger.info("### After streamgobblers.start() - before waitFor");
-                                    
             // any error???
             this.exitValue = prcs.waitFor(); // can throw an InterruptedException if process did not terminate
 
-            logger.info("Process exitValue: " + exitValue); 
-
-	    logger.info("### Before streamgobblers.join()");
+            ///logger.info("Process exitValue: " + exitValue); 
 
 	    // From the comments of 
@@ -194,5 +182,4 @@
 	    inputGobbler.join(); 
 	    
-	    logger.info("### After streamgobblers.join()");
 
 	    // set the variables the code that created a SafeProcess object may want to inspect
