Title: [41374] trunk/hudson/plugins/vncrecorder: abandoned usage of log4j

Diff

Modified: trunk/hudson/plugins/vncrecorder/pom.xml (41373 => 41374)


--- trunk/hudson/plugins/vncrecorder/pom.xml	2015-08-19 19:12:53 UTC (rev 41373)
+++ trunk/hudson/plugins/vncrecorder/pom.xml	2015-08-21 08:48:26 UTC (rev 41374)
@@ -41,15 +41,6 @@
 			<email>[email protected]</email>
 		</developer>
 	</developers>
-
-	<dependencies>
-		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<version>1.2.17</version>
-		</dependency>
-
-	</dependencies>
 	<scm>
 		<connection>scm:svn:https://svn.jenkins-ci.org/trunk/hudson/plugins/vncrecorder</connection>
 		<developerConnection>scm:svn:https://svn.jenkins-ci.org/trunk/hudson/plugins/vncrecorder</developerConnection>

Modified: trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/VncRecorderBuildWrapper.java (41373 => 41374)


--- trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/VncRecorderBuildWrapper.java	2015-08-19 19:12:53 UTC (rev 41373)
+++ trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/VncRecorderBuildWrapper.java	2015-08-21 08:48:26 UTC (rev 41374)
@@ -23,19 +23,6 @@
  * SUCH DAMAGE.
  */
 package org.jenkinsci.plugins.vncrecorder;
-import hudson.Extension;
-import hudson.Launcher;
-import hudson.Util;
-import hudson.model.BuildListener;
-import hudson.model.Item;
-import hudson.model.Result;
-import hudson.model.AbstractBuild;
-import hudson.model.AbstractProject;
-import hudson.model.Hudson;
-import hudson.tasks.BuildWrapper;
-import hudson.tasks.BuildWrapperDescriptor;
-import hudson.util.FormValidation;
-
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
@@ -45,18 +32,28 @@
 import java.util.Map;
 import java.util.concurrent.Future;
 
-import net.sf.json.JSONObject;
-
 import org.apache.commons.lang.SystemUtils;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
 import org.jenkinsci.plugins.vncrecorder.vncutil.VncRecorder;
 import org.kohsuke.stapler.AncestorInPath;
 import org.kohsuke.stapler.DataBoundConstructor;
 import org.kohsuke.stapler.QueryParameter;
 import org.kohsuke.stapler.StaplerRequest;
 
+import hudson.Extension;
+import hudson.Launcher;
+import hudson.Util;
+import hudson.model.AbstractBuild;
+import hudson.model.AbstractProject;
+import hudson.model.BuildListener;
+import hudson.model.Hudson;
+import hudson.model.Item;
+import hudson.model.Result;
+import hudson.tasks.BuildWrapper;
+import hudson.tasks.BuildWrapperDescriptor;
+import hudson.util.FormValidation;
+import net.sf.json.JSONObject;
 
+
 public class VncRecorderBuildWrapper extends BuildWrapper {
 
 	public static final String CANT_FIND_VNC2SWF = "/Set/your/path/for/vnc2swf";; 
@@ -151,7 +148,8 @@
 		}
 
 		final VncRecorder vr = new VncRecorder();
-		final Logger vncLogger = vr.getLoggerForPrintStream(listener.getLogger());
+		vr.setLoggingStream(listener.getLogger());
+//		final Logger vncLogger = vr.getLoggerForPrintStream(listener.getLogger());
 		if (!SystemUtils.IS_OS_UNIX)
 		{
 			listener.fatalError("Feature \"Record VNC session\" works only under Unix/Linux!");
@@ -170,21 +168,20 @@
 			outFileName = "${JOB_NAME}_${BUILD_NUMBER}";
 		}
 		String outFileBase =  Util.replaceMacro(outFileName,build.getEnvironment(listener)) + ".swf";
-		vncLogger.info("Recording from vnc server: " + vncServReplaced);
-		vncLogger.info("Using vnc passwd file: " + vncPasswFilePathReplaced);
-		vncLogger.setLevel(Level.WARN);
+		listener.getLogger().println("Recording from vnc server: " + vncServReplaced);
+		listener.getLogger().println("Using vnc passwd file: " + vncPasswFilePathReplaced);
 		//		listener.getLogger().printf("Using vnc passwd file: %s\n",vncPasswFilePath);	
 
 
 		File vncPasswFile = new File(vncPasswFilePathReplaced);
 		if (vncPasswFilePathReplaced.isEmpty())
 		{
-			vncLogger.warn("VNC password file is an empty string, trying vnc connection without password");
+			listener.getLogger().println("VNC password file is an empty string, trying vnc connection without password");
 			vncPasswFile = null;
 		}
 		else if (!vncPasswFile.exists())
 		{
-			vncLogger.warn("Can't find " +vncPasswFile  +", trying vnc connection without password ");
+			listener.getLogger().println("Can't find " +vncPasswFile  +", trying vnc connection without password ");
 			vncPasswFile = null;
 		}
 
@@ -229,7 +226,7 @@
 
 				if ((removeIfSuccessful && outFileSwf.exists()) && (build == null || build.getResult() == Result.SUCCESS || build.getResult() == null)  )
 				{
-					vncLogger.info("Build successful: Removing video file " + outFileSwf.getAbsolutePath() + " \n");
+					listener.getLogger().println("Build successful: Removing video file " + outFileSwf.getAbsolutePath() + " \n");
 					outFileSwf.delete();
 					outFileHtml.delete();
 					return true;

Modified: trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncProcess.java (41373 => 41374)


--- trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncProcess.java	2015-08-19 19:12:53 UTC (rev 41373)
+++ trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncProcess.java	2015-08-21 08:48:26 UTC (rev 41374)
@@ -31,40 +31,25 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.WriterAppender;
-
 public class VncProcess {
 
-	protected Logger logger = Logger.getLogger(VncProcess.class);
 	static protected ExecutorService execServ = Executors.newFixedThreadPool(10);
 	static protected ExecutorService terminatorServ = Executors.newFixedThreadPool(10);
 	static protected ScheduledExecutorService splitCheckerExec = Executors.newSingleThreadScheduledExecutor();	
 	static final protected String VNC2SWF_BINARY =  "vnc2swf";
 	protected Process process;
+	protected PrintStream loggerStream = new PrintStream(System.out);
 
-	public Logger getLoggerForPrintStream(PrintStream ps)
-	{
-		PatternLayout p = new PatternLayout("%d{ISO8601} %-5p [%t] %m%n");
-		WriterAppender wa = new WriterAppender(p,ps);
-		logger.addAppender(wa);
-		return logger;
-	}
-	
 	public VncProcess() {
 		super();
-		logger.addAppender(new ConsoleAppender( new PatternLayout("%d{ISO8601} %-5p [%t] %m%n")));
 	}
 
-
 	protected Process executeProcess(String[] com) throws Exception,
 	InterruptedException {
-		logger.debug("Starting command " + Arrays.toString(com));
+		loggerStream.println("Starting command " + Arrays.toString(com));
 		process = new ProcessBuilder( com ).start();
-		if (!com[0].equalsIgnoreCase("kill"))
-			logger.debug("PID of command " + Arrays.toString(com) + " is: " + getUnixPID(process));
+//		if (!com[0].equalsIgnoreCase("kill"))
+//			loggerStream.println("PID of command " + Arrays.toString(com) + " is: " + getUnixPID(process));
 		return process;
 	}
 
@@ -80,7 +65,12 @@
 		}  
 	}
 
-
+	public void setLoggingStream(PrintStream loggerStream)
+	{
+		this.loggerStream = loggerStream;
+	}
+	
+	
 	public static void shutdown() 
 	{
 //		execServ.shutdownNow();

Modified: trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncRecorder.java (41373 => 41374)


--- trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncRecorder.java	2015-08-19 19:12:53 UTC (rev 41373)
+++ trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncRecorder.java	2015-08-21 08:48:26 UTC (rev 41374)
@@ -47,7 +47,7 @@
 
 	public Future<Integer> record(String vncServ, String targetFile, File vncPassw, String vnc2swfPath) 
 	{
-		logger.info("Recording from server: " + vncServ + " into " + targetFile);
+		loggerStream.println("Recording from server: " + vncServ + ", to: " + targetFile);
 		VncRecorderCallable vn = new VncRecorderCallable(vncServ, targetFile,vncPassw,vnc2swfPath);
 		recordingState = execServ.submit(vn);
 		return recordingState;

Modified: trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncRecorderCallable.java (41373 => 41374)


--- trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncRecorderCallable.java	2015-08-19 19:12:53 UTC (rev 41373)
+++ trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/vncutil/VncRecorderCallable.java	2015-08-21 08:48:26 UTC (rev 41374)
@@ -67,36 +67,36 @@
 					rc = proc.waitFor();
 				} catch (InterruptedException e)
 				{
-					logger.info("Command: " + Arrays.toString(com) + " canceled");
+					loggerStream.println("Command: " + Arrays.toString(com) + " canceled");
 					stop();
 					return -999;
 				}
 				catch (Exception e)
 				{
-					logger.error("Command: " + Arrays.toString(com) + " failed",e);
+					loggerStream.println("Command: " + Arrays.toString(com) + " failed" + e.getMessage());
 					terminatorServ.submit(term);
 					return -999;
 				}
 				if (rc != 0)
 				{
-					logger.error("Command: " + Arrays.toString(com) + " returned: " + rc + ", trying " + i + " from " + 50);
+					loggerStream.println("Command: " + Arrays.toString(com) + " returned: " + rc + ", trying " + i + " from " + 50);
 					String line;
 					BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
 					BufferedReader errIn = new BufferedReader(new InputStreamReader(process.getErrorStream()));
 					while (( line = in.readLine()) != null)
 					{
-						logger.info(line);
+						loggerStream.println(line);
 					}
 					while (( line = errIn.readLine()) != null)
 					{
-						logger.error(line);
+						loggerStream.println(line);
 					}
 					Thread.sleep(5000);
 				}
 			}
 		} catch (Exception e) {
 			e.printStackTrace();
-			logger.error("Error in VncRecorderCallable", e);
+			loggerStream.println("Error in VncRecorderCallable" + e.getMessage());
 		}
 		return -1;
 	}

--
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to