improve logging

This commit is contained in:
Sebastian Sdorra
2011-05-05 19:36:08 +02:00
parent 6fd04b19d3
commit 514c1e032b
2 changed files with 27 additions and 2 deletions

View File

@@ -79,7 +79,7 @@ public class HgChangesetViewer implements ChangesetViewer
+ "<files-added>{file_adds}</files-added>"
+ "<files-mods>{file_mods}</files-mods>"
+ "<files-dels>{file_dels}</files-dels>"
+ "</changeset>\n";
+ "</changeset>";
//J+
/** Field description */
@@ -150,6 +150,14 @@ public class HgChangesetViewer implements ChangesetViewer
new StringReader(sb.toString())));
changesets = new ChangesetPagingResult(total, changesetList);
}
else if ( logger.isErrorEnabled() )
{
logger.error(
"command for fetching changesets failed with exit code {} and output {}",
result.getReturnCode(),
result.getOutput()
);
}
}
catch (ParserConfigurationException ex)
@@ -197,7 +205,7 @@ public class HgChangesetViewer implements ChangesetViewer
*/
private int getTotalChangesets(String repositoryPath) throws IOException
{
int total = 0;
int total = -1;
Command command = new SimpleCommand(handler.getConfig().getHgBinary(),
"-R", repositoryPath, "tip", "--template",
TEMPLATE_TOTAL);
@@ -207,6 +215,14 @@ public class HgChangesetViewer implements ChangesetViewer
{
total = Integer.parseInt(result.getOutput().trim());
}
else if ( logger.isErrorEnabled() )
{
logger.error(
"could not read tip revision, command returned with exit code {} and content {}",
result.getReturnCode(),
result.getOutput()
);
}
return total;
}

View File

@@ -176,6 +176,15 @@ public class SimpleCommand implements Command
}
int returnCode = process.waitFor();
if ( logger.isDebugEnabled() )
{
logger.debug( "command returned with exitcode {}", returnCode );
if ( logger.isTraceEnabled() )
{
logger.trace("command content: {}{}", s, content.toString() );
}
}
result = new SimpleCommandResult(content.toString(), returnCode);
}