in agent/src/jetbrains/buildServer/xmlReportPlugin/XmlReportPlugin.java [344:451]
private void logStatistics(@NotNull final RulesContext rulesContext) {
final BuildProgressLogger logger = getBuild().getBuildLogger();
final Map<File, ParsingResult> succeeded = rulesContext.getRulesState().getProcessedFiles();
final Map<File, ParsingResult> failedToParse = rulesContext.getRulesState().getFailedToProcessFiles();
final List<File> outOfDate = rulesContext.getRulesState().getOutOfDateFiles();
final int processedFileCount = succeeded.size() + failedToParse.size();
final LogAction summaryLogAction = processedFileCount == 0 ? rulesContext.getRulesData().getWhenNoDataPublished() : LogAction.INFO;
if (summaryLogAction == LogAction.DO_NOTHING) return;
LoggingUtils.logInTarget(LoggingUtils.getTypeDisplayName(rulesContext.getRulesData().getType()) + " report watcher",
new Runnable() {
public void run() {
final int totalFileCount = processedFileCount + outOfDate.size();
summaryLogAction.doLogAction(
totalFileCount == 0
? "No reports found for paths:"
: totalFileCount + " " + StringUtil.pluralize("report", totalFileCount) + " found for paths:", logger);
final Collection<String> rules = rulesContext.getRulesData().getRules().getBody();
if (rules.isEmpty()) {
LoggingUtils.warn("<no paths>", logger);
}
for (String rule : rules) {
summaryLogAction.doLogAction(rule, logger);
}
final ParsingResult result = getParserFactory(rulesContext.getRulesData().getType()).createEmptyResult();
if (!failedToParse.isEmpty()) {
LoggingUtils.logInTarget("Parsing errors",
new Runnable() {
public void run() {
LoggingUtils
.error("Failed to parse " + failedToParse.size() + " " + StringUtil.pluralize("report", failedToParse.size()), logger);
for (Map.Entry<File, ParsingResult> parsedFile : failedToParse.entrySet()) {
final ParsingResult parsingResult = parsedFile.getValue();
final File file = parsedFile.getKey();
final Throwable problem = getProblem(parsingResult);
String path = getPathInCheckoutDir(file);
if (problem == null) path = path + ": Report is incomplete or has unexpected structure";
else if (StringUtil.isNotEmpty(problem.getMessage())) path = path + ": " + problem.getMessage();
LoggingUtils.logError(path, problem, logger, rulesContext.getRulesData().isVerbose() || failedToParse.size() == 1);
result.accumulate(parsingResult);
}
}
}, logger);
if (rulesContext.getRulesData().failBuildIfParsingFailed()) {
logger.logBuildProblem(createBuildProblem(rulesContext.getRulesData().getType(), failedToParse.keySet()));
}
}
if (!succeeded.isEmpty()) {
LoggingUtils.logInTarget("Successfully parsed",
new Runnable() {
public void run() {
LoggingUtils
.message(succeeded.size() + " " + StringUtil.pluralize("report", succeeded.size()), logger);
for (Map.Entry<File, ParsingResult> parsedFile : succeeded.entrySet()) {
final ParsingResult parsingResult = parsedFile.getValue();
final File file = parsedFile.getKey();
final String path = getPathInCheckoutDir(file);
if (rulesContext.getRulesData().isVerbose() || succeeded.size() == 1) {
LoggingUtils.message(path, logger);
} else {
LoggingUtils.LOG.debug(path);
}
result.accumulate(parsingResult);
}
}
}, logger);
}
if (!outOfDate.isEmpty()) {
LoggingUtils.logInTarget("Skipped as out-of-date", new Runnable() {
@Override
public void run() {
LoggingUtils.verbose("Processing start time is: [" + rulesContext.getRulesData().getMonitorRulesParameters().getStartTime() + "]", logger);
summaryLogAction.doLogAction(outOfDate.size() + " " + StringUtil.pluralize("report", outOfDate.size()), logger);
for (File outOfDateFile : outOfDate) {
final String path = getPathInCheckoutDir(outOfDateFile);
final String details = path + " has last modified timestamp [" + outOfDateFile.lastModified() + "]";
if (rulesContext.getRulesData().isVerbose() || outOfDate.size() == 1 || processedFileCount == 0) {
summaryLogAction.doLogAction(path, logger);
}
LoggingUtils.verbose(details, logger);
}
}
}, logger);
}
result.logAsTotalResult(rulesContext.getRulesData().getParseReportParameters());
}
}, logger);
}