org.ggp.base.util.logging.LogSummaryGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alloy-ggp-base Show documentation
Show all versions of alloy-ggp-base Show documentation
A modified version of the GGP-Base library for Alloy.
The newest version!
package org.ggp.base.util.logging;
import java.io.File;
import java.io.FilenameFilter;
public abstract class LogSummaryGenerator {
public String getLogSummary(String matchId) {
final String thePrefix = matchId;
File logsDirectory = new File("logs");
FilenameFilter logsFilter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith(thePrefix);
}
};
String[] theMatchingMatches = logsDirectory.list(logsFilter);
if (theMatchingMatches == null) {
System.err.println("Log summary retrieval for " + matchId + " yielded an error.");
} else if (theMatchingMatches.length > 1) {
System.err.println("Log summary retrieval for " + matchId + " matched multiple matches.");
} else if (theMatchingMatches.length == 0) {
System.err.println("Log summary retrieval for " + matchId + " matched zero matches.");
} else {
return getSummaryFromLogsDirectory(logsDirectory + "/" + theMatchingMatches[0]);
}
return null;
}
public abstract String getSummaryFromLogsDirectory(String theLogsDirectory);
}