提交 fd32c6be 编写于 作者: K kohsuke

reworked the logging approach.

Ant tasks should report information through Ant's logging mechanism.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1188 71c3de6d-444a-0410-be80-ed276b4c234a
上级 c0769bcc
......@@ -24,14 +24,13 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.TimeZone;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* A class used to parse the output of the CVS log command.
......@@ -286,7 +285,7 @@ class ChangeLogParser {
String branch = findBranch(m_revision);
LOGGER.fine("Recorded a change: "+m_date+','+m_author+','+m_revision+"(branch="+branch+"),"+m_comment);
owner.log("Recorded a change: "+m_date+','+m_author+','+m_revision+"(branch="+branch+"),"+m_comment,Project.MSG_VERBOSE);
entry.addFile(m_file, m_revision, m_previousRevision, branch, m_dead);
}
......@@ -338,6 +337,4 @@ class ChangeLogParser {
m_dead = false;
branches.clear();
}
private static final Logger LOGGER = Logger.getLogger(ChangeLogParser.class.getName());
}
......@@ -16,9 +16,11 @@
*/
package hudson.org.apache.tools.ant.taskdefs.cvslib;
import hudson.util.ForkOutputStream;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.AbstractCvsTask;
import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.taskdefs.cvslib.CvsVersion;
import java.io.File;
......@@ -35,7 +37,6 @@ import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.Vector;
import java.util.logging.Logger;
/**
* Examines the output of cvs log and group related changes together.
......@@ -267,11 +268,12 @@ public class ChangeLogTask extends AbstractCvsTask {
}
final ChangeLogParser parser = new ChangeLogParser(this);
final RedirectingStreamHandler handler =
new RedirectingStreamHandler(parser);
RedirectingStreamHandler handler;
handler = new RedirectingStreamHandler(
new ForkOutputStream(new RedirectingOutputStream(parser),
new LogOutputStream(this,Project.MSG_VERBOSE)));
LOGGER.fine("["+m_dir+"] $ "+getCommand());
log(getCommand(), Project.MSG_VERBOSE);
log("["+m_dir+"] $ "+getCommand(), Project.MSG_VERBOSE);
setDest(m_dir);
setExecuteStreamHandler(handler);
......@@ -351,7 +353,7 @@ public class ChangeLogTask extends AbstractCvsTask {
* @return the filtered entry set
*/
private CVSEntry[] filterEntrySet(final CVSEntry[] entrySet) {
LOGGER.fine("Filtering entries");
log("Filtering entries",Project.MSG_VERBOSE);
final Vector results = new Vector();
......@@ -361,23 +363,23 @@ public class ChangeLogTask extends AbstractCvsTask {
if(date==null) {
// skip dates that didn't parse.
LOGGER.fine("Filtering out "+cvsEntry+" because it has no date");
log("Filtering out "+cvsEntry+" because it has no date",Project.MSG_VERBOSE);
continue;
}
if (null != m_start && m_start.after(date)) {
//Skip dates that are too early
LOGGER.fine("Filtering out "+cvsEntry+" because it's too early");
log("Filtering out "+cvsEntry+" because it's too early",Project.MSG_VERBOSE);
continue;
}
if (null != m_stop && m_stop.before(date)) {
//Skip dates that are too late
LOGGER.fine("Filtering out "+cvsEntry+" because it's too late");
log("Filtering out "+cvsEntry+" because it's too late",Project.MSG_VERBOSE);
continue;
}
if (!cvsEntry.containsBranch(branch)) {
// didn't match the branch
LOGGER.fine("Filtering out "+cvsEntry+" because it didn't match the branch");
log("Filtering out "+cvsEntry+" because it didn't match the branch",Project.MSG_VERBOSE);
continue;
}
results.addElement(cvsEntry);
......@@ -435,6 +437,4 @@ public class ChangeLogTask extends AbstractCvsTask {
}
}
}
private static final Logger LOGGER = Logger.getLogger(ChangeLogTask.class.getName());
}
\ No newline at end of file
......@@ -21,19 +21,21 @@ import org.apache.tools.ant.taskdefs.PumpStreamHandler;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* A dummy stream handler that just passes stuff to the parser.
*
* @version $Revision$ $Date$
*/
class RedirectingStreamHandler
extends PumpStreamHandler {
class RedirectingStreamHandler extends PumpStreamHandler {
RedirectingStreamHandler(final ChangeLogParser parser) {
super(new RedirectingOutputStream(parser),
new ByteArrayOutputStream());
this(new RedirectingOutputStream(parser));
}
RedirectingStreamHandler(OutputStream out) {
super(out, new ByteArrayOutputStream());
}
String getErrors() {
try {
......
......@@ -425,6 +425,11 @@ public class CVSSCM extends AbstractCVSFamilySCM {
hadError[0] = true;
errorOutput.write(msg);
errorOutput.write('\n');
return;
}
if(debugLogging) {
errorOutput.write(msg);
errorOutput.write('\n');
}
}
};
......@@ -880,4 +885,12 @@ public class CVSSCM extends AbstractCVSFamilySCM {
}
}
}
/**
* Temporary hack for assisting trouble-shooting.
*
* <p>
* Setting this property to true would cause <tt>cvs log</tt> to dump a lot of messages.
*/
public static boolean debugLogging = false;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册